import { useParams } from "react-router-dom";
import { api } from "../../API/API";
import BackButton from "../../Components/BackButton";
import BasicWindow from "../../Components/BasicWindow";
import Button from "../../Components/Button";

async function handleDeleteProject(
  projectName: string,
  token: string,
): Promise<void> {
  await api.removeProject(projectName, token);
}

function AdminProjectPage(): JSX.Element {
  const content = <></>;
  const { projectName } = useParams();
  const token = localStorage.getItem("accessToken");

  const buttons = (
    <>
      <Button
        text="Delete"
        onClick={() => handleDeleteProject(projectName, token)}
        type="button"
      />
      <BackButton />
    </>
  );

  return <BasicWindow content={content} buttons={buttons} />;
}

export default AdminProjectPage;
