From 4a78d31a7faecdfec63d93d8ecb66e75de52676a Mon Sep 17 00:00:00 2001 From: BOHA Date: Sat, 6 Jun 2026 01:20:24 +0200 Subject: [PATCH] fix(types): resolve all client TypeScript errors (attendance + plan rollback) - AttendanceAdmin: declare worked_hours_raw on UserTotalData (the hook sets it at runtime; the local interface omitted it) - usePlanWork.rollbackMutation: type the mutation param as unknown + explicit cast so passing the TanStack mutation result (with the dynamically-stashed _rolled) no longer trips the weak-type check tsc -p tsconfig.app.json --noEmit is now clean (0 errors, was 9). Co-Authored-By: Claude Opus 4.8 (1M context) --- src/admin/hooks/usePlanWork.ts | 18 +++++++++++------- src/admin/pages/AttendanceAdmin.tsx | 3 +++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/admin/hooks/usePlanWork.ts b/src/admin/hooks/usePlanWork.ts index 1c2b3a1..659c4a0 100644 --- a/src/admin/hooks/usePlanWork.ts +++ b/src/admin/hooks/usePlanWork.ts @@ -466,23 +466,27 @@ export function usePlanWork({ initialDate, canEdit }: UsePlanWorkArgs) { // Roll back an optimistic patch on mutation error. Called from // PlanWork's mutation wrappers via `rollbackMutation(mutation, key)`. - function rollbackMutation( - mutation: { _rolled?: Record | null }, - userId: number, - ) { - if (!mutation._rolled) return; + // `mutation` is a TanStack mutation result with a `_rolled` snapshot stashed + // on it (see the `(createEntry as any)._rolled = …` writes above). Typed as + // `unknown` + an explicit cast so callers can pass the mutation object + // directly without the "weak type" mismatch a `{ _rolled? }` param causes. + function rollbackMutation(mutation: unknown, userId: number) { + const stash = mutation as { + _rolled?: Record | null; + }; + if (!stash._rolled) return; const prev = qc.getQueryData(currentGridKey as any); if (!prev) return; const userPrev = prev.cells[userId] ?? {}; const userNext = { ...userPrev }; - for (const [date, cell] of Object.entries(mutation._rolled)) { + for (const [date, cell] of Object.entries(stash._rolled)) { userNext[date] = cell; } qc.setQueryData(currentGridKey, { ...prev, cells: { ...prev.cells, [userId]: userNext }, }); - mutation._rolled = null; + stash._rolled = null; } return { diff --git a/src/admin/pages/AttendanceAdmin.tsx b/src/admin/pages/AttendanceAdmin.tsx index 7fe6414..e2fd7d0 100644 --- a/src/admin/pages/AttendanceAdmin.tsx +++ b/src/admin/pages/AttendanceAdmin.tsx @@ -21,6 +21,9 @@ interface UserTotalData { unpaid_hours: number; fund: number | null; worked_hours: number; + // Raw worked hours incl. sub-day remainders (set by computeUserTotals in + // useAttendanceAdmin); used for the Fond "used" calculation below. + worked_hours_raw?: number; covered: number; missing: number; overtime: number;