import { createClient } from "@/utils/supabase/server"; import { redirect } from "next/navigation"; import { headers } from "next/headers"; import type { Profile } from "@/types/profile"; import { getSignedAvatarUrl } from "@/utils/assets/avatars"; import { EditableName } from "./editable-name"; import { ShareProfileButton } from "./share-profile"; import { AvatarUpload } from "./avatar-upload"; export default async function ProfilePage() { const supabase = await createClient(); const { data: { user }, } = await supabase.auth.getUser(); if (!user) return redirect("/login"); const { data: profile } = await supabase .from("users") .select("*") .eq("id", user.id) .single(); if (!profile) { return (

Profile not found.

); } // Generate a signed URL for the user's own avatar const avatarUrl = profile.avatar_url ? await getSignedAvatarUrl(profile.id) : null; const memberSince = new Date(profile.created_at).toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric", }); // Build the full share URL for the QR code const requestHeaders = await headers(); const host = requestHeaders.get("host") ?? "localhost:3000"; const protocol = requestHeaders.get("x-forwarded-proto") ?? "https"; const basePath = process.env.BASE_PATH ?? ""; const shareUrl = `${protocol}://${host}${basePath}/friends/add?id=${profile.id}`; return (
{/* Header */}

Profile

Manage your account information.

{/* Profile Card */}
{/* Banner area */}
{/* Avatar + name */}

{profile.email}

{/* Details */}

Account Details

); } function DetailRow({ label, value, mono, badge, }: { label: string; value: string; mono?: boolean; badge?: "green" | "yellow"; }) { return (
{label}
{badge ? ( {value} ) : ( {value} )}
); }