import Link from "next/link"; import { redirect } from "next/navigation"; import { CheckInCard } from "@/components/check-in/check-in-card"; import { StatusToastBridge } from "@/components/feedback/status-toast-bridge"; import { AppShell } from "@/components/navigation/app-shell"; import { PageIntro } from "@/components/navigation/page-intro"; import { EnergyMeterCard } from "@/components/planning/energy-meter-card"; import { ProfileAvatar } from "@/components/profile/profile-avatar"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { sanitizeNextPath } from "@/lib/auth/navigation"; import { getAuthState } from "@/lib/auth/session"; import { getTodayCheckInForCurrentUser } from "@/lib/check-in/service"; import { isTestWizardEnabled } from "@/lib/config/feature-flags"; import { getDashboardStatusToast } from "@/lib/feedback/status-messages"; import { getTodayActivitiesForCurrentUser } from "@/lib/planning/service"; import { calculatePlanningMeterSnapshot } from "@/lib/planning/meter"; import { getProfileBundleForCurrentUser } from "@/lib/profile/service"; import { getParamValue, type PageSearchParams } from "@/lib/search-params"; export const dynamic = "force-dynamic"; type DashboardPageProps = { searchParams: Promise; }; function formatToggleState(value: boolean, enabledLabel = "Aan", disabledLabel = "Uit") { return value ? enabledLabel : disabledLabel; } function formatReminderTime(value: string | null) { return value ? value.slice(0, 5) : "Nog niet ingesteld"; } export default async function DashboardPage({ searchParams }: DashboardPageProps) { const authState = await getAuthState(); const resolvedSearchParams = await searchParams; if (!authState.isConfigured) { redirect("/login?error=auth-not-configured"); } if (!authState.isAuthenticated) { redirect(`/login?next=${encodeURIComponent(sanitizeNextPath("/dashboard"))}`); } const profileBundle = await getProfileBundleForCurrentUser(); if (!profileBundle) { redirect(`/login?next=${encodeURIComponent(sanitizeNextPath("/dashboard"))}`); } const { profile, settings } = profileBundle; const [checkInStatus, planningStatus] = await Promise.all([ getTodayCheckInForCurrentUser(), getTodayActivitiesForCurrentUser(), ]); const statusToast = getDashboardStatusToast(getParamValue(resolvedSearchParams, "status")); if (!profile.onboardingSeen) { redirect("/onboarding"); } const profileTitle = profile.displayName ?? profile.email ?? authState.email ?? "Ingelogde gebruiker"; const onboardingState = profile.onboardingCompleted ? "Afgerond" : "Nog niet afgerond"; const morningReminderState = settings.morningReminderEnabled ? `Aan om ${formatReminderTime(settings.morningReminderTime)}` : "Uit"; const planningMeter = calculatePlanningMeterSnapshot( planningStatus?.activities ?? [], checkInStatus?.todayCheckIn?.dailyBudget ?? null, ); return (
Test wizard ) : null } />

Auth

Cookie-based sessie actief
Gebruiker-ID `{authState.userId}` is server-side gevalideerd via Supabase SSR-auth.

Profiel

{profileTitle} {profile.tagline ?? "Nog geen korte profielregel toegevoegd."}
Taal `{profile.locale}` en timezone `{profile.timezone}` staan nu per gebruiker opgeslagen. {profile.bio ? ( {profile.bio} ) : null}

Onboarding

{onboardingState}
Nieuwe accounts starten bewust zonder afgeronde onboarding, zodat `ST-103` straks een duidelijke eerste flow kan aansturen.

Instellingen

Punten {formatToggleState(settings.showEnergyPoints, "zichtbaar", "verborgen")}
Ochtendreminder: {morningReminderState}. Reflectieprompts:{" "} {formatToggleState(settings.reflectionReminderEnabled)}.

Dagplanning

{planningStatus?.activities.length ? `${planningStatus.activities.length} activiteiten voor vandaag` : "Nog niets toegevoegd voor vandaag"}
Plan kleine, concrete activiteiten voor vandaag en leg ook onverwachte activiteiten vast als je dag anders loopt dan gedacht.
Open dagplanning
{isTestWizardEnabled() ? (

Wizard core

Interne testwizard actief
Gebruik deze alleen in development of preview om nieuwe multi-step flows te controleren.
) : null}
{!profile.onboardingCompleted ? (

Je onboarding is nog niet afgerond.

Je kunt de korte flow later alsnog afronden om je basisinstellingen en eerste voorkeuren vast te leggen.

Rond onboarding af
) : (

Je instellingen kun je nu ook los beheren.

`ST-104` staat nu klaar als aparte route, zodat je reminders, timezone en zichtbaarheid van punten later zelfstandig kunt aanpassen.

Open instellingen
)}
); }