import Link from "next/link" import { redirect } from "next/navigation" import { Suspense, type ReactElement } from "react" import { getTranslations } from "next-intl/server" import { User, Mail, Phone, MapPin, Calendar, Clock, Shield } from "lucide-react" import { requireAuth } from "@/shared/lib/auth-guard" import { getUserProfile } from "@/modules/users/data-access" import { ProfileStudentOverview, ProfileStudentOverviewSkeleton } from "@/modules/settings/components/profile-student-overview" import { ProfileTeacherOverview, ProfileTeacherOverviewSkeleton } from "@/modules/settings/components/profile-teacher-overview" import { SettingsSectionErrorBoundary } from "@/modules/settings/components/settings-section-error-boundary" import { Avatar, AvatarFallback, AvatarImage } from "@/shared/components/ui/avatar" import { Badge } from "@/shared/components/ui/badge" import { Button } from "@/shared/components/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/shared/components/ui/card" import { PageHeader } from "@/shared/components/ui/page-header" import { formatDate } from "@/shared/lib/utils" export const dynamic = "force-dynamic" export async function generateMetadata() { const t = await getTranslations("settings.profilePage") return { title: t("title") } } export default async function ProfilePage(): Promise { const ctx = await requireAuth() const userId = ctx.userId const userProfile = await getUserProfile(userId) if (!userProfile) { redirect("/login") } const roles = ctx.roles const isStudent = roles.includes("student") const isTeacher = roles.includes("teacher") const t = await getTranslations("settings.profilePage") return (
{t("editProfile")} } />
{userProfile.image ? : null} {(userProfile.name ?? userProfile.email).slice(0, 2).toUpperCase()}
{userProfile.name ?? "-"}
{userProfile.email}
{t("personalInfo.title")} {t("personalInfo.description")}
{t("personalInfo.fullName")}
{userProfile.name ?? "-"}
{t("personalInfo.gender")}
{userProfile.gender ?? "-"}
{t("personalInfo.age")}
{userProfile.age ?? "-"}
{t("personalInfo.phone")}
{userProfile.phone ? : null} {userProfile.phone ?? "-"}
{t("personalInfo.address")}
{userProfile.address ? : null} {userProfile.address ?? "-"}
{t("accountInfo.title")} {t("accountInfo.description")}
{t("accountInfo.email")}
{userProfile.email}
{t("accountInfo.role")}
{userProfile.role}
{t("accountInfo.memberSince")}
{formatDate(userProfile.createdAt)}
{t("accountInfo.onboardedAt")}
{userProfile.onboardedAt ? formatDate(userProfile.onboardedAt) : "-"}
{isStudent ? ( }> ) : null} {isTeacher ? ( }> ) : null}
) }