mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-19 05:54:06 +01:00
feat: retrive profile base on user_id
This commit is contained in:
parent
398ef2fe25
commit
ba6a785c71
@ -1,5 +1,3 @@
|
|||||||
// components/ProfilePage.tsx
|
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { createSupabaseClient } from "@/lib/supabase/serverComponentClient";
|
import { createSupabaseClient } from "@/lib/supabase/serverComponentClient";
|
||||||
@ -10,22 +8,11 @@ import ReactMarkdown from "react-markdown";
|
|||||||
|
|
||||||
interface Profile extends Tables<"Profiles"> {}
|
interface Profile extends Tables<"Profiles"> {}
|
||||||
|
|
||||||
export default async function ProfilePage() {
|
export default async function ProfilePage({ params }: { params: { uid: string } }) {
|
||||||
const supabase = createSupabaseClient();
|
const supabase = createSupabaseClient();
|
||||||
|
const uid = params.uid;
|
||||||
|
|
||||||
const {
|
const { data: profileData, error } = await getUserProfile(supabase, uid);
|
||||||
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);
|
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return (
|
return (
|
||||||
@ -32,7 +32,7 @@ const UnAuthenticatedComponents = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const AuthenticatedComponents = () => {
|
const AuthenticatedComponents = ({ uid }: { uid: string }) => {
|
||||||
let notifications = 100;
|
let notifications = 100;
|
||||||
const displayValue = notifications >= 100 ? "..." : notifications;
|
const displayValue = notifications >= 100 ? "..." : notifications;
|
||||||
return (
|
return (
|
||||||
@ -58,7 +58,7 @@ const AuthenticatedComponents = () => {
|
|||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent align="end">
|
<DropdownMenuContent align="end">
|
||||||
<DropdownMenuItem>
|
<DropdownMenuItem>
|
||||||
<Link href="/profile">Profile</Link>
|
<Link href={`/profile/${uid}`}>Profile</Link>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
<DropdownMenuItem>Settings</DropdownMenuItem>
|
<DropdownMenuItem>Settings</DropdownMenuItem>
|
||||||
@ -88,7 +88,7 @@ export function ProfileBar() {
|
|||||||
<>
|
<>
|
||||||
{sessionLoaded ? (
|
{sessionLoaded ? (
|
||||||
user ? (
|
user ? (
|
||||||
<AuthenticatedComponents />
|
<AuthenticatedComponents uid={user.id} />
|
||||||
) : (
|
) : (
|
||||||
<UnAuthenticatedComponents />
|
<UnAuthenticatedComponents />
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user