import ErrorBanner from "@/components/ui/error-banner" import { Label } from "@/components/ui/label" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Separator } from "@/components/ui/separator" import { SettingsPanelDescription, SettingsPanelHeader, SettingsPanelTitle, SettingsPanelContent } from "@/components/ui/settings-dialog" import { Switch } from "@/components/ui/switch" import { useTheme } from "@/components/ui/theme-provider" import _ from "@/lib/translate" import { AccountsSettings } from "@/types/Accounts/AccountsSettings" import { useFrappeGetDoc, useFrappeUpdateDoc } from "frappe-react-sdk" import { toast } from "sonner" export const Preferences = () => { const { data: accountsSettings, mutate, error: fetchError, isLoading } = useFrappeGetDoc("Accounts Settings", "Accounts Settings", undefined, { revalidateOnFocus: false }) const { updateDoc, error } = useFrappeUpdateDoc() const onUpdate = (field: keyof AccountsSettings, value: any) => { mutate(updateDoc("Accounts Settings", "Accounts Settings", { [field]: value }), { optimisticData: { ...accountsSettings as AccountsSettings, [field]: value }, revalidate: false, }).then(() => { toast.success(_("Preferences updated"), { dismissible: true, duration: 500, }) }) } return <> {_("Preferences")} {_("Configure settings for the banking module")}
{fetchError && } {error && }

{_("For example, if set to 4, the system will try to find matching transfer transactions in other banks 4 days before and after the transaction date. This is because transactions can clear on different days on different bank accounts.")}

{_("This will automatically run transaction matching rules on unreconciled transactions every hour.")}

onUpdate("automatically_run_rules_on_unreconciled_transactions", checked ? 1 : 0)} />

{_("The system will attempt to automatically match a party to a bank transaction based on account number or IBAN.")}

onUpdate("enable_party_matching", checked ? 1 : 0)} />

{_("If a party cannot be matched by account number or IBAN, the system will try fuzzy matching using the party name and transaction description.")}

onUpdate("enable_fuzzy_matching", checked ? 1 : 0)} />
{/* */}
} const ThemeSwitcher = () => { const { theme, setTheme } = useTheme() const themeCards: Array<{ value: "Light" | "Dark" | "Automatic", label: string }> = [ { value: "Light", label: _("Light"), }, { value: "Dark", label: _("Dark"), }, { value: "Automatic", label: _("System"), }, ] return

{_("Switch between light, dark, or system theme")}

{themeCards.map((option) => { const selected = theme === option.value return ( ) })}
} const ThemePreviewWindow = ({ theme, roundedClass }: { theme: "light" | "dark", roundedClass: string }) => { const isLight = theme === "light" const frameClass = isLight ? "bg-white border-gray-100" : "bg-gray-900 border-gray-800" const subtleSurfaceClass = isLight ? "bg-gray-50" : "bg-gray-800" const mutedLineClass = isLight ? "bg-gray-200" : "bg-gray-700" const mutedLineStrongClass = isLight ? "bg-gray-300" : "bg-gray-600" const dividerClass = isLight ? "border-gray-100" : "border-gray-800" const cardClass = isLight ? "bg-white border-gray-200" : "bg-gray-900 border-gray-700" return
{/*
*/}
}