Skip to content

Commit

Permalink
Made navbar change appropriately to whether user is logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
sonofthomp committed Nov 2, 2024
1 parent 3b5f756 commit 37c85bb
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions frontend/src/app/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { useRouter } from "next/navigation";
import { User } from "firebase/auth";

const navBarLinks = [
{ name: "Home", link: "/" },
{ name: "About", link: "/about" },
{ name: "Carbon Dashboard", link: "/dashboard" },
{ name: "Transactions", link: "/transactions" },
{ name: "Map", link: "/map" },
{ name: "Home", link: "/", access_restricted: false },
{ name: "About", link: "/about", access_restricted: false },
{ name: "Carbon Dashboard", link: "/dashboard", access_restricted: true },
{ name: "Transactions", link: "/transactions", access_restricted: true },
{ name: "Map", link: "/map", access_restricted: true },
];

const Navbar = () => {
Expand Down Expand Up @@ -53,13 +53,15 @@ const Navbar = () => {

<div className="hidden max-w-full flex-grow justify-end overflow-clip sm:flex">
<ul className="flex items-center gap-2 2xsm:gap-6">
{navBarLinks.map(({ name, link }) => (
<li key={name}>
<a href={link} className="text-sm font-extrabold text-black">
{name.toUpperCase()}
</a>
</li>
))}
{navBarLinks.map(({ name, link, access_restricted }) =>
user || !access_restricted ? (
<li key={name}>
<a href={link} className="text-sm font-extrabold text-black">
{name.toUpperCase()}
</a>
</li>
) : null
)}
<li>
{user ? (
<button
Expand Down

0 comments on commit 37c85bb

Please sign in to comment.