feat(dict): 7-day retention auto-purge + inline restore UI

This commit is contained in:
Александр Зимин
2026-06-09 13:40:23 +00:00
parent 05d2093273
commit 8621687a60
5 changed files with 286 additions and 3 deletions
+25
View File
@@ -783,6 +783,31 @@ export const useDictionaries = () => useQuery(dictionariesQuery)
export const useDictionaryDetail = (name: string | undefined) =>
useQuery({ ...dictionaryDetailQuery(name ?? ''), enabled: Boolean(name) })
/**
* Soft-deleted справочники (Корзина admin page). Admin-only — non-admin
* получит 403, fallback на пустой массив. 7-day retention window: dict
* физически purgе'ится через DictionaryPurgeJob cron после deleted_at +
* 7 дней. Restore возможен ТОЛЬКО до purge.
*/
export const useDictionariesDeleted = (enabled = true) =>
useQuery({
queryKey: ['dictionaries', 'deleted'],
queryFn: async (): Promise<DictionaryDetail[]> => {
try {
const { data } = await apiClient.get<DictionaryDetail[]>('/dictionaries/deleted')
return data
} catch (err) {
if ((err as { response?: { status?: number } })?.response?.status === 403) {
return []
}
throw err
}
},
enabled,
staleTime: 30_000,
retry: false,
})
/**
* Список всех закэшированных юзеров — для пикеров «Пользователь» в
* фильтрах audit/reviews. INTERNAL+ scope; non-INTERNAL получит 403,