Wire tenant archive export in frontend

This commit is contained in:
2026-07-05 12:31:59 +02:00
parent 0a7b0448ad
commit 3c4a75a858
3 changed files with 108 additions and 24 deletions

View File

@@ -55,6 +55,22 @@ export type TenantImportResult = {
files: { restored: number; skipped: number }
}
export type TenantExportJob = {
exportId: string
tenantId?: number
status: "queued" | "running" | "ready" | "failed" | string
filename: string
fileSize?: number | null
filesDone?: number
filesTotal?: number
error?: string | null
statusUrl?: string
downloadUrl?: string | null
createdAt?: string
updatedAt?: string | null
completedAt?: string | null
}
export type SystemStatus = {
checkedAt: string
backend: {
@@ -173,13 +189,23 @@ export const useAdmin = () => {
})
}
const exportTenant = async (id: number): Promise<Blob> => {
return await $api(`/api/admin/tenants/${id}/export`, {
const startTenantExport = async (id: number): Promise<TenantExportJob> => {
return await $api(`/api/admin/tenants/${id}/exports`, {
method: "POST",
})
}
const getTenantExport = async (exportId: string): Promise<TenantExportJob> => {
return await $api(`/api/admin/tenant-exports/${exportId}`)
}
const downloadTenantExport = async (exportId: string): Promise<Blob> => {
return await $api(`/api/admin/tenant-exports/${exportId}/download`, {
responseType: "blob",
})
}
const importTenant = async (body: Record<string, any>): Promise<TenantImportResult> => {
const importTenant = async (body: Record<string, any> | FormData): Promise<TenantImportResult> => {
return await $api("/api/admin/tenant-imports", {
method: "POST",
body,
@@ -222,7 +248,9 @@ export const useAdmin = () => {
createTenant,
invitePortalUser,
updateTenant,
exportTenant,
startTenantExport,
getTenantExport,
downloadTenantExport,
importTenant,
}
}