mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-20 06:24:06 +01:00
feat: fetch profile image for nav bar
This commit is contained in:
parent
c99301a66d
commit
ac2af453e5
@ -16,9 +16,10 @@ import { useUserRole } from "@/hooks/useUserRole";
|
|||||||
|
|
||||||
interface AuthenticatedComponentsProps {
|
interface AuthenticatedComponentsProps {
|
||||||
uid: string;
|
uid: string;
|
||||||
|
avatarUrl?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AuthenticatedComponents = ({ uid }: AuthenticatedComponentsProps) => {
|
export const AuthenticatedComponents = ({ uid, avatarUrl }: AuthenticatedComponentsProps) => {
|
||||||
const notifications = 100;
|
const notifications = 100;
|
||||||
const displayValue = notifications >= 100 ? "..." : notifications;
|
const displayValue = notifications >= 100 ? "..." : notifications;
|
||||||
const { data } = useUserRole();
|
const { data } = useUserRole();
|
||||||
@ -44,7 +45,12 @@ export const AuthenticatedComponents = ({ uid }: AuthenticatedComponentsProps) =
|
|||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button variant="outline" size="icon" className="overflow-hidden rounded-full">
|
<Button variant="outline" size="icon" className="overflow-hidden rounded-full">
|
||||||
<Avatar>
|
<Avatar>
|
||||||
<AvatarImage src="https://api.dicebear.com/9.x/pixel-art/svg" />
|
{avatarUrl ? (
|
||||||
|
<AvatarImage src={avatarUrl} alt="profile" />
|
||||||
|
) : (
|
||||||
|
<AvatarImage src="https://api.dicebear.com/9.x/pixel-art/svg" alt="profile" />
|
||||||
|
)}
|
||||||
|
|
||||||
<AvatarFallback>1</AvatarFallback>
|
<AvatarFallback>1</AvatarFallback>
|
||||||
</Avatar>
|
</Avatar>
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import { SearchBar } from "./serchBar";
|
|||||||
import { AuthenticatedComponents } from "./AuthenticatedComponents";
|
import { AuthenticatedComponents } from "./AuthenticatedComponents";
|
||||||
import { UnAuthenticatedComponents } from "./UnAuthenticatedComponents";
|
import { UnAuthenticatedComponents } from "./UnAuthenticatedComponents";
|
||||||
|
|
||||||
|
import { createSupabaseClient } from "@/lib/supabase/serverComponentClient";
|
||||||
import { getUserId } from "@/lib/supabase/actions/getUserId";
|
import { getUserId } from "@/lib/supabase/actions/getUserId";
|
||||||
|
|
||||||
const ListItem = React.forwardRef<React.ElementRef<"a">, React.ComponentPropsWithoutRef<"a">>(
|
const ListItem = React.forwardRef<React.ElementRef<"a">, React.ComponentPropsWithoutRef<"a">>(
|
||||||
@ -44,8 +45,9 @@ const ListItem = React.forwardRef<React.ElementRef<"a">, React.ComponentPropsWit
|
|||||||
ListItem.displayName = "ListItem";
|
ListItem.displayName = "ListItem";
|
||||||
|
|
||||||
export async function NavigationBar() {
|
export async function NavigationBar() {
|
||||||
|
const client = createSupabaseClient();
|
||||||
const userId = await getUserId();
|
const userId = await getUserId();
|
||||||
|
const { data: avatarUrl } = await client.from("profiles").select("avatar_url").eq("id", userId).single();
|
||||||
const businessComponents = [
|
const businessComponents = [
|
||||||
{
|
{
|
||||||
title: "Business",
|
title: "Business",
|
||||||
@ -119,7 +121,11 @@ export async function NavigationBar() {
|
|||||||
<ThemeToggle />
|
<ThemeToggle />
|
||||||
</div>
|
</div>
|
||||||
<Separator orientation="vertical" className="mx-3" />
|
<Separator orientation="vertical" className="mx-3" />
|
||||||
{userId ? <AuthenticatedComponents uid={userId} /> : <UnAuthenticatedComponents />}
|
{userId ? (
|
||||||
|
<AuthenticatedComponents uid={userId} avatarUrl={avatarUrl?.avatar_url} />
|
||||||
|
) : (
|
||||||
|
<UnAuthenticatedComponents />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user