Skip to content

Code Quality: Refactor Personal Timesheet Data Managment#1166

Open
b1ink0 wants to merge 10 commits intofeat/redesignfrom
feat/refactor-personal-timesheet-data
Open

Code Quality: Refactor Personal Timesheet Data Managment#1166
b1ink0 wants to merge 10 commits intofeat/redesignfrom
feat/refactor-personal-timesheet-data

Conversation

@b1ink0
Copy link
Copy Markdown
Collaborator

@b1ink0 b1ink0 commented Apr 2, 2026

Description

This PR improves personal timesheet data management by using use-context-selector library.

Screenshot/Screencast

Loading UI when filtering:

Screen.Recording.2026-04-08.at.12.49.30.PM.mov

Checklist

  • I have carefully reviewed the code before submitting it for review.
  • This code is adequately covered by unit tests to validate its functionality.
  • I have conducted thorough testing to ensure it functions as intended.
  • A member of the QA team has reviewed and tested this PR (To be checked by QA or code reviewer)

@b1ink0 b1ink0 self-assigned this Apr 3, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 PersonalTimesheetTable and 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 likedTaskData is never refreshed/updated. Since taskLiked is re-derived from likedTaskData on mount, rows that remount later (or other parts of the UI) can show a stale liked state until a full refresh. Consider updating the likedTaskData in context optimistically, or invalidating/refetching the get_liked_tasks query after toggle_like succeeds.
  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.

b1ink0 added 2 commits April 8, 2026 12:45
This ensures that incorrect aggregation of time entries is not displayed.
@b1ink0 b1ink0 marked this pull request as ready for review April 8, 2026 08:24
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.

2 participants