@@ -6,10 +6,19 @@ import { useSession } from "next-auth/react";
66import { motion } from "framer-motion" ;
77import { Button } from "./ui/button" ;
88import UserAccountDropDown from "./UserAccountDropDown" ;
9+ import { useEffect , useState } from "react" ;
10+ import { Circle } from "lucide-react" ;
911
1012export const Appbar = ( ) => {
11- const session = useSession ( ) ;
12- const user = session . data ?. user ;
13+ // const session = useSession();
14+ // const user = session.data?.user;
15+ const [ initialLoading , setInitialLoading ] = useState < boolean > ( true ) ;
16+ const { data : session , status } = useSession ( ) ;
17+ useEffect ( ( ) => {
18+ if ( status !== "loading" ) {
19+ setInitialLoading ( false ) ;
20+ }
21+ } , [ status , session ] ) ;
1322
1423 return (
1524 < nav className = "sticky mx-auto wrapper top-0 z-50 flex items-center gap-2 w-full" >
@@ -20,32 +29,18 @@ export const Appbar = () => {
2029 className = "flex w-full justify-between mx-auto bg-secondary/15 shadow-lg shadow-neutral-600/5 backdrop-blur-lg border border-primary/10 p-4 rounded-b-2xl lg:px-24"
2130 >
2231 < Link href = { "/" } className = "flex items-center gap-2 cursor-pointer" >
23- { /* <Image
24- src={"https://appx-wsb-gcp.akamai.net.in/subject/2023-01-17-0.17044360120951185.jpg"}
25- alt="Logo"
26- width={300}
27- height={200}
28- className="rounded-full size-10"
29- /> */ }
3032 < span className = "text-2xl md:text-3xl font-bold tracking-tight text-foreground block custom-text-color animate-pulse backdrop-blur-lg" >
3133 Imaginate AI
3234 </ span >
3335 </ Link >
3436 < div className = "flex items-center gap-8" >
35- { ! user ? (
36- < Button
37- size = { "lg" }
38- onClick = { async ( ) => {
39- await signIn ( 'google' ) ;
40- } }
41- >
42- Login
43- </ Button >
37+ { initialLoading && status === "loading" ? (
38+ < Circle className = "animate-spin" />
39+ ) : ! session ? (
40+ < Button size = { "lg" } onClick = { async ( ) => { await signIn ( 'google' ) ; } } > Login</ Button >
4441 ) : (
45- ""
42+ < UserAccountDropDown />
4643 ) }
47-
48- < UserAccountDropDown />
4944 </ div >
5045 </ motion . div >
5146 </ nav >
0 commit comments