Implement i18n with German and English support (default DE)
This commit is contained in:
57
app/[lang]/dashboard/[planId]/page.tsx
Normal file
57
app/[lang]/dashboard/[planId]/page.tsx
Normal file
@@ -0,0 +1,57 @@
|
||||
import { notFound } from "next/navigation"
|
||||
import { cookies } from "next/headers"
|
||||
import prisma from "@/lib/prisma"
|
||||
import { PlanLoginForm } from "@/components/plan-login-form"
|
||||
import { PlanDashboard } from "./_components/plan-dashboard"
|
||||
import { getDictionary } from "@/get-dictionary"
|
||||
|
||||
export default async function DashboardPage({
|
||||
params
|
||||
}: {
|
||||
params: Promise<{ planId: string, lang: string }>
|
||||
}) {
|
||||
const { planId, lang } = await params
|
||||
const dict = await getDictionary(lang as any)
|
||||
|
||||
const plan = await prisma.plan.findUnique({
|
||||
where: { id: planId },
|
||||
include: { bookings: true },
|
||||
})
|
||||
|
||||
if (!plan) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
const cookieStore = await cookies()
|
||||
const isAuthenticated = cookieStore.get(`plan_auth_${plan.id}`)?.value === "true"
|
||||
|
||||
if (!isAuthenticated) {
|
||||
return (
|
||||
<main className="flex min-h-screen flex-col items-center p-4">
|
||||
<PlanLoginForm planId={plan.id} dict={dict.login} />
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="flex min-h-screen flex-col items-center p-4">
|
||||
<div className="w-full max-w-4xl space-y-6">
|
||||
<div className="flex flex-col md:flex-row justify-between items-start md:items-center gap-4">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold">{dict.home.title}</h1>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
{plan.startDate.toLocaleDateString(lang)} - {plan.endDate.toLocaleDateString(lang)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="text-sm bg-muted px-3 py-1 rounded-md">
|
||||
Plan ID: <span className="font-mono font-bold">{plan.id}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="p-4 border rounded-lg bg-card text-card-foreground shadow-sm">
|
||||
<PlanDashboard plan={plan} dict={dict.dashboard} settingsDict={dict.settings} lang={lang} />
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user