Code Quality: Refactor Personal Timesheet Data Managment#1166
Open
b1ink0 wants to merge 10 commits intofeat/redesignfrom
Open
Code Quality: Refactor Personal Timesheet Data Managment#1166b1ink0 wants to merge 10 commits intofeat/redesignfrom
b1ink0 wants to merge 10 commits intofeat/redesignfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the personal timesheet page to centralize state/data-fetching in a dedicated provider and reduce rerenders by adopting use-context-selector, while splitting UI into a standalone table component.
Changes:
- Introduces
PersonalTimesheetProvider+ context-selector hook to manage personal timesheet state, filters, pagination, and realtime updates. - Extracts personal timesheet table UI into
PersonalTimesheetTableand adds helper utilities (mergeTimesheetData,validateDate). - Removes the previous generic timesheet reducer/utils and updates task row “liked” behavior to read liked tasks from context.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/packages/app/src/pages/timesheet/utils.ts | Removes old validateDate helper (moved/refactored under personal timesheet). |
| frontend/packages/app/src/pages/timesheet/reducer.ts | Removes old shared reducer in favor of personal-specific reducer/provider. |
| frontend/packages/app/src/pages/timesheet/team/teamTimesheetTable.tsx | Layout class adjustments and import formatting. |
| frontend/packages/app/src/pages/timesheet/personal/context.ts | Adds personal timesheet context using use-context-selector. |
| frontend/packages/app/src/pages/timesheet/personal/reducer.ts | Adds personal-specific reducer/state machine for filters/pagination/realtime merge. |
| frontend/packages/app/src/pages/timesheet/personal/provider.tsx | Adds provider that fetches timesheet + liked tasks and wires realtime updates. |
| frontend/packages/app/src/pages/timesheet/personal/utils.ts | Adds mergeTimesheetData and refactored validateDate. |
| frontend/packages/app/src/pages/timesheet/personal/personalTimesheetTable.tsx | Extracts UI, wires to context selectors, keeps infinite scroll + task log. |
| frontend/packages/app/src/pages/timesheet/personal/index.tsx | Simplifies page to provider + table composition. |
| frontend/packages/app/src/components/timesheet-row/personalTimesheetRow.tsx | Removes liked-task props passthrough; relies on TaskRow behavior. |
| frontend/packages/app/src/components/timesheet-row/components/row/types.ts | Removes liked-task props from TaskRowProps. |
| frontend/packages/app/src/components/timesheet-row/components/row/taskRow.tsx | Reads liked tasks from personal context and removes post-toggle refresh callback. |
Comments suppressed due to low confidence (1)
frontend/packages/app/src/components/timesheet-row/components/row/taskRow.tsx:120
- After toggling a task like, the provider’s
likedTaskDatais never refreshed/updated. SincetaskLikedis re-derived fromlikedTaskDataon mount, rows that remount later (or other parts of the UI) can show a stale liked state until a full refresh. Consider updating thelikedTaskDatain context optimistically, or invalidating/refetching theget_liked_tasksquery aftertoggle_likesucceeds.
const handleStar = async (
e: React.MouseEvent<HTMLButtonElement>,
taskKey: string,
): Promise<void> => {
e.stopPropagation();
const data = {
name: taskKey,
add: taskLiked ? "No" : "Yes",
doctype: "Task",
};
setTaskLiked((prev) => !prev);
try {
await toggleLikeCall(data);
} catch (err) {
const error = parseFrappeErrorMsg(
err as Parameters<typeof parseFrappeErrorMsg>[0],
);
toast.error(error);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
frontend/packages/app/src/pages/timesheet/personal/personalTimesheetTable.tsx
Show resolved
Hide resolved
This ensures that incorrect aggregation of time entries is not displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR improves personal timesheet data management by using
use-context-selectorlibrary.Screenshot/Screencast
Loading UI when filtering:
Screen.Recording.2026-04-08.at.12.49.30.PM.mov
Checklist