"use client";
import React, { useState } from "react";
import Link from "next/link";
import Image from "next/image";
import { usePathname } from "next/navigation";
import classnames from "classnames";
import { GiHamburgerMenu } from "react-icons/gi";
import { MdOutlineRestaurantMenu } from "react-icons/md";
import Reserve from "./reserveButton";

const NavBar = () => {
  const currentPath = usePathname();
  console.log(currentPath);
  const [toggle_menu, set_toggle_menu] = useState(false);

  // Create an array to hold the list items
  const links = [
    { label: "Menu", href: "/menu" },
    { label: "Gallery", href: "/gallery" },
    { label: "Reviews", href: "/reviews" },
  ];
  // Create an array to hold the list items
  const links2 = [
    { label: "About", href: "/about-us" },
    { label: "Contact", href: "/contact" },
    // { label: "Dashboard", href: "/dashboard" },
    { label: "Users", href: "/users" },
    // { label: "Issues", href: "/issues" },
  ];

  return (
    <nav className="">
      {/* <center className="text-base-100">O</center> */}
      <div className="flex flex-wrap center items-center justify-center p-4 bg-secondary">
        <div className="-z-10">
          <Image
            src="/img01.webp"
            alt="nav image"
            layout="fill"
            objectFit="cover"
            quality={100}
            className="brightness-50 hidden md:block"
          />
          <Image
            src="/img01.webp"
            alt="nav image"
            layout="fill"
            objectFit="cover"
            className="brightness-0 block md:hidden"
          />
        </div>
        <ul className="hover:cursor-pointer hidden md:block space-x-4 text-xl font-sans antialiased">
          {links.map((link) => (
            <Link
              key={link.href}
              // className={`${link.href === currentPath ? 'text-zinc-900' : 'text-zinc-500 hover:text-zinc-800'}`}
              // replace with classnames object instead
              className={classnames({
                "border-b border-jefesRed text-base-100":
                  link.href === currentPath,
                "text-base-100": link.href !== currentPath,
                "hover:text-jefesRed": true,
              })}
              href={link.href}
            >
              {link.label}
            </Link>
          ))}
        </ul>
        <Link href="/">
          <Image
            src="/logo.svg"
            width={0}
            height={0}
            sizes="200vw"
            style={{ width: "45%", height: "auto" }}
            alt="Logo"
            className="hidden md:block center mx-auto"
          />
          <Image
            src="/logo.svg"
            width={0}
            height={0}
            sizes="100vw"
            style={{ width: "50%", height: "auto" }}
            alt="Logo"
            className="block md:hidden"
          />
        </Link>
        <ul className="hover:cursor-pointer hidden md:block space-x-4 text-xl font-sans antialiased">
          {links2.map((link) => (
            <Link
              key={link.href}
              // className={`${link.href === currentPath ? 'text-zinc-900' : 'text-zinc-500 hover:text-zinc-800'}`}
              // replace with classnames object instead
              className={classnames({
                "border-b border-jefesRed text-base-100":
                  link.href === currentPath,
                "text-base-100": link.href !== currentPath,
                "hover:text-jefesRed": true,
              })}
              href={link.href}
            >
              {link.label}
            </Link>
          ))}
        </ul>
        <Reserve />
      </div>
      <div className="block md:hidden">
        <GiHamburgerMenu
          className="text-base-100 text-4xl space-x-2 absolute top-3 right-3"
          onClick={() => set_toggle_menu(true)}
        />
        {toggle_menu && (
          <div className="navbar_small_screen_overlay flex_center slide_bottom">
            <MdOutlineRestaurantMenu
              fontSize={27}
              className="text-base-100 absolute top-3 right-3 text-4xl"
              onClick={() => set_toggle_menu(false)}
            />
            <ul className="w-full flex flex-col text-2xl col-auto gap-4 grid-cols-1 table-auto absolute">
              {links.map((link) => (
                <Link
                  key={link.href}
                  // className={`${link.href === currentPath ? 'text-zinc-900' : 'text-zinc-500 hover:text-zinc-800'}`}
                  // replace with classnames object instead
                  className={classnames({
                    "border-b border-jefesRed text-base-100":
                      link.href === currentPath,
                    "text-base-100": link.href !== currentPath,
                    // "hover:text-jefesRed": true,
                  })}
                  href={link.href}
                >
                  {link.label}
                </Link>
              ))}
            </ul>
          </div>
        )}
      </div>
    </nav>
  );
};

export default NavBar;
