refactor: breakdown Tasks component to Dialogs#236
refactor: breakdown Tasks component to Dialogs#236its-me-abhishek merged 11 commits intoCCExtractor:mainfrom
Conversation
| import { useState, useEffect } from 'react'; | ||
| import { Task } from '../../utils/types'; | ||
|
|
||
| export interface EditTaskState { |
There was a problem hiding this comment.
please move these interfaces to types.ts
|
Please add the relevant test cases for new files, functions, etc. |
its-me-abhishek
left a comment
There was a problem hiding this comment.
Please fix these, and add test cases for these changes, as the changes are too big and might lead to breaking changes.
| const today = new Date(); | ||
| const yesterday = new Date(today); | ||
| const referenceDate = new Date('2024-01-10T12:00:00Z'); | ||
|
|
There was a problem hiding this comment.
remove these extra lines every where
There was a problem hiding this comment.
and use just prettier
| const callArg = hooks.editTaskOnBackend.mock.calls[0][0]; | ||
|
|
||
| expect(callArg.tags).toEqual(expect.arrayContaining(['newtag', '-tag1'])); | ||
| expect(callArg.tags).toEqual(expect.arrayContaining(['newtag', 'tag1'])); |
There was a problem hiding this comment.
this does not remove a tag though, just makes the test pass, but in a wrong way I guess
| import CopyToClipboard from 'react-copy-to-clipboard'; | ||
| import { formattedDate, handleCopy } from './tasks-utils'; | ||
|
|
||
| interface EditTaskDialogProps { |
There was a problem hiding this comment.
this shall be moved to the types.ts file as well
| @@ -0,0 +1,202 @@ | |||
| import { Badge } from '@/components/ui/badge'; | |||
There was a problem hiding this comment.
Please add test cases for this file
There was a problem hiding this comment.
added test cases for AddTaskDialog file
| @@ -0,0 +1,1233 @@ | |||
| import { Task } from '../../utils/types'; | |||
There was a problem hiding this comment.
Please add test cases for this file
There was a problem hiding this comment.
added test case for EditTaskdialog file
| }; | ||
|
|
||
| const handleProjectSaveClick = (task: Task) => { |
There was a problem hiding this comment.
I think the old names for these functions make sense, and shall be reverted
There was a problem hiding this comment.
reverted functions back to old names
| @@ -0,0 +1,81 @@ | |||
| import { useState, useEffect } from 'react'; | |||
There was a problem hiding this comment.
the file name shall have a capital U as we use PascalCase for tsx files and camelCase/kebab-case
|
@its-me-abhishek okk am on it. will fix these soon |
|
@its-me-abhishek on it fixing them now |
|
Resolving the conflicts now |
|
hey @its-me-abhishek i have fixed merge conflicts its ready to review |
@its-me-abhishek Did you mean EditTaskDialog file or component??? Or did you mean everywhere file, component, interface ?? |
|
Just the EditTaskDialog file and function names to TaskDialog |
okk fixing it |
its-me-abhishek
left a comment
There was a problem hiding this comment.
the test files' name is incorrect for TaskDialog, EditTaskDialog needs to be re named
sorry changing it now in a minute |
* seperated addtaskdialog && edittaskdialog * moved interfaces to types.ts * added tests for useEditTask.tsx * added tests for new files * fixed changes * resolved conflicts * changed names to TaskDialog * fixed name of testfile
Description
This PR refactors the existing Tasks.tsx component by extracting dialog-related UI and logic into modular, focused components. Previously, Tasks.tsx managed add/edit dialogs, keyboard shortcuts, and all task logic in a single file — causing state coupling, re-render issues, and flaky tests.
The refactor introduces:
✔ AddTaskDialog.tsx
✔ EditTaskDialog.tsx
✔ New custom hooks to centrally manage editing state
✔ Updated keyboard shortcuts logic to properly track selected task
✔ Properly highlights selected task using index passed from parent
✔ Removes direct state mutation issues inside Tasks.tsx
Separated dialog UIs and logic into standalone, reusable components
Introduced state management hook for editing:
Handles entry date, tags, and in-place editor toggles
Resets edit state when selected task changes
Fixed shortcut navigation support (↑ ↓ navigation indexes update correctly)
Eliminated inline DOM queries (getElementById) where possible
Improved test reliability:
No more uncontrolled act warnings
Pagination, overdue filtering, and tag update tests now stable
cleaned the old handlers which we not being used
Fixes: #230
Additional Notes
wroks fine as it used to before chnages let me know if you need any more changes or want me to chnage specific something