import { useSettingsStore } from "../../stores/settingsStore"; import { Input } from "../ui/Input"; import { Toggle } from "../ui/Toggle"; import { SettingsRow } from "../ui/SettingsRow"; import type { DbType } from "../../lib/types"; const DB_TYPES: { id: DbType; label: string }[] = [ { id: "postgresql", label: "PostgreSQL" }, { id: "mysql", label: "MySQL" }, { id: "sqlite", label: "SQLite" }, { id: "redis", label: "Redis" }, ]; export function AdvancedSettingsTab() { const { settings, updateSetting } = useSettingsStore(); if (!settings) return null; const defaultPorts = settings.default_ports ?? { postgresql: 5432, mysql: 3306, sqlite: null, redis: 6379, }; const updatePort = (key: string, value: string) => { const port = value === "" ? null : Number(value); const next = { ...defaultPorts, [key]: port }; updateSetting("default_ports", JSON.stringify(next)); }; return (

Safety

updateSetting("confirm_before_delete", checked ? "true" : "false") } label="Confirm before delete" />

Default ports

{DB_TYPES.map((db) => ( updatePort(db.id, value)} className="w-24" aria-label={`Default port for ${db.label}`} /> ))}
); }