feat(time): wire Timesheets page to the backend (MAPPS-125) #86

Merged
longjacksonle merged 1 commit from feat/mapps-125-wire-timesheets into main 2026-06-07 02:17:51 +02:00

What

Wires the Timesheets page (/timesheets, TimesheetsPage in src/pages/time.rs) to the live time-tracking API. It was a hardcoded weekly grid: fixed work-item rows (TKT-1234, PRJ-101, ...), hardcoded per-day hours, a hardcoded daily-total row, a decorative week selector anchored to Jan 13 2025, and a decorative Submit button.

Closes MAPPS-125.

How

  • Fetches the signed-in user's entries for the selected week via GET /time-entries?user_id=<me>&date_from=<mon>&date_to=<sun> and pivots them client-side into per-work-item rows with seven day buckets (Mon..Sun), summing duration_minutes into each (row, weekday) cell. Real daily totals and grand total.
  • The /timesheets summary endpoint returns week aggregates (total/billable minutes, entry count, approval status), not the per-work-item/day breakdown the grid needs, so the pivot is done in the client. The summary is consumed only for the week-level approval_status badge (Approved / Rejected / Pending approval / Not submitted).
  • Rows are labelled from GET /tickets (ticket_number: title) and GET /projects (Project: name), falling back to Internal for entries linked to neither.
  • The week now defaults to the current week (monday_of_week(today)) instead of the 2025 demo anchor; the prev/next selector re-runs the fetch.
  • Restores a working Submit Timesheet action: POST /timesheets/<user_id>/<week_start>/submit, disabled when the week has no entries or is already approved, refreshing the status badge on success.
  • Loading, empty (no time logged this week), and load-failed states replace the always-on demo grid. Removed the now-unused TimesheetRow component.

Dependency

The grid load depends on PMS-145 (the GET /time-entries ORDER BY 500 fix) being deployed; without it the grid shows the load-failed state.

Verification

  • cargo fmt --check clean; cargo clippy --target wasm32-unknown-unknown --all-targets -- -D warnings clean.
  • Against the live dev-sso stack with a real Bunyip token: GET /projects 200, GET /timesheets?user_id=&week= 200, GET /time-entries?user_id=&date_from=&date_to= 200 (all empty on the fresh dev DB, so the page renders the empty + Not-submitted states as expected).

🤖 Generated with Claude Code

## What Wires the Timesheets page (`/timesheets`, `TimesheetsPage` in `src/pages/time.rs`) to the live time-tracking API. It was a hardcoded weekly grid: fixed work-item rows (`TKT-1234`, `PRJ-101`, ...), hardcoded per-day hours, a hardcoded daily-total row, a decorative week selector anchored to Jan 13 2025, and a decorative Submit button. Closes MAPPS-125. ## How - Fetches the signed-in user's entries for the selected week via `GET /time-entries?user_id=<me>&date_from=<mon>&date_to=<sun>` and pivots them client-side into per-work-item rows with seven day buckets (Mon..Sun), summing `duration_minutes` into each (row, weekday) cell. Real daily totals and grand total. - The `/timesheets` summary endpoint returns week aggregates (total/billable minutes, entry count, approval status), not the per-work-item/day breakdown the grid needs, so the pivot is done in the client. The summary is consumed only for the week-level `approval_status` badge (Approved / Rejected / Pending approval / Not submitted). - Rows are labelled from `GET /tickets` (`ticket_number: title`) and `GET /projects` (`Project: name`), falling back to `Internal` for entries linked to neither. - The week now defaults to the current week (`monday_of_week(today)`) instead of the 2025 demo anchor; the prev/next selector re-runs the fetch. - Restores a working Submit Timesheet action: `POST /timesheets/<user_id>/<week_start>/submit`, disabled when the week has no entries or is already approved, refreshing the status badge on success. - Loading, empty (no time logged this week), and load-failed states replace the always-on demo grid. Removed the now-unused `TimesheetRow` component. ## Dependency The grid load depends on PMS-145 (the `GET /time-entries` ORDER BY 500 fix) being deployed; without it the grid shows the load-failed state. ## Verification - `cargo fmt --check` clean; `cargo clippy --target wasm32-unknown-unknown --all-targets -- -D warnings` clean. - Against the live dev-sso stack with a real Bunyip token: `GET /projects` 200, `GET /timesheets?user_id=&week=` 200, `GET /time-entries?user_id=&date_from=&date_to=` 200 (all empty on the fresh dev DB, so the page renders the empty + Not-submitted states as expected). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(time): wire Timesheets page to the backend (MAPPS-125)
All checks were successful
Check / clippy + fmt + tests (pull_request) Successful in 43s
Create release / Create release from merged PR (pull_request) Has been skipped
0807f923d5
The Timesheets page rendered a hardcoded weekly grid (fixed work-item rows, hardcoded per-day hours, a hardcoded daily-total row) anchored to a Jan 2025 demo week, with a decorative Submit button. It now builds the grid from real data.

It fetches the signed-in user's entries for the selected week via GET /time-entries?user_id=<me>&date_from=<mon>&date_to=<sun> and pivots them client-side into per-work-item rows with seven day buckets (Mon..Sun), summing duration into each (row, weekday) cell, with real daily totals and a grand total. The /timesheets summary endpoint returns week aggregates rather than the per-work-item/day breakdown the grid needs, so the pivot is done here; the summary is used only for the week-level approval_status badge.

Rows are labelled from GET /tickets (ticket_number: title) and GET /projects (Project: name), falling back to Internal for entries linked to neither. The week defaults to the current week instead of the 2025 demo anchor. The Submit Timesheet action posts to /timesheets/<user_id>/<week_start>/submit, is disabled when the week has no entries or is already approved, and refreshes the status badge on success. Loading, empty (no time logged this week), and load-failed states replace the always-on demo grid.

Sibling of MAPPS-124; depends on PMS-145 (the GET /time-entries ORDER BY 500 fix) being deployed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
longjacksonle deleted branch feat/mapps-125-wire-timesheets 2026-06-07 02:17:51 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-apps!86
No description provided.