From 10ad276c38b6d138b392776ab01b0ba4a3770f03 Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Wed, 18 Mar 2026 10:48:22 +0100 Subject: [PATCH] feat: add soft-delete API functions and deleted_at to Site type --- lib/api/sites.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/api/sites.ts b/lib/api/sites.ts index 60d2f4b..7093b57 100644 --- a/lib/api/sites.ts +++ b/lib/api/sites.ts @@ -26,6 +26,7 @@ export interface Site { is_verified?: boolean created_at: string updated_at: string + deleted_at?: string | null } export interface CreateSiteRequest { @@ -77,8 +78,8 @@ export async function updateSite(id: string, data: UpdateSiteRequest): Promise { - await apiRequest(`/sites/${id}`, { +export async function deleteSite(id: string): Promise<{ message: string; purge_at: string }> { + return apiRequest<{ message: string; purge_at: string }>(`/sites/${id}`, { method: 'DELETE', }) } @@ -94,3 +95,20 @@ export async function verifySite(id: string): Promise { method: 'POST', }) } + +export async function restoreSite(id: string): Promise { + await apiRequest(`/sites/${id}/restore`, { + method: 'POST', + }) +} + +export async function permanentDeleteSite(id: string): Promise { + await apiRequest(`/sites/${id}/permanent`, { + method: 'DELETE', + }) +} + +export async function listDeletedSites(): Promise { + const response = await apiRequest<{ sites: Site[] }>('/sites/deleted') + return response?.sites || [] +}