Skip to content

Commit 97f757d

Browse files
Merge pull request #2 from AtharvaChobe/fix/shadcn-ui#243-login-btn-removed-and-added-profile-btn
removed the login btn after login and added a profile button
2 parents 68f680c + 007b250 commit 97f757d

File tree

1 file changed

+34
-10
lines changed

1 file changed

+34
-10
lines changed

app/(marketing)/layout.tsx

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import Link from "next/link"
2-
2+
import { UserAccountNav } from "@/components/user-account-nav"
33
import { marketingConfig } from "@/config/marketing"
44
import { cn } from "@/lib/utils"
55
import { buttonVariants } from "@/components/ui/button"
66
import { MainNav } from "@/components/main-nav"
77
import { SiteFooter } from "@/components/site-footer"
8+
import { getCurrentUser } from "@/lib/session"
89

910
interface MarketingLayoutProps {
1011
children: React.ReactNode
@@ -13,21 +14,44 @@ interface MarketingLayoutProps {
1314
export default async function MarketingLayout({
1415
children,
1516
}: MarketingLayoutProps) {
17+
18+
19+
let user: any;
20+
getCurrentUser().then(currentUser => {
21+
user = currentUser;
22+
});
23+
24+
1625
return (
1726
<div className="flex min-h-screen flex-col">
1827
<header className="container z-40 bg-background">
1928
<div className="flex h-20 items-center justify-between py-6">
2029
<MainNav items={marketingConfig.mainNav} />
2130
<nav>
22-
<Link
23-
href="/login"
24-
className={cn(
25-
buttonVariants({ variant: "secondary", size: "sm" }),
26-
"px-4"
27-
)}
28-
>
29-
Login
30-
</Link>
31+
{
32+
user
33+
?
34+
<Link
35+
href="/login"
36+
className={cn(
37+
buttonVariants({ variant: "secondary", size: "sm" }),
38+
"px-4"
39+
)}
40+
>
41+
Login
42+
</Link>
43+
:
44+
<div className='flex justify-center items-center gap-3'>
45+
<h3>Welcome {user.name}</h3>
46+
<UserAccountNav
47+
user={{
48+
name: user.name,
49+
image: user.image,
50+
email: user.email,
51+
}}
52+
/>
53+
</div>
54+
}
3155
</nav>
3256
</div>
3357
</header>

0 commit comments

Comments
 (0)