feat(base): add client csv export service call

This commit is contained in:
Philipinho
2026-04-18 18:23:43 +01:00
parent f119d728a8
commit 18668c7bcf
@@ -1,4 +1,5 @@
import api from "@/lib/api-client";
import { saveAs } from "file-saver";
import {
IBase,
IBaseProperty,
@@ -46,6 +47,26 @@ export async function deleteBase(baseId: string): Promise<void> {
await api.post("/bases/delete", { baseId });
}
export async function exportBaseToCsv(baseId: string): Promise<void> {
const req = await api.post(
"/bases/export-csv",
{ baseId },
{ responseType: "blob" },
);
const header = (req?.headers?.["content-disposition"] as string) ?? "";
const utf8Match = header.match(/filename\*=UTF-8''([^;]+)/i);
const plainMatch = header.match(/filename="?([^";]+)"?/i);
let fileName = utf8Match?.[1] ?? plainMatch?.[1] ?? "base.csv";
try {
fileName = decodeURIComponent(fileName);
} catch {
// fallback to raw filename
}
saveAs(req.data, fileName);
}
export async function listBases(
spaceId: string,
params?: { cursor?: string; limit?: number },