Skip to content

Commit dbda4a1

Browse files
committed
Revert "Fix nav to work with ssg agent store (but also introduce on-load jump)"
This reverts commit 28b83b6.
1 parent 28b83b6 commit dbda4a1

File tree

2 files changed

+59
-145
lines changed

2 files changed

+59
-145
lines changed

web/src/components/navbar/client-auth-nav.tsx

Lines changed: 0 additions & 96 deletions
This file was deleted.

web/src/components/navbar/navbar.tsx

Lines changed: 59 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
import { Menu, DollarSign, BookHeart, Bot } from 'lucide-react'
1+
import {
2+
Menu,
3+
DollarSign,
4+
LogIn,
5+
BarChart2,
6+
BookHeart,
7+
User,
8+
Bot,
9+
} from 'lucide-react'
210
import Image from 'next/image'
311
import Link from 'next/link'
4-
import dynamic from 'next/dynamic'
12+
import { getServerSession } from 'next-auth'
513

14+
import { UserDropdown } from './user-dropdown'
615
import { Button } from '../ui/button'
716
import {
817
DropdownMenu,
@@ -12,47 +21,12 @@ import {
1221
} from '../ui/dropdown-menu'
1322
import { Icons } from '../icons'
1423

15-
// TODO: This dynamic pattern might not be the best way to handle the navbar. Reconsider from first principles.
16-
17-
// Dynamically import client auth components to prevent SSR and enable SSG
18-
const ClientAuthNav = dynamic(
19-
() =>
20-
import('./client-auth-nav').then((mod) => ({ default: mod.ClientAuthNav })),
21-
{
22-
ssr: false,
23-
loading: () => <div className="w-[50px] h-[40px]" />, // Placeholder to prevent layout shift
24-
}
25-
)
26-
27-
const ClientUsageLink = dynamic(
28-
() =>
29-
import('./client-auth-nav').then((mod) => ({
30-
default: mod.ClientUsageLink,
31-
})),
32-
{
33-
ssr: false,
34-
}
35-
)
36-
37-
const ClientMobileUsageLink = dynamic(
38-
() =>
39-
import('./client-auth-nav').then((mod) => ({
40-
default: mod.ClientMobileUsageLink,
41-
})),
42-
{
43-
ssr: false,
44-
}
45-
)
24+
import { authOptions } from '@/app/api/auth/[...nextauth]/auth-options'
25+
import { cn } from '@/lib/utils'
4626

47-
const ClientMobileAuthNav = dynamic(
48-
() =>
49-
import('./client-auth-nav').then((mod) => ({ default: mod.ClientAuthNav })),
50-
{
51-
ssr: false,
52-
}
53-
)
27+
export const Navbar = async () => {
28+
const session = await getServerSession(authOptions)
5429

55-
export const Navbar = () => {
5630
return (
5731
<header className="container mx-auto p-4 flex justify-between items-center relative z-10">
5832
<Link
@@ -97,9 +71,15 @@ export const Navbar = () => {
9771
<Bot className="h-4 w-4" />
9872
Agent Store
9973
</Link>
100-
<div className="min-w-[50px] flex items-center">
101-
<ClientUsageLink />
102-
</div>
74+
75+
{session && (
76+
<Link
77+
href="/usage"
78+
className="hover:text-blue-400 transition-colors font-medium px-2 py-1 rounded-md hover:bg-blue-50 dark:hover:bg-blue-900/20"
79+
>
80+
Usage
81+
</Link>
82+
)}
10383
</nav>
10484
<div className="flex items-center space-x-3">
10585
<DropdownMenu>
@@ -139,13 +119,43 @@ export const Navbar = () => {
139119
Agent Store
140120
</Link>
141121
</DropdownMenuItem>
142-
<ClientMobileUsageLink />
143-
<ClientMobileAuthNav isMobile />
122+
123+
{session && (
124+
<DropdownMenuItem asChild>
125+
<Link href="/usage" className="flex items-center">
126+
<BarChart2 className="mr-2 h-4 w-4" />
127+
Usage
128+
</Link>
129+
</DropdownMenuItem>
130+
)}
131+
{!session && (
132+
<DropdownMenuItem asChild>
133+
<Link href="/login" className="flex items-center">
134+
<LogIn className="mr-2 h-4 w-4" />
135+
Log in
136+
</Link>
137+
</DropdownMenuItem>
138+
)}
144139
</DropdownMenuContent>
145140
</DropdownMenu>
146-
<div className="min-w-[50px] h-[44px] flex items-center justify-end -ml-3">
147-
<ClientAuthNav />
148-
</div>
141+
{session ? (
142+
<UserDropdown session={session} />
143+
) : (
144+
<Link href="/login" className="hidden md:inline-block relative group">
145+
<div className="absolute inset-0 bg-[rgb(255,110,11)] translate-x-0.5 -translate-y-0.5" />
146+
<Button
147+
className={cn(
148+
'relative',
149+
'bg-white text-black hover:bg-white',
150+
'border border-white/50',
151+
'transition-all duration-300',
152+
'group-hover:-translate-x-0.5 group-hover:translate-y-0.5'
153+
)}
154+
>
155+
Log in
156+
</Button>
157+
</Link>
158+
)}
149159
{/* <ThemeSwitcher /> */}
150160
</div>
151161
</header>

0 commit comments

Comments
 (0)