import Link from 'next/link'; import Image from 'next/image'; import CartButton from './CartButton'; import AccountMenu from './AccountMenu'; import ThemeToggle from './ThemeToggle'; import NavDropdown from './NavDropdown'; import CurrencySelector from './CurrencySelector'; import MobileNav from './MobileNav'; import { prisma } from '@/lib/prisma'; import { getCurrentCustomer } from '@/lib/auth'; import { isAdminAuthenticated } from '@/lib/adminAuth'; export default async function Header() { const [categories, collections, customer, isAdmin] = await Promise.all([ prisma.category.findMany({ where: { showOnPersonalised: true }, orderBy: { name: 'asc' }, }), prisma.collection.findMany({ orderBy: { name: 'asc' } }), getCurrentCustomer(), isAdminAuthenticated(), ]); const personalisedLinks = [ { href: '/made-to-order', label: 'Shop all' }, ...categories.map((c) => ({ href: `/made-to-order?category=${c.slug}`, label: c.name })), ]; const shopBySections = [ { title: 'Occasions', links: collections .filter((c) => c.group === 'OCCASION') .map((c) => ({ href: `/made-to-order?collection=${c.slug}`, label: c.name })), }, { title: 'Gifts for', links: collections .filter((c) => c.group === 'RECIPIENT') .map((c) => ({ href: `/made-to-order?collection=${c.slug}`, label: c.name })), }, ]; return (
Craft2Prints Craft2Prints
{isAdmin && ( Admin )}
); }