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

export const TemplateRoutes = () => {
  return (
    <Routes>
      <Route index element={ <ListTemplate /> } />
      <Route path="/edit/:record_id" element={ <EditTemplate /> } />
      <Route path="/create" element={ <CreateTemplate /> } />
    </Routes>
  );
}

const ListTemplate = () => {
  const columns = [
    { field: "label", column: { flex: 1 }},
  ];
  return <List<Template> resource={`templates/contracts`} schemaName={"ContractTemplate"} columns={columns} />
}

const EditTemplate = () => {
  return <Edit<Template> resource={`templates/contracts`} schemaName={"ContractTemplate"} />
}

const CreateTemplate = () => {
  return <New<Template> resource={`templates/contracts`} schemaName={"ContractTemplate"} />
}
