Files
goodgo-platform/apps/web/app/(dashboard)/layout.tsx
Ho Ngoc Hai a590a41e73 feat(web): add loading skeletons, error boundaries, and accessibility improvements
- Add segment-level loading.tsx for dashboard, search, admin, and auth routes
- Add segment-level error.tsx with Vietnamese error messages for all route groups
- Add skip-to-content navigation link in root layout
- Add id="main-content" to all layout main elements
- Add aria-label to nav elements and mobile menu buttons
- Improve dashboard nav responsiveness (icon-only on mobile)
- Hide user name on small screens in dashboard layout

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-08 13:48:33 +07:00

64 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use client';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import { Button } from '@/components/ui/button';
import { useAuthStore } from '@/lib/auth-store';
import { cn } from '@/lib/utils';
const navItems = [
{ href: '/dashboard', label: 'Bảng điều khiển', icon: '🏠' },
{ href: '/listings', label: 'Tin đăng', icon: '📋' },
{ href: '/listings/new', label: 'Đăng tin', icon: '' },
{ href: '/analytics', label: 'Phân tích', icon: '📊' },
];
export default function DashboardLayout({ children }: { children: React.ReactNode }) {
const pathname = usePathname();
const { user, logout } = useAuthStore();
return (
<div className="min-h-screen bg-background">
<header className="sticky top-0 z-50 border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
<div className="mx-auto flex h-14 max-w-7xl items-center px-4">
<Link href="/" className="mr-6 flex items-center space-x-2">
<span className="text-lg font-bold text-primary">GoodGo</span>
</Link>
<nav aria-label="Bảng điều khiển" className="flex items-center space-x-1">
{navItems.map((item) => (
<Link
key={item.href}
href={item.href}
aria-label={item.label}
className={cn(
'rounded-md px-2 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground sm:px-3',
pathname === item.href
? 'bg-accent text-accent-foreground'
: 'text-muted-foreground',
)}
>
<span className="sm:mr-1.5">{item.icon}</span>
<span className="hidden sm:inline">{item.label}</span>
</Link>
))}
</nav>
<div className="ml-auto flex items-center space-x-3">
{user && (
<span className="hidden text-sm text-muted-foreground sm:inline">
{user.fullName}
</span>
)}
<Button variant="ghost" size="sm" onClick={() => logout()}>
Đăng xuất
</Button>
</div>
</div>
</header>
<main id="main-content" className="mx-auto max-w-7xl px-4 py-6">{children}</main>
</div>
);
}