Skip to content

Commit 598fde2

Browse files
authored
Merge pull request #189 from Ameerjafar/session
Added the spinner until the session get's the image
2 parents 6d6275c + e0d54b3 commit 598fde2

File tree

4 files changed

+35
-11
lines changed

4 files changed

+35
-11
lines changed

src/app/page.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import Appbar from '@/components/Appbar/Appbar'
21
import { Footer } from '@/components/Appbar/Footer'
32
import Home from '@/components/Home/Home'
43
import { ScrollToTopButton } from '@/components/ui/scroll-to-top-button'
54

65
export default function Page() {
76
return (
87
<>
9-
<Appbar />
108
<Home />
119
<Footer />
1210
<ScrollToTopButton />
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const AppBarSkeleton = () => {
2+
return (
3+
<header className="animate-pulse w-screen py-4 border-b md:border-none fixed top-0 left-0 right-0 bg-white md:bg-white/0 z-50 ">
4+
<div className="container pl-32 px-4 ">
5+
<div className="flex justify-between items-center md:border md:p-2.5 rounded-xl max-w-2xl lg:max-w-4xl mx-auto md:bg-white/90 md:backdrop:blur-sm">
6+
<div>
7+
<div className="h-10 w-10 rounded-lg inline-flex justify-center items-center bg-gray-200">
8+
</div>
9+
</div>
10+
<div className="hidden md:block">
11+
<nav className="flex gap-8 rounded-md">
12+
<div className = 'rounded-md bg-gray-300 w-20 h-5'></div>
13+
<div className = 'rounded-md bg-gray-300 w-20 h-5'></div>
14+
<div className = 'rounded-md bg-gray-300 w-20 h-5'></div>
15+
<div className = 'rounded-md bg-gray-300 w-20 h-5'></div>
16+
</nav>
17+
</div>
18+
<div className = 'rounded-md h-8 w-20 bg-gray-200'>
19+
</div>
20+
</div>
21+
</div>
22+
</header>
23+
)
24+
}
25+
26+
27+
export default AppBarSkeleton;

src/components/Appbar/Appbar.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
'use client'
2-
32
import Link from 'next/link'
4-
53
import Logo from '../icons/Logo'
64
import { Menu } from 'lucide-react'
7-
import { useSession } from 'next-auth/react'
85
import LoginWithGoogleButton from '../ui/login-with-google'
96
import { WalletMultiButton } from '@solana/wallet-adapter-react-ui'
107
import { useRouter } from 'next/navigation'
118
import { useEffect, useState } from 'react'
129
import { FaWallet } from 'react-icons/fa6'
1310
import { useWallet } from '@solana/wallet-adapter-react'
1411
import ProfileDropDown from '../common/ProfileDropDown'
12+
import { useSession } from 'next-auth/react'
1513

1614
const Appbar = () => {
17-
const { data } = useSession()
18-
const router = useRouter()
15+
const { data,status } = useSession();
16+
const router = useRouter();
1917
const [isMounted, setIsMounted] = useState(false)
2018
const { connected } = useWallet()
2119
const [opacity, setOpacity] = useState(1);
@@ -99,7 +97,7 @@ const Appbar = () => {
9997
{/* <LoginWithGoogleButton />*/}
10098
{/* </>*/}
10199
{/*)}*/}
102-
{data && (
100+
{status === "authenticated" && data && (
103101
<button
104102
onClick={() => {
105103
router.push('/wallet')
@@ -131,7 +129,7 @@ const Appbar = () => {
131129
endIcon={<FaWallet />}
132130
/>
133131
)}
134-
<LoginWithGoogleButton />
132+
{status === 'unauthenticated' && <LoginWithGoogleButton />}
135133
</>
136134
)}
137135
<span className="md:hidden">

src/components/Home/Hero.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import Image from 'next/image'
66
import Appbar from '../Appbar/Appbar'
77
import { signIn, useSession } from 'next-auth/react'
88
import { useRouter } from 'next/navigation'
9+
import AppBarSkeleton from '../Appbar/AppBarSkeleton'
910

1011
const Hero = () => {
11-
const session = useSession()
12+
const session = useSession();
1213
const router = useRouter()
1314
return (
1415
<section className="items-center md:mt-40 mt-28">
15-
<Appbar />
16+
{session.status === 'loading' ? <AppBarSkeleton /> : <Appbar />}
1617
<div className="container relative mx-auto px-4">
1718
<Image
1819
src="https://res.cloudinary.com/dtc9ysbnn/image/upload/v1723236916/solana_eoqyva.svg"

0 commit comments

Comments
 (0)