import type { ReactNode } from 'react'; import { headers } from 'next/headers'; import { and, count, eq, isNull } from '@/lib/db'; import { db, notifications } from '@/lib/db'; import { requireUser } from '@/lib/auth/session'; import { AccountNav } from '@/components/account/account-nav'; export default async function AccountLayout({ children }: { children: ReactNode }) { const h = await headers(); const path = h.get('x-invoke-path') ?? h.get('next-url') ?? undefined; const user = await requireUser(path); const rows = await db().select({ n: count() }).from(notifications).where(and(eq(notifications.userId, user.id), isNull(notifications.readAt))); const n = rows[0]?.n ?? 0; return (
{children}
); }