Add admin menu link to header when authenticated
- Check isAdminAuthenticated() in Header component - Show 'Admin' link to /admin/orders when user is logged in as admin - Allows quick navigation to admin section after login Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 4.5
parent
8edb5e1f5b
commit
6c8d34edde
@@ -8,15 +8,17 @@ 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] = await Promise.all([
|
||||
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' },
|
||||
@@ -69,6 +71,11 @@ export default async function Header() {
|
||||
</nav>
|
||||
<div className="flex items-center gap-2 sm:gap-4">
|
||||
<CurrencySelector />
|
||||
{isAdmin && (
|
||||
<Link href="/admin/orders" className="tag-label hover:text-ink">
|
||||
Admin
|
||||
</Link>
|
||||
)}
|
||||
<div className="hidden md:block">
|
||||
<AccountMenu customer={customer ? { name: customer.name, email: customer.email } : null} />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user