diff --git a/admin/src/pages/StaffTab.tsx b/admin/src/pages/StaffTab.tsx index a5c0c1c..7b435ca 100644 --- a/admin/src/pages/StaffTab.tsx +++ b/admin/src/pages/StaffTab.tsx @@ -40,48 +40,70 @@ export function StaffTab({ storeId }: { storeId: string }) { } } + async function switchRole(u: StaffUser) { + const next: StaffRole = u.role === 'MANAGER' ? 'EMPLOYEE' : 'MANAGER'; + if (!window.confirm(`${u.displayName} devient ${ROLE_LABEL[next]}. Ses sessions ouvertes seront fermées.`)) return; + try { + await api.patch(`${base}/${u.id}`, { role: next }); + reload(); + } catch (e) { + setError((e as Error).message); + } + } + + const active = staff.filter((u) => u.active); + const managers = active.filter((u) => u.role === 'MANAGER').length; + // Actifs d'abord, Dirigeants en tête. + const sorted = [...staff].sort((a, b) => Number(b.active) - Number(a.active) || a.role.localeCompare(b.role) || a.displayName.localeCompare(b.displayName)); + return ( <>
+ {active.length} compte{active.length > 1 ? 's' : ''} actif{active.length > 1 ? 's' : ''} · {managers} dirigeant{managers > 1 ? 's' : ''} +
+| Nom | -Rôle | -Statut | -Actions | -|
|---|---|---|---|---|
| {u.displayName} | -{u.email} | -{ROLE_LABEL[u.role]} | -{u.active ? Actif : Désactivé} | -- {' '} - - | -
Créez au moins un Dirigeant : il pourra ensuite ajouter lui-même son équipe depuis l’app MonEspacePro.
+ +- Aucun employé. Créez au moins un dirigeant pour que le magasin puisse utiliser l'app Pro. -
- )} -