"use client"; import * as React from "react"; 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 { IconBell, 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"; 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] = React.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: IconSettings, title: "Preferences", content:
Preferences content
, }, { id: "notifications", icon: IconBell, title: "Notifications", content:
Notifications content
, }, { id: "connections", icon: IconPlugConnected, title: "Connections", content:
Connections content
, }, ], }, { title: "Workspace", tabs: [ { id: "general", icon: IconWorld, title: "General", content:
General content
, }, { id: "members", icon: IconUsers, title: "Members", content:
Members content
, }, { id: "security", icon: IconLock, title: "Security", content:
Security content
, }, { id: "identity", icon: IconFingerprint, title: "Identity", content:
Identity content
, }, ], }, ]; 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}
); }