import { useEffect, useState } from "react"; import { api } from "../../api/client"; const PROVIDER_NAMES: Record = { cloudflare: "Cloudflare", loopia: "Loopia", pihole: "Pi-hole", azure: "Azure DNS", cpanel: "cPanel", technitium: "Technitium", }; const INTEGRATION_NAMES: Record = { tailscale: "Tailscale", proxmox: "Proxmox", synology: "Synology", semaphore: "Semaphore", gitea: "Gitea", dockhand: "Dockhand", uptimekuma: "Uptime Kuma", phpipam: "phpIPAM", }; function ColorList({ names, colors, onChange, }: { names: Record; colors: Record; onChange: (id: string, color: string) => void; }) { return (
{Object.entries(names).map(([id, name]) => { const color = colors[id] ?? "#6366f1"; return (
{name} onChange(id, e.target.value)} /> {color}
); })}
); } export default function BadgeSettings() { const [loading, setLoading] = useState(true); const [loadError, setLoadError] = useState(null); const [providerColors, setProviderColors] = useState>({}); const [integrationColors, setIntegrationColors] = useState>({}); const [saving, setSaving] = useState(false); const [saved, setSaved] = useState(false); const [saveError, setSaveError] = useState(null); useEffect(() => { Promise.all([api.settings.providerColors(), api.settings.integrationColors()]) .then(([providerRes, integrationRes]) => { setProviderColors(providerRes.providerColors); setIntegrationColors(integrationRes.integrationColors); }) .catch((err) => setLoadError(err instanceof Error ? err.message : String(err))) .finally(() => setLoading(false)); }, []); async function handleSave() { setSaving(true); setSaveError(null); setSaved(false); try { const res = await api.settings.update({ providerColors, integrationColors }); setProviderColors(res.settings.providerColors); setIntegrationColors(res.settings.integrationColors); setSaved(true); setTimeout(() => setSaved(false), 3000); } catch (err) { setSaveError(err instanceof Error ? err.message : String(err)); } finally { setSaving(false); } } if (loading) return
Loading…
; return ( <>

Badges

{saveError && {saveError}} {saved && ✓ Colors saved}
{loadError &&
{loadError}
}

DNS provider badge colors

Customize the color of each DNS provider's badge throughout the app.

setProviderColors((c) => ({ ...c, [id]: color }))} />

Integration badge colors

Customize the color of each integration type's badge throughout the app.

setIntegrationColors((c) => ({ ...c, [id]: color }))} />
); }