"use client" import type { ReactNode } from "react" import { useAuth } from "@/lib/auth-context" import { Button } from "@/components/ui/button" import { Avatar, AvatarFallback } from "@/components/ui/avatar" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent, DropdownMenuCheckboxItem, } from "@/components/ui/dropdown-menu" import { LogOut, User, Building2, Cpu, ShieldAlert, KeyRound } from "lucide-react" import { ModeToggle } from "@/components/mode-toggle" import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog" import { Label } from "@/components/ui/label" import { Input } from "@/components/ui/input" import { useState } from "react" import { useToast } from "@/components/ui/use-toast" // Defines props for the AppShell component interface AppShellProps { children: ReactNode // React children to be rendered within the shell } // AppShell component provides the main layout structure for the application export function AppShell({ children }: AppShellProps) { // Access authentication context for user info, logout function, room data, and room update function const { user, logout, rooms, updateRooms, changePassword } = useAuth() const { toast } = useToast() const [changePasswordOpen, setChangePasswordOpen] = useState(false) const [currentPassword, setCurrentPassword] = useState("") const [newPassword, setNewPassword] = useState("") const handleChangePassword = async () => { if (!currentPassword || !newPassword) return const success = await changePassword(currentPassword, newPassword) if (success) { toast({ title: "Passwort geändert" }) setChangePasswordOpen(false) setCurrentPassword("") setNewPassword("") } else { toast({ title: "Fehler", description: "Passwort konnte nicht geändert werden", variant: "destructive" }) } } // Generates user initials for the avatar fallback const initials = user?.name ?.split(" ") .map((n) => n[0]) .join("") .toUpperCase() .slice(0, 2) || "" // Fallback to empty string if user name is not available return (
{user?.name}
{user?.email}