From ba6a785c71ef9138748c69c46c1acf2cc9d45f8a Mon Sep 17 00:00:00 2001 From: sirin Date: Mon, 14 Oct 2024 18:36:57 +0700 Subject: [PATCH] feat: retrive profile base on user_id --- src/app/(user)/profile/{ => [uid]}/page.tsx | 19 +++---------------- src/components/navigationBar/profileBar.tsx | 6 +++--- 2 files changed, 6 insertions(+), 19 deletions(-) rename src/app/(user)/profile/{ => [uid]}/page.tsx (90%) diff --git a/src/app/(user)/profile/page.tsx b/src/app/(user)/profile/[uid]/page.tsx similarity index 90% rename from src/app/(user)/profile/page.tsx rename to src/app/(user)/profile/[uid]/page.tsx index ceecf73..b45fd9f 100644 --- a/src/app/(user)/profile/page.tsx +++ b/src/app/(user)/profile/[uid]/page.tsx @@ -1,5 +1,3 @@ -// components/ProfilePage.tsx - import React from "react"; import Image from "next/image"; import { createSupabaseClient } from "@/lib/supabase/serverComponentClient"; @@ -10,22 +8,11 @@ import ReactMarkdown from "react-markdown"; interface Profile extends Tables<"Profiles"> {} -export default async function ProfilePage() { +export default async function ProfilePage({ params }: { params: { uid: string } }) { const supabase = createSupabaseClient(); + const uid = params.uid; - const { - data: { user }, - } = await supabase.auth.getUser(); - - if (!user) { - return ( -
-

No user found!

-
- ); - } - - const { data: profileData, error } = await getUserProfile(supabase, user.id); + const { data: profileData, error } = await getUserProfile(supabase, uid); if (error) { return ( diff --git a/src/components/navigationBar/profileBar.tsx b/src/components/navigationBar/profileBar.tsx index 41b31b9..e701ddb 100644 --- a/src/components/navigationBar/profileBar.tsx +++ b/src/components/navigationBar/profileBar.tsx @@ -32,7 +32,7 @@ const UnAuthenticatedComponents = () => { ); }; -const AuthenticatedComponents = () => { +const AuthenticatedComponents = ({ uid }: { uid: string }) => { let notifications = 100; const displayValue = notifications >= 100 ? "..." : notifications; return ( @@ -58,7 +58,7 @@ const AuthenticatedComponents = () => { - Profile + Profile Settings @@ -88,7 +88,7 @@ export function ProfileBar() { <> {sessionLoaded ? ( user ? ( - + ) : ( )