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 Provision = {
  id: string,
  label: string,
}

export const ProvisionRoutes = () => {

  return (
    <Routes>
      <Route index element={ <ListProvision /> } />
      <Route path="/edit/:record_id" element={ <EditProvision /> } />
      <Route path="/create" element={ <CreateProvision /> } />
    </Routes>
  );
}

const ListProvision = () => {
  const columns = [
    { field: "label", column: { flex: 1 }},
  ];
  return <List<Provision> resource={`templates/provisions`} schemaName={"ProvisionTemplate"} columns={columns} />
}

const EditProvision = () => {
  return <Edit<Provision> resource={`templates/provisions`} schemaName={"ProvisionTemplate"} />
}

const CreateProvision = () => {
  return <New<Provision> resource={`templates/provisions`} schemaName={"ProvisionTemplate"} />
}
