Skip to content

refactor: breakdown Tasks component to Dialogs#236

Merged
its-me-abhishek merged 11 commits intoCCExtractor:mainfrom
Neeraj-gagat:refactor/task.tsx
Dec 8, 2025
Merged

refactor: breakdown Tasks component to Dialogs#236
its-me-abhishek merged 11 commits intoCCExtractor:mainfrom
Neeraj-gagat:refactor/task.tsx

Conversation

@Neeraj-gagat
Copy link
Copy Markdown
Contributor

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

import { useState, useEffect } from 'react';
import { Task } from '../../utils/types';

export interface EditTaskState {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move these interfaces to types.ts

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@its-me-abhishek
Copy link
Copy Markdown
Collaborator

Please add the relevant test cases for new files, functions, etc.

Copy link
Copy Markdown
Contributor Author

@Neeraj-gagat Neeraj-gagat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done with the selff review nothing changed on the ui level . so the old tests cover everything the only tests pending were for file useEditTask custom hook. so i added tests for that file. let me know if i need to do any more changes

Copy link
Copy Markdown
Collaborator

@its-me-abhishek its-me-abhishek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these extra lines every where

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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']));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shall be moved to the types.ts file as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -0,0 +1,202 @@
import { Badge } from '@/components/ui/badge';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add test cases for this file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added test cases for AddTaskDialog file

@@ -0,0 +1,1233 @@
import { Task } from '../../utils/types';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add test cases for this file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added test case for EditTaskdialog file

};

const handleProjectSaveClick = (task: Task) => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the old names for these functions make sense, and shall be reverted

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted functions back to old names

@@ -0,0 +1,81 @@
import { useState, useEffect } from 'react';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the file name shall have a capital U as we use PascalCase for tsx files and camelCase/kebab-case

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is done

@Neeraj-gagat
Copy link
Copy Markdown
Contributor Author

@its-me-abhishek okk am on it. will fix these soon

Comment thread frontend/src/components/HomeComponents/Tasks/AddTaskDialog.tsx Outdated
@Neeraj-gagat
Copy link
Copy Markdown
Contributor Author

@its-me-abhishek on it fixing them now

@Neeraj-gagat
Copy link
Copy Markdown
Contributor Author

Resolving the conflicts now

@Neeraj-gagat
Copy link
Copy Markdown
Contributor Author

hey @its-me-abhishek i have fixed merge conflicts its ready to review

Copy link
Copy Markdown
Collaborator

@its-me-abhishek its-me-abhishek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT:

Rename Edit Task Dialog to TaskDialog since there is no separate task dialog, and both viewing and editing happen within the same unified interface.

Please fix, will merge then

@Neeraj-gagat
Copy link
Copy Markdown
Contributor Author

Neeraj-gagat commented Dec 8, 2025

EDIT:

Rename Edit Task Dialog to TaskDialog since there is no separate task dialog, and both viewing and editing happen within the same unified interface.

Please fix, will merge then

@its-me-abhishek Did you mean EditTaskDialog file or component??? Or did you mean everywhere file, component, interface ??

@its-me-abhishek its-me-abhishek changed the title seperated addtaskdialog && edittaskdialog refactor: breakdown Tasks component to Dialogs Dec 8, 2025
@its-me-abhishek
Copy link
Copy Markdown
Collaborator

Just the EditTaskDialog file and function names to TaskDialog

@Neeraj-gagat
Copy link
Copy Markdown
Contributor Author

Just the EditTaskDialog file and function names to TaskDialog

okk fixing it

Copy link
Copy Markdown
Collaborator

@its-me-abhishek its-me-abhishek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test files' name is incorrect for TaskDialog, EditTaskDialog needs to be re named

@Neeraj-gagat
Copy link
Copy Markdown
Contributor Author

the test files' name is incorrect for TaskDialog, EditTaskDialog needs to be re named

sorry changing it now in a minute

@its-me-abhishek its-me-abhishek merged commit b414b99 into CCExtractor:main Dec 8, 2025
4 checks passed
ShivaGupta-14 pushed a commit to ShivaGupta-14/ccsync that referenced this pull request Dec 25, 2025
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Break down Tasks.tsx into smaller files and utilities with incremental, tested PRs

2 participants