Wire tenant archive export in frontend
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user