54 lines
2.4 KiB
TypeScript
Executable File
54 lines
2.4 KiB
TypeScript
Executable File
import { Link, usePage } from '@inertiajs/react';
|
|
import AppLogo from '@/components/app-logo';
|
|
import { UserMenuContent } from '@/components/user-menu-content';
|
|
import { Avatar, AvatarFallback } from '@/components/ui/avatar';
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuTrigger,
|
|
} from '@/components/ui/dropdown-menu';
|
|
import { useInitials } from '@/hooks/use-initials';
|
|
import { useFlashToast } from '@/hooks/use-flash-toast';
|
|
import type { Auth } from '@/types';
|
|
|
|
export default function AppLayout({ children }: { children: React.ReactNode }) {
|
|
const { auth } = usePage<{ auth: Auth }>().props;
|
|
const getInitials = useInitials();
|
|
useFlashToast();
|
|
|
|
return (
|
|
<div className="flex min-h-svh flex-col bg-background">
|
|
<header className="sticky top-0 z-40 border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80">
|
|
<div className="mx-auto flex h-14 w-full max-w-7xl items-center justify-between gap-4 px-4 sm:px-6">
|
|
<Link href="/planner" className="flex items-center">
|
|
<AppLogo />
|
|
</Link>
|
|
|
|
{auth?.user && (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger
|
|
className="rounded-full outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
aria-label="Меню пользователя"
|
|
data-test="user-menu-trigger"
|
|
>
|
|
<Avatar className="h-8 w-8">
|
|
<AvatarFallback className="rounded-full bg-neutral-200 text-xs text-black dark:bg-neutral-700 dark:text-white">
|
|
{getInitials(auth.user.name)}
|
|
</AvatarFallback>
|
|
</Avatar>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" className="w-56">
|
|
<UserMenuContent user={auth.user} />
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)}
|
|
</div>
|
|
</header>
|
|
|
|
<main className="mx-auto w-full max-w-7xl flex-1 px-4 py-6 sm:px-6">
|
|
{children}
|
|
</main>
|
|
</div>
|
|
);
|
|
}
|