import Link from "next/link";
import { ReactElement } from "react";
import Logo from "./logo";
import { RedirectButton } from "./rediect-button";
import { ToggleThemeButton } from "./theme-toggle-button";

type Page = {
  title: string;
  url: string;
  openInNewTab?: boolean;
};

const pages: Page[] = [
  { title: "Player", url: "/player" },
  { title: "Server", url: "/server/java" },
  { title: "Mojang", url: "/mojang/status" },
  { title: "API", url: "https://api.mcutils.xyz", openInNewTab: true },
];

export default function NavBar(): ReactElement {
  return (
    <div className="bg-secondary w-full rounded-lg flex items-center gap-3 mt-2 bg-opacity-85 h-12">
      <Link href="/" className="flex items-center gap-2 pl-3 pr-1">
        <Logo />
        <p className="hidden md:block">Minecraft Utilities</p>
      </Link>

      <div className="flex-grow"></div>

      {pages.map((page, index) => {
        return <RedirectButton key={index} title={page.title} url={page.url} openInNewTab={page.openInNewTab} />;
      })}

      <div className="flex-grow"></div>

      <div className="mr-4 flex items-center gap-2">
        <div className="hidden md:block">
          <RedirectButton
            title="Star us on Github!"
            url="https://github.com/RealFascinated/minecraft-helper"
            openInNewTab
          />
        </div>
        <ToggleThemeButton />
      </div>
    </div>
  );
}
