feat: add Discord avatar to share header
This commit is contained in:
+20
-1
@@ -1,15 +1,26 @@
|
||||
import type { Metadata } from "next";
|
||||
import Link from "next/link";
|
||||
import { getServerSession } from "next-auth";
|
||||
import { ArrowLeft, Plus } from "lucide-react";
|
||||
import { DropdownMenuAvatar } from "@/components/avatar";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ThemeToggle } from "@/components/theme-toggle";
|
||||
import { getSessionDiscordId } from "@/lib/auth/auth";
|
||||
import { authOptions } from "@/lib/auth/auth-options";
|
||||
import { getDiscordMemberProfile } from "@/lib/discord/discord";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Share | Erika!",
|
||||
description: "แชร์ข้อความและไฟล์ .txt ผ่านลิงก์สั้น",
|
||||
};
|
||||
|
||||
export default function ShareLayout({ children }: { children: React.ReactNode }) {
|
||||
export default async function ShareLayout({ children }: { children: React.ReactNode }) {
|
||||
const session = await getServerSession(authOptions);
|
||||
const discordId = getSessionDiscordId(session);
|
||||
const profile = discordId
|
||||
? await getDiscordMemberProfile(discordId)
|
||||
: null;
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-background text-foreground">
|
||||
<header className="sticky top-0 z-10 border-b bg-background/90 backdrop-blur">
|
||||
@@ -31,6 +42,14 @@ export default function ShareLayout({ children }: { children: React.ReactNode })
|
||||
สร้างลิงก์
|
||||
</Link>
|
||||
</Button>
|
||||
{session?.user && (
|
||||
<DropdownMenuAvatar
|
||||
userName={session.user.name ?? ""}
|
||||
userImage={session.user.image ?? ""}
|
||||
profile={profile}
|
||||
showName={false}
|
||||
/>
|
||||
)}
|
||||
<ThemeToggle />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user