Files
gunshiz a3803118ef
CI / Verify (push) Successful in 2m10s
CI / Build immutable images and deploy (push) Successful in 2m33s
feat : add analytics page
2026-10-10 20:19:49 +07:00

61 lines
2.9 KiB
TypeScript

"use client";
import Link from "next/link";
import Image from "@/components/ui/resilient-image";
import { usePathname } from "next/navigation";
import { BookOpenIcon, ChartNoAxesCombinedIcon, MenuIcon } from "lucide-react";
import { Button, buttonVariants } from "@/components/ui/button";
import {
Drawer,
DrawerClose,
DrawerContent,
DrawerDescription,
DrawerHeader,
DrawerTitle,
DrawerTrigger,
} from "@/components/ui/drawer";
const destinations = [
{ href: "/", label: "หน้ารวม", icon: null },
{ href: "/commission", label: "จ้างคำนวณทีม", icon: "/icon/commission.webp" },
{ href: "/stygian", label: "ไกด์ Stygian", icon: "/icon/stygian.webp" },
{ href: "/analytics", label: "วิเคราะห์ข้อมูล", icon: null },
] as const;
export function PublicNavigation() {
const pathname = usePathname();
const isCurrent = (href: string) => href === "/" ? pathname === "/" : pathname.startsWith(href);
return <>
<nav aria-label="เมนูหลัก" className="hidden items-center gap-1 lg:flex">
{destinations.slice(1).map(({ href, label, icon }) =>
<Link key={href} href={href} aria-current={isCurrent(href) ? "page" : undefined}
className={buttonVariants({ variant: "ghost", size: "sm" })}>
{icon ? <Image src={icon} alt="" width={24} height={24} className="size-6 object-contain" /> : <ChartNoAxesCombinedIcon data-icon="inline-start" aria-hidden="true" />}{label}
</Link>)}
</nav>
<div className="lg:hidden">
<Drawer>
<DrawerTrigger render={<Button type="button" variant="outline" size="sm" aria-label="เปิดเมนูหลัก" />}>
<MenuIcon data-icon="inline-start" aria-hidden="true" />เมนู
</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>เมนูหลัก</DrawerTitle>
<DrawerDescription>เลือกหน้าที่ต้องการดู</DrawerDescription>
</DrawerHeader>
<nav aria-label="เมนูหลักบนมือถือ" className="grid gap-1 p-4">
{destinations.map(({ href, label, icon }) =>
<DrawerClose key={href} render={<Link href={href} aria-current={isCurrent(href) ? "page" : undefined}
className="flex min-h-11 items-center gap-3 rounded-lg px-3 text-sm hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring" />}>
{icon ? <Image src={icon} alt="" width={20} height={20} className="size-5 object-contain" /> : href === "/analytics" ? <ChartNoAxesCombinedIcon aria-hidden="true" /> : <BookOpenIcon aria-hidden="true" />}{label}
{isCurrent(href) ? <span className="ml-auto text-xs text-primary">ปัจจุบัน</span> : null}
</DrawerClose>)}
</nav>
</DrawerContent>
</Drawer>
</div>
</>;
}