import Link from "next/link"; import { redirect } from "next/navigation"; import { StatusToastBridge } from "@/components/feedback/status-toast-bridge"; import { AppShell } from "@/components/navigation/app-shell"; import { PageIntro } from "@/components/navigation/page-intro"; import { ProfileAvatar } from "@/components/profile/profile-avatar"; import { SettingsForm } from "@/components/settings/settings-form"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { sanitizeNextPath } from "@/lib/auth/navigation"; import { getAuthState } from "@/lib/auth/session"; import { getSettingsStatusToast } from "@/lib/feedback/status-messages"; import { getProfileBundleForCurrentUser } from "@/lib/profile/service"; import { getParamValue, type PageSearchParams } from "@/lib/search-params"; export const dynamic = "force-dynamic"; type SettingsPageProps = { searchParams: Promise; }; export default async function SettingsPage({ searchParams }: SettingsPageProps) { 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("/settings"))}`); } const profileBundle = await getProfileBundleForCurrentUser(); if (!profileBundle) { redirect(`/login?next=${encodeURIComponent(sanitizeNextPath("/settings"))}`); } if (!profileBundle.profile.onboardingSeen) { redirect("/onboarding"); } const statusToast = getSettingsStatusToast( getParamValue(resolvedSearchParams, "error"), getParamValue(resolvedSearchParams, "status"), ); const profileTitle = profileBundle.profile.displayName ?? profileBundle.profile.email ?? authState.email ?? "Ingelogde gebruiker"; return (
Terug naar dashboard } />
); }