diff --git a/src/admin/components/PlanGrid.tsx b/src/admin/components/PlanGrid.tsx index 6ae5b55..f3ca636 100644 --- a/src/admin/components/PlanGrid.tsx +++ b/src/admin/components/PlanGrid.tsx @@ -1,5 +1,12 @@ import { useMemo } from "react"; -import { GridData, ResolvedCell, planCategoryLabel } from "../lib/queries/plan"; +import type { CSSProperties } from "react"; +import { + GridData, + ResolvedCell, + planCategoryLabel, + categoryMap, + PlanCategory, +} from "../lib/queries/plan"; import type { Project } from "../lib/queries/projects"; import PlanRangeChips from "./PlanRangeChips"; @@ -7,6 +14,7 @@ interface Props { data: GridData | undefined; canEdit: boolean; projects: Project[]; + categories: PlanCategory[]; // The (userId, date) of the most recent successful mutation. The // matching cell gets a one-shot highlight pulse. `nonce` is part of // the value so back-to-back mutations on the same cell re-trigger @@ -92,10 +100,12 @@ export default function PlanGrid({ data, canEdit, projects, + categories, pulseKey, onCellClick, }: Props) { const today = useMemo(() => todayIso(), []); + const catMap = useMemo(() => categoryMap(categories), [categories]); if (!data) return ( @@ -206,10 +216,17 @@ export default function PlanGrid({ diff --git a/src/admin/components/PlanRangeChips.tsx b/src/admin/components/PlanRangeChips.tsx index e3fa700..c1723a7 100644 --- a/src/admin/components/PlanRangeChips.tsx +++ b/src/admin/components/PlanRangeChips.tsx @@ -1,17 +1,19 @@ -import { - ResolvedCell, - planCategoryLabel, - cellProjectLabel, -} from "../lib/queries/plan"; +import { ResolvedCell, cellProjectLabel } from "../lib/queries/plan"; import type { Project } from "../lib/queries/projects"; interface Props { cell: ResolvedCell | null; project: Project | null; readonly?: boolean; + categoryLabel: string; } -export default function PlanRangeChips({ cell, project, readonly }: Props) { +export default function PlanRangeChips({ + cell, + project, + readonly, + categoryLabel, +}: Props) { void readonly; if (!cell) return null; // Prefer the server-embedded project label (always present). Fall back to @@ -27,9 +29,7 @@ export default function PlanRangeChips({ cell, project, readonly }: Props) { return (