feat: retrive profile base on user_id

This commit is contained in:
sirin 2024-10-14 18:36:57 +07:00
parent 398ef2fe25
commit ba6a785c71
2 changed files with 6 additions and 19 deletions

View File

@ -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 (
<div className="flex items-center justify-center h-screen">
<p className="text-red-500">No user found!</p>
</div>
);
}
const { data: profileData, error } = await getUserProfile(supabase, user.id);
const { data: profileData, error } = await getUserProfile(supabase, uid);
if (error) {
return (

View File

@ -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 = () => {
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem>
<Link href="/profile">Profile</Link>
<Link href={`/profile/${uid}`}>Profile</Link>
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem>Settings</DropdownMenuItem>
@ -88,7 +88,7 @@ export function ProfileBar() {
<>
{sessionLoaded ? (
user ? (
<AuthenticatedComponents />
<AuthenticatedComponents uid={user.id} />
) : (
<UnAuthenticatedComponents />
)