Refine invoice template editor interactions

This commit is contained in:
2026-03-13 16:59:14 +01:00
parent 490be6a89b
commit 5fd349dee2
3 changed files with 271 additions and 50 deletions

View File

@@ -2,6 +2,16 @@ import { AUTH_TOKEN_STORAGE_KEY } from "./storage";
const API_ROOT = import.meta.env.VITE_API_URL ?? (import.meta.env.DEV ? "http://localhost:8090/api" : "/api");
export class ApiError extends Error {
status: number;
constructor(message: string, status: number) {
super(message);
this.name = "ApiError";
this.status = status;
}
}
type ApiErrorPayload = {
message?: string;
error?: string;
@@ -44,7 +54,7 @@ function authHeaders(): Record<string, string> {
async function handleResponse<T>(response: Response): Promise<T> {
if (!response.ok) {
throw new Error(await readErrorMessage(response));
throw new ApiError(await readErrorMessage(response), response.status);
}
if (response.status === 204) {
return undefined as T;