feat(dict): 7-day retention auto-purge + inline restore UI
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user