import { MCGrizzConf } from "../types/mcgrizzconf.ts";
import { NavItem } from "../types/nav.ts";
import { makeConfFile } from "./confFile.ts";

/**
 * @description Determines the state of setup and returns the nav items for that state
 */
export function getNavItems(): NavItem[] {
  let conf: MCGrizzConf;
  try {
    conf = JSON.parse(Deno.readTextFileSync("mcgrizz.json"));
  } catch {
    conf = makeConfFile();
  }

  switch (conf.loader) {
    case "unset":
      return [{
        title: "Setup",
        href: "/",
      }];
    case "forge":
    case "fabric":
    case "vanilla":
      return [
        {
          title: "Server Terminal",
          href: "/terminal",
        },
        {
          title: "Players",
          href: "/players",
        },
        {
          title: "Server Properties",
          href: "/properties",
        },
      ];
  }
}
