"use client"; import { cn } from "@/lib/utils"; import { Dialog, DialogContent, DialogTrigger, } from "@/app/_components/ui/dialog"; import { ScrollArea } from "@/app/_components/ui/scroll-area"; import { Separator } from "@/app/_components/ui/separator"; import { Avatar, AvatarFallback, AvatarImage, } from "@/app/_components/ui/avatar"; import { IconAdjustmentsHorizontal, IconBaselineDensityLarge, IconBell, IconFileExport, IconFileImport, IconFingerprint, IconLock, IconPlugConnected, IconSettings, IconUser, IconUsers, IconWorld, } from "@tabler/icons-react"; import type { User } from "@/src/models/users/users.model"; import { ProfileSettings } from "./profile-settings"; import { DialogTitle } from "@radix-ui/react-dialog"; import { useState } from "react"; import NotificationsSetting from "./notification-settings"; import PreferencesSettings from "./preference-settings"; import ImportData from "./import-data"; interface SettingsDialogProps { user: User | null; trigger: React.ReactNode; defaultTab?: string; open?: boolean; onOpenChange?: (open: boolean) => void; } interface SettingsTab { id: string; icon: typeof IconUser; title: string; content: React.ReactNode; } interface SettingsSection { title: string; tabs: SettingsTab[]; } export function SettingsDialog({ user, trigger, defaultTab = "account", open, onOpenChange, }: SettingsDialogProps) { const [selectedTab, setSelectedTab] = useState(defaultTab); // Get user display name const preferredName = user?.profile?.first_name || ""; const userEmail = user?.email || ""; const displayName = preferredName || userEmail?.split("@")[0] || "User"; const userAvatar = user?.profile?.avatar || ""; const sections: SettingsSection[] = [ { title: "Account", tabs: [ { id: "account", icon: IconUser, title: "My Account", content: , }, { id: "preferences", icon: IconAdjustmentsHorizontal, title: "Preferences", content: , }, { id: "notifications", icon: IconBell, title: "Notifications", content: , }, ], }, { title: "Workspace", tabs: [ { id: "import", icon: IconFileImport, title: "Import", content: , }, { id: "export", icon: IconFileExport, title: "Export", content:
Export
, }, ], }, ]; const currentTab = sections .flatMap((section) => section.tabs) .find((tab) => tab.id === selectedTab); return ( {trigger}
{/* Sidebar */}
{displayName[0].toUpperCase()} {displayName}
{sections.map((section, index) => (

{section.title}

{section.tabs.map((tab) => ( ))}
{index < sections.length - 1 && ( )}
))}
{/* Content */}
{currentTab?.content}
); }