Files
erika/app/profile/page.tsx
T

64 lines
2.3 KiB
TypeScript

import type { Metadata } from "next";
import Link from "next/link";
import { getServerSession } from "next-auth";
import { ArrowLeft } from "lucide-react";
import { authOptions } from "@/lib/auth/auth-options";
import { getSessionDiscordId } from "@/lib/auth/auth";
import { loadGuildProfile } from "@/lib/profile/guild-profile";
import { ProfileLoginCard } from "@/components/profile/profile-login-card";
import { ProfilePassport } from "@/components/profile/profile-passport";
import { RealtimeRefresh } from "@/components/realtime-refresh";
import { ThemeToggle } from "@/components/theme-toggle";
import { Button } from "@/components/ui/button";
export const dynamic = "force-dynamic";
export const metadata: Metadata = {
title: "โปรไฟล์ของฉัน",
description: "ดูเลเวล XP เวลาในห้องเสียง และอันดับ Discord ของคุณใน Erika!",
alternates: { canonical: "/profile" },
robots: { index: false, follow: false },
};
export default async function ProfilePage() {
const session = await getServerSession(authOptions);
const discordId = getSessionDiscordId(session);
let content = <ProfileLoginCard />;
if (session?.user && discordId) {
const guildProfile = await loadGuildProfile(discordId);
content = (
<>
<RealtimeRefresh topic="leaderboards" leaderboard="profile" />
<ProfilePassport
userName={session.user.name ?? ""}
userImage={session.user.image ?? ""}
profile={guildProfile.profile}
profileUnavailable={guildProfile.profileUnavailable}
xp={guildProfile.xp}
voice={guildProfile.voice}
/>
</>
);
}
return (
<main className="relative min-h-screen overflow-hidden bg-background text-foreground">
<div className="relative mx-auto flex w-full max-w-5xl flex-col gap-6 px-4 py-6 sm:px-6 lg:py-10">
<nav aria-label="ทางลัด" className="flex items-center justify-between gap-3">
<Button variant="ghost" asChild>
<Link href="/">
<ArrowLeft data-icon="inline-start" />
กลับหน้าหลัก
</Link>
</Button>
<ThemeToggle />
</nav>
{content}
</div>
</main>
);
}