import { useRef } from "react"; import { useTranslation } from "react-i18next"; import { PaintbrushIcon } from "lucide-react"; import { Button } from "@/components/button"; import { Input } from "@/components/input"; import type { BrandingSettings } from "@/api/settings-api"; import { AccordionSection } from "./AdminSettingsShared"; import { BRANDING_LOGO_ACCEPT, isAcceptedBrandingLogoFile, } from "./branding-logo-file"; export function AdminBrandingSection({ open, onToggle, settings, setSettings, saving, onSave, onResetLogo, }: { open: boolean; onToggle: () => void; settings: BrandingSettings | null; setSettings: (settings: BrandingSettings) => void; saving: boolean; onSave: () => void; onResetLogo: () => void; }) { const { t } = useTranslation(); const fileInputRef = useRef(null); function handleFileChange(event: React.ChangeEvent) { const file = event.target.files?.[0]; event.target.value = ""; if (!file || !settings) return; if (!isAcceptedBrandingLogoFile(file)) { alert(t("admin.brandingLogoInvalid")); return; } const reader = new FileReader(); reader.onload = () => { if (typeof reader.result === "string") { setSettings({ ...settings, logo: reader.result }); } }; reader.readAsDataURL(file); } return ( } open={open} onToggle={onToggle} > {settings === null ? (
{t("common.loading")}
) : (
{t("admin.brandingLogo")} {t("admin.brandingLogoDesc")}
{settings.logo ? ( ) : (
)} {settings.logo && ( )}
)} ); }