diff --git a/package-lock.json b/package-lock.json index 361a165..fdcc5d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "b2d-ventures", "version": "0.1.0", "dependencies": { + "@radix-ui/react-avatar": "^1.1.0", "@radix-ui/react-dropdown-menu": "^2.1.1", "@radix-ui/react-navigation-menu": "^1.2.0", "@radix-ui/react-progress": "^1.1.0", @@ -475,6 +476,31 @@ } } }, + "node_modules/@radix-ui/react-avatar": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-avatar/-/react-avatar-1.1.0.tgz", + "integrity": "sha512-Q/PbuSMk/vyAd/UoIShVGZ7StHHeRFYU7wXmi5GV+8cLXflZAEpHL/F697H1klrzxKXNtZ97vWiC0q3RKUH8UA==", + "dependencies": { + "@radix-ui/react-context": "1.1.0", + "@radix-ui/react-primitive": "2.0.0", + "@radix-ui/react-use-callback-ref": "1.1.0", + "@radix-ui/react-use-layout-effect": "1.1.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-collection": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.1.0.tgz", diff --git a/src/components/navigationBar/Unsigned.tsx b/src/components/navigationBar/Unsigned.tsx index 2bc21c2..89d5761 100644 --- a/src/components/navigationBar/Unsigned.tsx +++ b/src/components/navigationBar/Unsigned.tsx @@ -17,7 +17,11 @@ import { NavigationMenuTrigger, navigationMenuTriggerStyle, } from "@/components/ui/navigation-menu"; -import { Search } from "lucide-react"; +import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; +import { Skeleton } from "@/components/ui/skeleton"; +import { Search, Bell, Heart, Wallet } from "lucide-react"; + +import useSession from "@/lib/supabase/useSession"; const landings = [ { @@ -54,7 +58,44 @@ const ListItem = React.forwardRef, React.ComponentPropsWit ); ListItem.displayName = "ListItem"; +const unAuthenticatedComponents = () => { + return ( +
+ + + + +
+ ); +}; + +const authenticatedComponents = () => { + return ( +
+ + + + + + 1 + +
+ ); +}; + export function UnsignedNav() { + const { session, loading } = useSession(); + const user = session?.user; + const [sessionLoaded, setSessionLoaded] = React.useState(false); + + React.useEffect(() => { + if (!loading) { + setSessionLoaded(true); + } + }, [loading]); + const businessComponents = [ { title: "Businesses", @@ -151,12 +192,17 @@ export function UnsignedNav() {
- - - - + {sessionLoaded ? ( + user ? ( + authenticatedComponents() + ) : ( + unAuthenticatedComponents() + ) + ) : ( +
+ +
+ )}
diff --git a/src/components/ui/skeleton.tsx b/src/components/ui/skeleton.tsx new file mode 100644 index 0000000..01b8b6d --- /dev/null +++ b/src/components/ui/skeleton.tsx @@ -0,0 +1,15 @@ +import { cn } from "@/lib/utils" + +function Skeleton({ + className, + ...props +}: React.HTMLAttributes) { + return ( +
+ ) +} + +export { Skeleton } diff --git a/src/lib/supabase/useSession.ts b/src/lib/supabase/useSession.ts new file mode 100644 index 0000000..c4bb61e --- /dev/null +++ b/src/lib/supabase/useSession.ts @@ -0,0 +1,27 @@ +"use client"; + +import { useEffect, useState } from "react"; +import { createSupabaseClient } from "./clientComponentClient"; +import { Session } from "@supabase/supabase-js"; + +export default function useSession() { + const [session, setSession] = useState(null); + const [loading, setLoading] = useState(true); + + useEffect(() => { + const supabase = createSupabaseClient(); + + const getSession = async () => { + const { + data: { session }, + } = await supabase.auth.getSession(); + + setSession(session); + setLoading(false); + }; + + getSession(); + }, []); + + return { session, loading }; +}