45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import type { Metadata } from "next";
|
|
import { getServerSession } from "next-auth";
|
|
import { ProfileLoginCard } from "./client";
|
|
import { ProfilePassport } from "./content";
|
|
import { authOptions } from "@/lib/auth/auth-options";
|
|
import { getSessionDiscordId } from "@/lib/auth/auth";
|
|
import { loadGuildProfile } from "@/lib/profile/guild-profile";
|
|
import { RealtimeRefresh } from "@/components/realtime-refresh";
|
|
|
|
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 content;
|
|
}
|