diff --git a/frontend/components/admin/AdminUserTab.vue b/frontend/components/admin/AdminUserTab.vue index 5304d37..050f73c 100644 --- a/frontend/components/admin/AdminUserTab.vue +++ b/frontend/components/admin/AdminUserTab.vue @@ -11,15 +11,33 @@ /> +
+ +
+ + + + + + + + + diff --git a/frontend/i18n/locales/fr.json b/frontend/i18n/locales/fr.json index 9dabbc1..4eaebea 100644 --- a/frontend/i18n/locales/fr.json +++ b/frontend/i18n/locales/fr.json @@ -194,8 +194,16 @@ "created": "Utilisateur créé avec succès.", "updated": "Utilisateur mis à jour avec succès.", "deleted": "Utilisateur supprimé avec succès.", + "archived": "Utilisateur archivé avec succès.", + "restored": "Utilisateur restauré avec succès.", "addUser": "Ajouter un utilisateur", - "editUser": "Modifier un utilisateur" + "editUser": "Modifier un utilisateur", + "archivedBadge": "Archivé", + "showArchived": "Afficher les utilisateurs archivés", + "archive": "Archiver", + "restore": "Restaurer", + "archiveConfirmTitle": "Archiver l'utilisateur", + "archiveConfirmMessage": "Êtes-vous sûr de vouloir archiver l'utilisateur « {username} » ? Son compte sera désactivé (il ne pourra plus se connecter), mais ses données et son historique restent conservés. Vous pourrez le restaurer plus tard." }, "admin": { "roles": { diff --git a/frontend/services/dto/user-data.ts b/frontend/services/dto/user-data.ts index 148bac0..d652c07 100644 --- a/frontend/services/dto/user-data.ts +++ b/frontend/services/dto/user-data.ts @@ -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 diff --git a/frontend/services/users.ts b/frontend/services/users.ts index ce64cd3..f29e49b 100644 --- a/frontend/services/users.ts +++ b/frontend/services/users.ts @@ -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 { + const data = await api.get>('/users?archived=true') + return extractHydraMembers(data) + } + async function getById(id: number): Promise { return api.get(`/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 { await api.delete(`/users/${id}`, {}, { - toastSuccessKey: 'users.deleted', + toastSuccessKey: 'users.archived', }) } - return { getAll, getById, create, update, remove } + async function restore(id: number): Promise { + return api.patch(`/users/${id}`, { archived: false }, { + toastSuccessKey: 'users.restored', + }) + } + + return { getAll, getArchived, getById, create, update, remove, restore } }