fcfa0707a1
- Add GET /api/auth/me endpoint returning current user from httpOnly cookie
- Add UserContext + useUser() hook that fetches from /api/auth/me on mount
- Wrap root layout with UserProvider
- Remove all localStorage.setItem/getItem('user') calls from login, register,
navbar, account pages, change-password, and checkout
- mustChangePassword redirect now reads from refreshed server session
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import type { Metadata } from 'next'
|
|
import './globals.css'
|
|
import { prisma } from '@/lib/prisma'
|
|
import { Footer } from '@/components/storefront/Footer'
|
|
import { UserProvider } from '@/context/UserContext'
|
|
|
|
export async function generateMetadata(): Promise<Metadata> {
|
|
try {
|
|
const rows = await prisma.siteSettings.findMany({
|
|
where: { key: { in: ['site_name', 'site_description', 'favicon_url'] } },
|
|
})
|
|
const s = Object.fromEntries(rows.map((r) => [r.key, r.value]))
|
|
return {
|
|
title: (s.site_name as string) || 'ShopX',
|
|
description: (s.site_description as string) || 'Your online store',
|
|
icons: { icon: (s.favicon_url as string) || '/icon.png' },
|
|
}
|
|
} catch {
|
|
return { title: 'ShopX', description: 'Your online store' }
|
|
}
|
|
}
|
|
|
|
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
return (
|
|
<html lang="it">
|
|
<body className="bg-gray-50 text-gray-900 min-h-screen flex flex-col">
|
|
<UserProvider>
|
|
{children}
|
|
</UserProvider>
|
|
<Footer />
|
|
</body>
|
|
</html>
|
|
)
|
|
}
|