"use client"; import dynamic from "next/dynamic"; import { useEffect, useState } from "react"; import { useQuery } from "@tanstack/react-query"; import { User, ShieldCheck, Palette, Sparkles, Database, Info } from "lucide-react"; import { api } from "@/lib/client/api"; import { Tabs, TabsList, TabsTrigger, TabsContent, Spinner } from "@/components/ui/primitives"; import { ProfileSection } from "./ProfileSection"; import { SecuritySection } from "./SecuritySection"; import { AppearanceSection } from "./AppearanceSection"; import { AISection } from "./AISection"; import { AboutSection } from "./AboutSection"; import { applyPrefs } from "./prefs"; export interface SettingsProfile { id: string; username: string; displayName: string; email: string | null; totpEnabled: boolean; preferences: Record; createdAt: string; workspace: { id: string; name: string }; aiBudgetUsd: number; sessionId: string } // @ts-ignore — DataSection is written by another engineer; a missing export falls back to a placeholder. const DataSection = dynamic(() => import("@/components/settings/DataSection").then((m: any) => (m.DataSection ?? m.default ?? (() =>

Data tools are not available yet.

)) as React.ComponentType).catch(() => (() =>

Data tools are not available yet.

) as React.ComponentType), { ssr: false, loading: () =>
}); const TABS = [{ id: "profile", label: "Profile", icon: }, { id: "security", label: "Security", icon: }, { id: "appearance", label: "Appearance", icon: }, { id: "ai", label: "AI", icon: }, { id: "data", label: "Data", icon: }, { id: "about", label: "About", icon: }]; export function SettingsView({ version }: { version: string }) { const [tab, setTab] = useState("profile"); useEffect(() => { const h = window.location.hash.slice(1); if (TABS.some((t) => t.id === h)) setTab(h); }, []); const { data: profile, refetch, isLoading } = useQuery({ queryKey: ["settings"], queryFn: () => api("/api/settings") }); useEffect(() => { if (profile) applyPrefs(profile.preferences as any); }, [profile]); const refresh = () => { refetch(); }; return (

Settings

{ setTab(v); history.replaceState(null, "", `#${v}`); }}>
{TABS.map((t) => {t.icon}{t.label})}
{isLoading || !profile ?
: <> }
); }