feat(user) : UI archivage/désarchivage des utilisateurs côté admin
- badge « Archivé » et libellé barré dans la liste admin - popup de confirmation avant archivage (rappelle que c'est réversible) - bouton de restauration (PATCH archived:false) pour les archivés - case « Afficher les utilisateurs archivés » (filtre ?archived=true) - masque l'action d'archivage sur son propre compte (évite le 403) - service users : getArchived/restore, toast remove -> users.archived - i18n FR : clés archived/restored/badge/confirmation
This commit is contained in:
@@ -10,6 +10,8 @@ export type UserData = {
|
||||
effectivePermissions?: string[]
|
||||
avatarUrl?: string | null
|
||||
apiToken?: string | null
|
||||
// Soft-delete flag: an archived user keeps its data but cannot log in
|
||||
archived?: boolean
|
||||
// HR / absence management
|
||||
isEmployee?: boolean
|
||||
hireDate?: string | null
|
||||
|
||||
@@ -10,6 +10,13 @@ export function useUserService() {
|
||||
return extractHydraMembers(data)
|
||||
}
|
||||
|
||||
// Archived users are hidden from the default collection; an admin lists
|
||||
// them explicitly via the `archived` filter (handled server-side).
|
||||
async function getArchived(): Promise<UserData[]> {
|
||||
const data = await api.get<HydraCollection<UserData>>('/users?archived=true')
|
||||
return extractHydraMembers(data)
|
||||
}
|
||||
|
||||
async function getById(id: number): Promise<UserData> {
|
||||
return api.get<UserData>(`/users/${id}`)
|
||||
}
|
||||
@@ -26,11 +33,19 @@ export function useUserService() {
|
||||
})
|
||||
}
|
||||
|
||||
// Deleting a user is a soft delete server-side: the account is archived
|
||||
// (kept for referential integrity) rather than removed.
|
||||
async function remove(id: number): Promise<void> {
|
||||
await api.delete(`/users/${id}`, {}, {
|
||||
toastSuccessKey: 'users.deleted',
|
||||
toastSuccessKey: 'users.archived',
|
||||
})
|
||||
}
|
||||
|
||||
return { getAll, getById, create, update, remove }
|
||||
async function restore(id: number): Promise<UserData> {
|
||||
return api.patch<UserData>(`/users/${id}`, { archived: false }, {
|
||||
toastSuccessKey: 'users.restored',
|
||||
})
|
||||
}
|
||||
|
||||
return { getAll, getArchived, getById, create, update, remove, restore }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user