-
Notifications
You must be signed in to change notification settings - Fork 167
feat(1263): Add purpose & status to task card, based on task card in website-my #1319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
96602a6
8f34209
c790c99
045a8d6
d615a30
2088552
90f78e4
a30aebe
f89f1a8
de52c89
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,15 +5,24 @@ import task, { | |||||||||||||||||||||||
| import { useState } from 'react'; | ||||||||||||||||||||||||
| import styles from '@/components/tasks/card/card.module.scss'; | ||||||||||||||||||||||||
| import { PENDING, SAVED, ERROR_STATUS } from '../constants'; | ||||||||||||||||||||||||
| import { useUpdateTaskMutation } from '@/app/services/tasksApi'; | ||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||
| useUpdateTaskMutation, | ||||||||||||||||||||||||
| useUpdateSelfTaskMutation, | ||||||||||||||||||||||||
| } from '@/app/services/tasksApi'; | ||||||||||||||||||||||||
| import { StatusIndicator } from './StatusIndicator'; | ||||||||||||||||||||||||
| import TaskDropDown from '../TaskDropDown'; | ||||||||||||||||||||||||
| import { TASK_STATUS_MAPING } from '@/constants/constants'; | ||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||
| STATUS_UPDATE_ERROR, | ||||||||||||||||||||||||
| STATUS_UPDATE_SUCCESSFUL, | ||||||||||||||||||||||||
| TASK_STATUS_MAPING, | ||||||||||||||||||||||||
| } from '@/constants/constants'; | ||||||||||||||||||||||||
| import { toast, ToastTypes } from '@/helperFunctions/toast'; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| type Props = { | ||||||||||||||||||||||||
| task: task; | ||||||||||||||||||||||||
| setEditedTaskDetails: React.Dispatch<React.SetStateAction<CardTaskDetails>>; | ||||||||||||||||||||||||
| isDevMode?: boolean; | ||||||||||||||||||||||||
| isSelfTask?: boolean; | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // TODO: remove this after fixing the card beautify status | ||||||||||||||||||||||||
|
|
@@ -33,11 +42,14 @@ const TaskStatusEditMode = ({ | |||||||||||||||||||||||
| task, | ||||||||||||||||||||||||
| setEditedTaskDetails, | ||||||||||||||||||||||||
| isDevMode, | ||||||||||||||||||||||||
| isSelfTask, | ||||||||||||||||||||||||
| }: Props) => { | ||||||||||||||||||||||||
| const [saveStatus, setSaveStatus] = useState(''); | ||||||||||||||||||||||||
| const [updateTask] = useUpdateTaskMutation(); | ||||||||||||||||||||||||
| const [updateSelfTask] = useUpdateSelfTaskMutation(); | ||||||||||||||||||||||||
| const { SUCCESS, ERROR } = ToastTypes; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const onChangeUpdateTaskStatus = ({ | ||||||||||||||||||||||||
| const onChangeUpdateTaskStatus = async ({ | ||||||||||||||||||||||||
| newStatus, | ||||||||||||||||||||||||
| newProgress, | ||||||||||||||||||||||||
| }: taskStatusUpdateHandleProp) => { | ||||||||||||||||||||||||
|
|
@@ -48,6 +60,21 @@ const TaskStatusEditMode = ({ | |||||||||||||||||||||||
| if (newProgress !== undefined) { | ||||||||||||||||||||||||
| payload.percentCompleted = newProgress; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||
| if (isDevMode && isSelfTask) { | ||||||||||||||||||||||||
| await updateSelfTask({ id: task.id, task: payload }).unwrap(); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| toast(SUCCESS, STATUS_UPDATE_SUCCESSFUL); | ||||||||||||||||||||||||
|
Comment on lines
+64
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The success toast is displayed unconditionally, regardless of whether try {
if (isDevMode && isSelfTask) {
await updateSelfTask({ id: task.id, task: payload }).unwrap();
toast(SUCCESS, STATUS_UPDATE_SUCCESSFUL);
}
}This way, the success message will only be shown when the task update operation is both attempted and completed successfully.
Suggested change
Spotted by Diamond |
||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||
| const errorMessage = | ||||||||||||||||||||||||
| error && typeof error === 'object' && 'data' in error | ||||||||||||||||||||||||
| ? (error.data as { message?: string }).message || | ||||||||||||||||||||||||
| STATUS_UPDATE_ERROR | ||||||||||||||||||||||||
| : STATUS_UPDATE_ERROR; | ||||||||||||||||||||||||
| toast(ERROR, errorMessage); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| setEditedTaskDetails((prev: CardTaskDetails) => ({ | ||||||||||||||||||||||||
| ...prev, | ||||||||||||||||||||||||
| ...payload, | ||||||||||||||||||||||||
|
|
@@ -80,7 +107,7 @@ const TaskStatusEditMode = ({ | |||||||||||||||||||||||
| oldProgress={task.percentCompleted} | ||||||||||||||||||||||||
| onChange={onChangeUpdateTaskStatus} | ||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||
| <StatusIndicator status={saveStatus} /> | ||||||||||||||||||||||||
| {!isDevMode && <StatusIndicator status={saveStatus} />} | ||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,6 +91,16 @@ | |
| color: #aeaeae; | ||
| } | ||
|
|
||
| .cardPurposeAndStatusFont { | ||
| font-size: 1.1rem; | ||
| color: #555; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use a predefined color from
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the colors that I used are not present in variables.css. I have taken them from my site. |
||
| } | ||
| .cardPurposeText { | ||
| padding: 8px; | ||
| color: #aeaeae; | ||
| font-size: 1rem; | ||
| } | ||
|
|
||
| .cardStatusFont { | ||
| font-size: 1.3rem; | ||
| font-weight: 500; | ||
|
|
@@ -247,10 +257,37 @@ | |
| justify-content: space-between; | ||
| } | ||
|
|
||
| .taskStatusDateAndPurposeContainer { | ||
| display: grid; | ||
| align-items: baseline; | ||
| grid-template-columns: 2fr 3fr; | ||
| gap: 2rem; | ||
| grid-auto-flow: column; | ||
| margin-bottom: 1rem; | ||
| } | ||
|
|
||
| .taskStatusEditMode { | ||
| margin-top: 0.8rem; | ||
| } | ||
|
|
||
| .taskStatusUpdate { | ||
| border: 1px solid #000000b3; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't find any existing css variables for this one. |
||
| border-radius: 4px; | ||
| font-size: inherit; | ||
| font-weight: bolder; | ||
| background-color: transparent; | ||
| color: $theme-primary-alt; | ||
| padding: 0.5rem; | ||
| height: 2.5rem; | ||
| width: 10rem; | ||
| transition: 250ms ease-in-out; | ||
| } | ||
|
|
||
| .taskStatusUpdate:hover { | ||
| background-color: $theme-primary-alt; | ||
| color: #ffffff; | ||
| } | ||
|
|
||
| .taskTagLevelWrapper { | ||
| display: flex; | ||
| padding-top: 0.5rem; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test verifies the UI state changes but doesn't confirm the actual API call functionality. Consider adding an assertion to verify that
updateSelfTaskMutationis called with the correct parameters:This would ensure the status update is properly propagated to the API layer, not just reflected in the UI component.
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.