-
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?
feat(1263): Add purpose & status to task card, based on task card in website-my #1319
Conversation
|
@Saitharun279 is attempting to deploy a commit to the RDS-Team Team on Vercel. A member of the Team first needs to authorize it. |
tejaskh3
left a comment
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.
- Please update this branch with develop.
- please pass me the link to the design you have updated.
- and if there is any design doc created for this task, please attach that to this PR details.
|
AnujChhikara
left a comment
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.
Hello @Saitharun279, could you please check if we can use predefined color variables from variables.scss instead of adding random colors?
| Purpose:{' '} | ||
| </b> | ||
| <span className={styles.cardPurposeText}> | ||
| {editedTaskDetails.purpose} |
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.
do we have purpose field when we create the TCR from status site?
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.
I just checked, it is not present in the TCR.
I think it needs to be added.
|
|
||
| .cardPurposeAndStatusFont { | ||
| font-size: 1.1rem; | ||
| color: #555; |
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.
Can we use a predefined color from variables.scss here?
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.
All the colors that I used are not present in variables.css. I have taken them from my site.
should i add them in variables.scss ?
|
Attached mobile video |
| } | ||
|
|
||
| .taskStatusUpdate { | ||
| border: 1px solid #000000b3; |
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.
- are there existing css variables we can use instead of hardcoding the color?
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.
Didn't find any existing css variables for this one.
src/components/tasks/card/index.tsx
Outdated
| }; | ||
| const isEditable = shouldEdit && isUserAuthorized && isEditMode; | ||
| const isSelfTask = editedTaskDetails.assignee === data?.username; | ||
| const verifiedTask = |
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.
- should this be named
isTaskCompletedas we're doing a check on the percentage this task has be completed?
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.
- The dropdown to update task staus should only be shown for non verified tasks, this variable
verifiedTaskis to check if task status is verified. - The check for 100 percent completion can be removed, as the status updation API allows update to Verified when percentage is 100.
I will remove this percentage check in next commit.
I think the variable can be renamed to isVerifiedTask.
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.
Removed 100 percentage check and modified variable name to isVerifiedTask
| const [updateTask] = useUpdateTaskMutation(); | ||
| const [updateSelfTask] = useUpdateSelfTaskMutation(); | ||
|
|
||
| const onChangeUpdateTaskStatus = ({ |
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.
- can we update this function to use try catch to make this cleaner and easier to update? example:
const onChangeUpdateTaskStatus = async ({
newStatus,
newProgress,
}: taskStatusUpdateHandleProp) => {
setSaveStatus(PENDING);
const payload: { status: string; percentCompleted?: number } = {
status: newStatus,
};
if (newProgress !== undefined) {
payload.percentCompleted = newProgress;
}
setEditedTaskDetails((prev: CardTaskDetails) => ({
...prev,
...payload,
}));
try{
if (isDevMode && isSelfTask){
await updateSelfTask({ id: task.id, task: payload })
} else {
await updateTask({ id: task.id, task: payload });
}
} catch(error){
setSaveStatus(ERROR_STATUS);
} finally {
setTimeout(() => {
setSaveStatus('');
}, 3000);
}
};- should we call
setEditedTaskDetailsafter the API call is successful preventing any inconsistent states? - can we remove the
setTimeoutfrom thefinallyblock?
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.
Will update in next commit.
But not sure about removing setTimeout, will check and update that as well.
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.
Done
|
…and toast messages.
| try { | ||
| if (isDevMode && isSelfTask) { | ||
| await updateSelfTask({ id: task.id, task: payload }).unwrap(); | ||
| } | ||
| toast(SUCCESS, STATUS_UPDATE_SUCCESSFUL); |
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.
The success toast is displayed unconditionally, regardless of whether updateSelfTask was executed or successful. Consider moving the toast inside the if block after the await call to ensure it only appears when the operation actually succeeds:
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.
| try { | |
| if (isDevMode && isSelfTask) { | |
| await updateSelfTask({ id: task.id, task: payload }).unwrap(); | |
| } | |
| toast(SUCCESS, STATUS_UPDATE_SUCCESSFUL); | |
| try { | |
| if (isDevMode && isSelfTask) { | |
| await updateSelfTask({ id: task.id, task: payload }).unwrap(); | |
| toast(SUCCESS, STATUS_UPDATE_SUCCESSFUL); | |
| } | |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
| it('change task status from BLOCKED to IN_PROGRESS when and isDevMode are true', async () => { | ||
| const setEditedTaskDetails = jest.fn(); | ||
|
|
||
| renderWithRouter( | ||
| <Provider store={store()}> | ||
| <TaskStatusEditMode | ||
| task={BLOCKED_TASK} | ||
| setEditedTaskDetails={setEditedTaskDetails} | ||
| isDevMode={true} | ||
| isSelfTask={true} | ||
| /> | ||
| </Provider> | ||
| ); | ||
|
|
||
| const statusSelect = screen.getByLabelText('Status:'); | ||
| expect(statusSelect).toHaveValue('BLOCKED'); | ||
|
|
||
| fireEvent.change(statusSelect, { target: { value: 'IN_PROGRESS' } }); | ||
| expect(statusSelect).toHaveValue('IN_PROGRESS'); | ||
| }); |
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 updateSelfTaskMutation is called with the correct parameters:
expect(updateSelfTaskSpy).toHaveBeenCalledWith({
id: BLOCKED_TASK.id,
task: expect.objectContaining({ status: 'IN_PROGRESS' })
});This would ensure the status update is properly propagated to the API layer, not just reflected in the UI component.
| it('change task status from BLOCKED to IN_PROGRESS when and isDevMode are true', async () => { | |
| const setEditedTaskDetails = jest.fn(); | |
| renderWithRouter( | |
| <Provider store={store()}> | |
| <TaskStatusEditMode | |
| task={BLOCKED_TASK} | |
| setEditedTaskDetails={setEditedTaskDetails} | |
| isDevMode={true} | |
| isSelfTask={true} | |
| /> | |
| </Provider> | |
| ); | |
| const statusSelect = screen.getByLabelText('Status:'); | |
| expect(statusSelect).toHaveValue('BLOCKED'); | |
| fireEvent.change(statusSelect, { target: { value: 'IN_PROGRESS' } }); | |
| expect(statusSelect).toHaveValue('IN_PROGRESS'); | |
| }); | |
| it('change task status from BLOCKED to IN_PROGRESS when isSelfTask and isDevMode are true', async () => { | |
| const setEditedTaskDetails = jest.fn(); | |
| const updateSelfTaskSpy = jest.fn().mockResolvedValue({}); | |
| jest.spyOn(taskHooks, 'useUpdateSelfTaskMutation').mockReturnValue([updateSelfTaskSpy, { isLoading: false }]); | |
| renderWithRouter( | |
| <Provider store={store()}> | |
| <TaskStatusEditMode | |
| task={BLOCKED_TASK} | |
| setEditedTaskDetails={setEditedTaskDetails} | |
| isDevMode={true} | |
| isSelfTask={true} | |
| /> | |
| </Provider> | |
| ); | |
| const statusSelect = screen.getByLabelText('Status:'); | |
| expect(statusSelect).toHaveValue('BLOCKED'); | |
| fireEvent.change(statusSelect, { target: { value: 'IN_PROGRESS' } }); | |
| expect(statusSelect).toHaveValue('IN_PROGRESS'); | |
| expect(updateSelfTaskSpy).toHaveBeenCalledWith({ | |
| id: BLOCKED_TASK.id, | |
| task: expect.objectContaining({ status: 'IN_PROGRESS' }) | |
| }); | |
| }); |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
Date: 17 January, 2025
Developer Name: Saitharun B
Issue Ticket Number
Description
Added code changes to let task owner do the following:
Documentation Updated?
Under Feature Flag
Database Changes
Breaking Changes
Development Tested?
Screenshots
Web
local_testing.mov
mobile
local.testing.moble.mov
Test Coverage
Screenshot
Additional Notes
design doc link