Skip to content

Commit f4914e0

Browse files
committed
Fix user image not showing issue
1 parent 5abde07 commit f4914e0

File tree

3 files changed

+20
-25
lines changed

3 files changed

+20
-25
lines changed

src/components/Appbar.tsx

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,19 @@ import { useSession } from "next-auth/react";
66
import { motion } from "framer-motion";
77
import { Button } from "./ui/button";
88
import UserAccountDropDown from "./UserAccountDropDown";
9+
import { useEffect, useState } from "react";
10+
import { Circle } from "lucide-react";
911

1012
export 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>

src/components/UserAccountDropDown.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { LogOut, UserRound } from "lucide-react";
66
import { useRouter } from "next/navigation";
77
import UserImage from "./UserImage";
88
import { motion, AnimatePresence } from "framer-motion";
9-
// import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "./ui/dropdown-menu";
109
import { Button } from "./ui/button";
1110
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "./ui/dropdown-menu";
1211

src/components/UserImage.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import Image from "next/image";
1+
/* eslint-disable @next/next/no-img-element */
2+
// import Image from "next/image";
23
import React from "react";
34

45
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5-
export default function UserImage(image:any ) {
6+
export default function UserImage({ image }: any) {
67
return (
78
<div>
8-
<Image
9+
<img
910
className="w-full h-full rounded-full cursor-pointer"
1011
src={image || ""}
1112
width={100}

0 commit comments

Comments
 (0)