"use client" import { useState, useEffect } from "react" import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Separator } from "@/components/ui/separator" import { settingsApi } from "@/lib/api" import { toast } from "sonner" import { Loader2, Check } from "lucide-react" interface ThemeConfig { logoUrl: string primaryColor: string companyName: string } const DEFAULT_THEME: ThemeConfig = { logoUrl: "/logo.png", primaryColor: "#000000", companyName: "GoHorseJobs" } export default function SettingsPage() { const [config, setConfig] = useState(DEFAULT_THEME) const [loading, setLoading] = useState(true) const [saving, setSaving] = useState(false) const fetchSettings = async () => { try { const data = await settingsApi.get("theme") if (data && Object.keys(data).length > 0) { setConfig({ ...DEFAULT_THEME, ...data }) // Merge with defaults } } catch (error) { console.error("Failed to fetch theme settings", error) // Accept default } finally { setLoading(false) } } useEffect(() => { fetchSettings() }, []) const handleSave = async () => { setSaving(true) try { await settingsApi.save("theme", config) toast.success("Theme settings saved successfully") // Force reload to apply? Or use Context. // Ideally Context updates. For now, reload works. window.location.reload() } catch (error) { console.error("Failed to save settings", error) toast.error("Failed to save settings") } finally { setSaving(false) } } if (loading) { return
} return (

System Settings

Manage application appearance and configuration.

Branding & Theme Customize the look and feel of your dashboard.
setConfig({ ...config, companyName: e.target.value })} />
setConfig({ ...config, logoUrl: e.target.value })} /> {config.logoUrl && ( Preview e.currentTarget.style.display = 'none'} /> )}

Enter a public URL for your logo.

setConfig({ ...config, primaryColor: e.target.value })} />
Sample Button
) }