Skip to content

Commit

Permalink
Revert "Fix: Hide Login/Signup button when user is authenticated"
Browse files Browse the repository at this point in the history
  • Loading branch information
Prudent Bird authored Jul 30, 2024
1 parent 6466dbf commit e187d87
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { Inter } from "next/font/google";

import "./globals.css";

import { SessionProvider } from "next-auth/react";

import Providers from "~/components/providers";
import { Toaster } from "~/components/ui/toaster";

Expand All @@ -24,7 +22,7 @@ export default function RootLayout({
<body className={inter.className}>
<div className="mx-auto w-full">
<Providers />
<SessionProvider>{children}</SessionProvider>
{children}
<Toaster />
</div>
</body>
Expand Down
2 changes: 0 additions & 2 deletions src/components/card/user-card.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AnimatePresence, motion } from "framer-motion";
import { signOut } from "next-auth/react";
import { useEffect, useState } from "react";

import { useUser } from "~/hooks/user/use-user";
Expand All @@ -13,7 +12,6 @@ const UserCard = ({ email }: { email: string }) => {
const handleLogout = () => {
updateUser({ email: "", name: "" });
setIsLogout(false);
signOut({ callbackUrl: "/" });
};

const handleEscapeClick = (event: KeyboardEvent) => {
Expand Down
11 changes: 5 additions & 6 deletions src/components/layouts/navbar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
"use client";

import { useSession } from "next-auth/react";
import Link from "next/link";
import { useEffect, useState } from "react";

import UserCard from "~/components/card/user-card";
import Logo from "~/components/common/logo";
import { useUser } from "~/hooks/user/use-user";
import { cn } from "~/lib/utils";
import { NAV_LINKS } from "./links";
import MobileNav from "./mobile-navbar";

const Navbar = () => {
const [scrolling, setIsScrolling] = useState<boolean>(false);
const { data: session } = useSession();
const { user } = useUser();

const handleScrollEvent = () => {
if (window.scrollY > 1) {
Expand All @@ -36,7 +36,7 @@ const Navbar = () => {
className={cn(
`relative mx-auto flex w-full max-w-[1200px] items-center gap-x-4 transition-all duration-500 md:justify-between`,
scrolling ? "py-2" : "py-4 md:py-9",
session?.user?.email && "justify-between",
user.email && "justify-between",
)}
>
<MobileNav />
Expand All @@ -55,9 +55,7 @@ const Navbar = () => {
);
})}
</div>
{session?.user?.email ? (
<UserCard email={session?.user?.email} />
) : (
{!user.email && (
<div className="w-fullx hidden items-center justify-end gap-x-4 justify-self-end md:flex lg:gap-x-8">
<Link
href="/login"
Expand All @@ -73,6 +71,7 @@ const Navbar = () => {
</Link>
</div>
)}
{user.email && <UserCard email={user.email} />}
</div>
</nav>
);
Expand Down

0 comments on commit e187d87

Please sign in to comment.