import { Link } from "react-router-dom";
import BackButton from "../../Components/BackButton";
import BasicWindow from "../../Components/BasicWindow";
import Button from "../../Components/Button";
import { ProjectListAdmin } from "../../Components/ProjectListAdmin";
import { Project } from "../../Types/goTypes";
import GetProjects from "../../Components/GetProjects";
import { useState } from "react";

function AdminManageProjects(): JSX.Element {
  const [projects, setProjects] = useState<Project[]>([]);
  GetProjects({
    setProjectsProp: setProjects,
    username: localStorage.getItem("username") ?? "",
  });
  const content = <ProjectListAdmin projects={projects} />;

  const buttons = (
    <>
      <Link to="/addProject">
        <Button
          text="Add Project"
          onClick={(): void => {
            return;
          }}
          type="button"
        />
      </Link>
      <BackButton />
    </>
  );

  return <BasicWindow content={content} buttons={buttons} />;
}
export default AdminManageProjects;
