1
0

Hide transactions button if not logged in

This commit is contained in:
Ahmed Al-Taiar
2023-11-22 11:58:57 -05:00
parent c9946b3d33
commit fb78791be7

View File

@ -17,7 +17,7 @@ type NavBarLayoutProps = {
} }
const NavBarLayout = ({ children }: NavBarLayoutProps) => { const NavBarLayout = ({ children }: NavBarLayoutProps) => {
const { hasRole } = useAuth() const { hasRole, isAuthenticated } = useAuth()
const [basket] = useState(getBasket()) const [basket] = useState(getBasket())
return ( return (
@ -40,14 +40,18 @@ const NavBarLayout = ({ children }: NavBarLayoutProps) => {
</div> </div>
<div className="ml-auto justify-end space-x-3"> <div className="ml-auto justify-end space-x-3">
<ul className="relative hidden items-center space-x-3 lg:flex"> <ul className="relative hidden items-center space-x-3 lg:flex">
<li> {isAuthenticated ? (
<Link <li>
to={routes.userTransactions()} <Link
className="btn btn-ghost font-inter hover:shadow-lg" to={routes.userTransactions()}
> className="btn btn-ghost font-inter hover:shadow-lg"
Transactions >
</Link> Transactions
</li> </Link>
</li>
) : (
<></>
)}
</ul> </ul>
<ThemeToggle /> <ThemeToggle />
<Link <Link
@ -114,14 +118,18 @@ const NavBarLayout = ({ children }: NavBarLayoutProps) => {
<p className="font-inter text-base">Basket</p> <p className="font-inter text-base">Basket</p>
</Link> </Link>
</li> </li>
<li> {isAuthenticated ? (
<Link <li>
to={routes.userTransactions()} <Link
className="btn btn-ghost w-full hover:shadow-lg" to={routes.userTransactions()}
> className="btn btn-ghost w-full hover:shadow-lg"
<p className="font-inter text-base">Transactions</p> >
</Link> <p className="font-inter text-base">Transactions</p>
</li> </Link>
</li>
) : (
<></>
)}
</ul> </ul>
</div> </div>
</div> </div>