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;