import { Route, Routes } from "react-router";
import List from "./base-page/List";
import Edit from "./base-page/Edit";
import New from "./base-page/New";

type Contract = {
  id: string,
  label: string
}

export const ContractRoutes = () => {
  return (
    <Routes>
      <Route index element={ <ListContract /> } />
      <Route path="/edit/:record_id" element={ <EditContract /> } />
      <Route path="/create" element={ <CreateContract /> } />
    </Routes>
  );
}

const ListContract = () => {
  const columns = [
    { field: "label", headerName: "Label", flex: 1 },
  ];
  return <List<Contract> resource={`contracts`} columns={columns} />
}

const EditContract = () => {
  return <Edit<Contract> resource={`contracts`} schemaName={"Contract"} />
}

const CreateContract = () => {
  return <New<Contract> resource={`contracts`} schemaName={"Contract"} />
}
