50 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-10-27 21:11:45 +00:00
/* Copyright (C) 2024 Manuel Bustillo*/
2024-08-11 12:34:16 +02:00
'use client'
2024-08-11 12:03:11 +02:00
import {
UserGroupIcon,
2024-08-11 12:34:16 +02:00
RectangleGroupIcon,
BanknotesIcon,
2024-08-11 12:03:11 +02:00
} from '@heroicons/react/24/outline';
2024-08-11 12:34:16 +02:00
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import clsx from 'clsx';
import { getSlug } from '@/app/lib/utils';
2024-08-11 12:03:11 +02:00
// Map of links to display in the side navigation.
// Depending on the size of the application, this would be stored in a database.
2024-08-11 12:03:11 +02:00
const links = [
{ name: 'Guests', href: `/${getSlug()}/dashboard/guests`, icon: UserGroupIcon },
{ name: 'Expenses', href: `/${getSlug()}/dashboard/expenses`, icon: BanknotesIcon },
{ name: 'Table distributions', href: `/${getSlug()}/dashboard/tables`, icon: RectangleGroupIcon },
2024-08-11 12:03:11 +02:00
];
2024-08-11 12:34:16 +02:00
2024-08-11 12:03:11 +02:00
export default function NavLinks() {
2024-08-11 12:34:16 +02:00
const pathname = usePathname();
2024-08-11 12:03:11 +02:00
return (
<>
{links.map((link) => {
const LinkIcon = link.icon;
return (
2024-08-11 12:34:16 +02:00
<Link
2024-08-11 12:03:11 +02:00
key={link.name}
href={link.href}
2024-08-11 12:34:16 +02:00
className={clsx(
'flex h-[48px] grow items-center justify-center gap-2 rounded-md bg-gray-50 p-3 text-sm font-medium hover:bg-sky-100 hover:text-blue-600 md:flex-none md:justify-start md:p-2 md:px-3',
{
'bg-sky-100 text-blue-600': pathname === link.href,
},
)}
2024-08-11 12:03:11 +02:00
>
<LinkIcon className="w-6" />
<p className="hidden md:block">{link.name}</p>
2024-08-11 12:34:16 +02:00
</Link>
2024-08-11 12:03:11 +02:00
);
})}
</>
);
}