Add project overview import
This commit is contained in:
parent
0180f768ac
commit
194bc9c0b1
9 changed files with 268 additions and 32 deletions
|
|
@ -64,7 +64,15 @@ async function request<T>(url: string, init?: RequestInit): Promise<T> {
|
|||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const details = await response.text();
|
||||
let details = await response.text();
|
||||
try {
|
||||
const parsed = JSON.parse(details) as { error?: unknown };
|
||||
if (typeof parsed.error === "string") {
|
||||
details = parsed.error;
|
||||
}
|
||||
} catch {
|
||||
// Keep non-JSON error responses unchanged.
|
||||
}
|
||||
throw new Error(details || `Anfrage fehlgeschlagen (Status ${response.status})`);
|
||||
}
|
||||
|
||||
|
|
@ -233,6 +241,16 @@ export function exportProjectTransfer(projectId: string) {
|
|||
return request<unknown>(`/api/projects/${projectId}/export`);
|
||||
}
|
||||
|
||||
export function importProjectTransferAsNew(transfer: unknown) {
|
||||
return request<{ projectId: string; name: string }>(
|
||||
"/api/projects/import",
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({ transfer }),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function importProjectTransfer(
|
||||
projectId: string,
|
||||
mode: "replace" | "duplicate",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue