From 1dcf8bfbcb2d144140a87c2f7212f7538bae8ed8 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Tue, 7 Jul 2026 12:42:50 +0000 Subject: [PATCH] AdminDepartments: light theme, group by location, location_name support Co-Authored-By: Claude Sonnet 4.6 --- src/pages/AdminDepartments.tsx | 110 ++++++++++++++++++++------------- 1 file changed, 68 insertions(+), 42 deletions(-) diff --git a/src/pages/AdminDepartments.tsx b/src/pages/AdminDepartments.tsx index f15b52a..65d8d43 100644 --- a/src/pages/AdminDepartments.tsx +++ b/src/pages/AdminDepartments.tsx @@ -6,6 +6,8 @@ interface WfDept { id: string name: string staff_count: number + location_id: string | null + location_name: string | null mapped_role_id: number | null } @@ -80,6 +82,16 @@ export function AdminDepartments({ user }: { user: User }) { } } + // Group departments by location + const locations = Array.from(new Set(depts.map(d => d.location_name ?? ''))).filter(Boolean) + const hasMultipleLocations = locations.length > 1 + const grouped: Record = {} + for (const d of depts) { + const key = d.location_name ?? '' + if (!grouped[key]) grouped[key] = [] + grouped[key].push(d) + } + return (
@@ -96,53 +108,67 @@ export function AdminDepartments({ user }: { user: User }) {
- {syncResult && ( -
- {syncResult} -
- )} - -

+

Map Workforce departments to roles. Self-registering employees will automatically receive the role mapped to their department.

- {error &&

{error}

} + {syncResult && ( +
+ {syncResult} +
+ )} + + {error &&

{error}

} {loading ? ( -

Loading departments…

+

Loading departments…

) : ( -
- {depts.map(dept => ( -
-
-
{dept.name}
-
- {dept.staff_count} staff +
+ {Object.entries(grouped).map(([location, locationDepts]) => ( +
+ {hasMultipleLocations && location && ( +
+ {location}
-
- setMappings(m => ({ + ...m, [dept.id]: e.target.value ? Number(e.target.value) : null + }))} + style={{ + background: 'var(--body-bg)', border: '1px solid var(--card-border)', + borderRadius: '6px', color: 'var(--text-dark)', padding: '0.4rem 0.6rem', + fontSize: '0.82rem', minWidth: '160px', + }} + > + + {roles.map(r => ( + + ))} + +
))} - +
))}
@@ -153,10 +179,10 @@ export function AdminDepartments({ user }: { user: User }) { } const goldBtn: React.CSSProperties = { - background: 'var(--gold)', color: 'var(--navy-dark)', border: 'none', - borderRadius: '6px', padding: '0.5rem 1rem', fontSize: '0.875rem', fontWeight: 600, + background: 'var(--navy)', color: '#fff', border: 'none', + borderRadius: '6px', padding: '0.5rem 1rem', fontSize: '0.875rem', fontWeight: 600, cursor: 'pointer', } const mutedBtn: React.CSSProperties = { - background: 'var(--surface-2)', color: 'var(--text-muted)', border: '1px solid var(--surface-2)', - borderRadius: '6px', padding: '0.5rem 1rem', fontSize: '0.875rem', + background: 'var(--body-bg)', color: 'var(--text-mid)', border: '1px solid var(--card-border)', + borderRadius: '6px', padding: '0.5rem 1rem', fontSize: '0.875rem', cursor: 'pointer', }