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
+34
View File
@@ -158,6 +158,40 @@ export const useDeleteDictionary = () => {
},
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['dictionaries'] })
qc.invalidateQueries({ queryKey: ['dictionaries', 'deleted'] })
},
})
}
/**
* Восстановление soft-deleted справочника. Admin-only. Сбрасывает
* deleted_at/deleted_by в NULL → dict снова visible в списке.
*
* <p>7-day retention window: admin может вызвать restore в течение 7 дней
* после soft-delete. После — physical purge через DictionaryPurgeJob
* (backend cron). Восстановление невозможно после purge — только из DB
* backup.
*
* <p>Backend errors:
* <ul>
* <li>403 forbidden_role — не admin</li>
* <li>404 dictionary_not_found — name never existed</li>
* <li>409 not_deleted — dict не помечен как удалённый</li>
* </ul>
*/
export const useRestoreDictionary = () => {
const qc = useQueryClient()
return useMutation({
mutationFn: async (name: string): Promise<DictionaryDetail> => {
const { data } = await apiClient.post<DictionaryDetail>(
`/dictionaries/${name}/restore`,
)
return data
},
onSuccess: (_, name) => {
qc.invalidateQueries({ queryKey: ['dictionaries'] })
qc.invalidateQueries({ queryKey: ['dictionary', name] })
qc.invalidateQueries({ queryKey: ['dictionaries', 'deleted'] })
},
})
}