Files
maskanx_cm_frontend/src/api/modules/brand.ts
T
AFFAANhandClaude Opus 5 b42b7406dc Initial commit: MaskanX frontend
Independent React, TypeScript and Vite web application for MaskanX.

Includes the chat console, agent and persona configuration, MCP client
management, model and provider settings, cron jobs, sessions, and
diagnostics.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-01 10:28:39 +05:30

55 lines
1.4 KiB
TypeScript

import { getApiToken, getApiUrl } from "../config";
import { request } from "../request";
export interface BrandLogoInfo {
configured: boolean;
width: number;
height: number;
filename: string;
path: string;
url: string;
updated_at: number | null;
success?: boolean;
}
function authHeaders(): HeadersInit {
const token = getApiToken();
return token ? { Authorization: `Bearer ${token}` } : {};
}
export const brandApi = {
getLogo: () => request<BrandLogoInfo>("/config/brand/logo"),
getLogoFileUrl: (updatedAt?: number | null) => {
const suffix = updatedAt ? `?updated_at=${encodeURIComponent(updatedAt)}` : "";
return `${getApiUrl("/config/brand/logo/file")}${suffix}`;
},
uploadLogo: async (file: File): Promise<BrandLogoInfo> => {
const formData = new FormData();
formData.append("file", file);
const response = await fetch(getApiUrl("/config/brand/logo"), {
method: "POST",
headers: authHeaders(),
body: formData,
});
if (!response.ok) {
const text = await response.text().catch(() => "");
throw new Error(
`Logo upload failed: ${response.status} ${response.statusText}${
text ? ` - ${text}` : ""
}`,
);
}
return await response.json();
},
deleteLogo: () =>
request<{ success: boolean }>("/config/brand/logo", {
method: "DELETE",
}),
};