Compare commits
5 Commits
6c480a4971
...
910106eae1
| Author | SHA1 | Date | |
|---|---|---|---|
| 910106eae1 | |||
| 484246bd5d | |||
| 71b9c42265 | |||
| bf02c4c10d | |||
| 3005c94010 |
355
api/fixtures/entities.js
Normal file
355
api/fixtures/entities.js
Normal file
@@ -0,0 +1,355 @@
|
||||
db.Entity.insertMany([
|
||||
{
|
||||
"_id": ObjectId("640e297191d0c1b8d9caa30c"),
|
||||
"address": "Barbareno Road - Chumash, SA",
|
||||
"created_at": "2023-03-12T18:46:23.366Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "individual",
|
||||
"firstname": "Nathaniel",
|
||||
"middlename": "",
|
||||
"lastname": "Toshi",
|
||||
"surnames": [],
|
||||
"day_of_birth": "1992-08-11T00:00:00.000Z",
|
||||
"place_of_birth": "Port Angeles, WA"
|
||||
},
|
||||
"label": "Nathaniel Toshi",
|
||||
"updated_at": "2023-03-12T19:35:13.750Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("640e5b7391d0c1b8d9caa311"),
|
||||
"address": "",
|
||||
"created_at": "2023-03-12T18:46:23.366Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "individual",
|
||||
"firstname": "Nina",
|
||||
"middlename": "",
|
||||
"lastname": "Domingo",
|
||||
"surnames": [],
|
||||
"day_of_birth": null,
|
||||
"place_of_birth": ""
|
||||
},
|
||||
"label": "Nina Cooper",
|
||||
"updated_at": "2023-03-12T23:08:35.082Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("640e5bb991d0c1b8d9caa312"),
|
||||
"address": "",
|
||||
"created_at": "2023-03-12T18:46:23.366Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "individual",
|
||||
"firstname": "Derek",
|
||||
"middlename": "",
|
||||
"lastname": "Hillman",
|
||||
"surnames": [],
|
||||
"day_of_birth": null,
|
||||
"place_of_birth": ""
|
||||
},
|
||||
"label": "Derek Hillman",
|
||||
"updated_at": "2023-03-12T23:09:45.939Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("64105c7642f24b3cb93244cc"),
|
||||
"address": "",
|
||||
"created_at": "2023-03-13T18:03:45.999Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "individual",
|
||||
"firstname": "Andrew",
|
||||
"middlename": "",
|
||||
"lastname": "Moore",
|
||||
"surnames": [],
|
||||
"day_of_birth": "2002-03-12T00:00:00.000Z",
|
||||
"place_of_birth": ""
|
||||
},
|
||||
"label": "Johnny Blackhand",
|
||||
"updated_at": "2023-03-14T11:37:26.398Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("64105ce142f24b3cb93244ce"),
|
||||
"address": "El Rancho Boulevard - Los Santos, SA",
|
||||
"created_at": "2023-03-13T18:03:45.999Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "corporation",
|
||||
"title": "East Custom",
|
||||
"activity": "réparation de véhicule",
|
||||
"employees": [
|
||||
{
|
||||
"position": "Dirigeant",
|
||||
"entity_id": ObjectId("64105c7642f24b3cb93244cc")
|
||||
}
|
||||
]
|
||||
},
|
||||
"label": "Benny's",
|
||||
"updated_at": "2023-03-14T11:39:13.143Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("6410721842f24b3cb93244da"),
|
||||
"address": "",
|
||||
"created_at": "2023-03-13T18:03:45.999Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "individual",
|
||||
"firstname": "Gary",
|
||||
"middlename": "",
|
||||
"lastname": "Terry",
|
||||
"surnames": [],
|
||||
"day_of_birth": null,
|
||||
"place_of_birth": ""
|
||||
},
|
||||
"label": "Gary Terry",
|
||||
"updated_at": "2023-03-14T13:09:44.325Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("6410724342f24b3cb93244dc"),
|
||||
"address": "",
|
||||
"created_at": "2023-03-13T18:03:45.999Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "individual",
|
||||
"firstname": "Wayne",
|
||||
"middlename": "",
|
||||
"lastname": "Terry",
|
||||
"surnames": [],
|
||||
"day_of_birth": null,
|
||||
"place_of_birth": ""
|
||||
},
|
||||
"label": "Wayne Terry",
|
||||
"updated_at": "2023-03-14T13:10:27.808Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("6410e1b1c64aae93833c8f67"),
|
||||
"address": "South Boulevard Del Perro - Los Santos, SA",
|
||||
"created_at": "2023-03-14T14:07:16.735Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "corporation",
|
||||
"title": "ROCKFORD",
|
||||
"activity": "production et diffusion musicale",
|
||||
"employees": []
|
||||
},
|
||||
"label": "RockFord",
|
||||
"updated_at": "2023-03-14T21:05:53.499Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("6410e21dc64aae93833c8f68"),
|
||||
"address": "Murrieta Street - Los Santos, SA",
|
||||
"created_at": "2023-03-14T14:07:16.735Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "individual",
|
||||
"firstname": "Lay",
|
||||
"middlename": "",
|
||||
"lastname": "Parks",
|
||||
"surnames": [],
|
||||
"day_of_birth": "2003-07-26T00:00:00.000Z",
|
||||
"place_of_birth": "Philadelphie, PN"
|
||||
},
|
||||
"label": "Lay Parks",
|
||||
"updated_at": "2023-03-14T21:07:41.072Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("6410e2aec64aae93833c8f69"),
|
||||
"address": "",
|
||||
"created_at": "2023-03-14T14:07:16.735Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "individual",
|
||||
"firstname": "Franklin",
|
||||
"middlename": "",
|
||||
"lastname": "Woods",
|
||||
"surnames": [],
|
||||
"day_of_birth": null,
|
||||
"place_of_birth": ""
|
||||
},
|
||||
"label": "Franklin Woods",
|
||||
"updated_at": "2023-03-14T21:10:06.643Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("64132ba1dfeec019e7312277"),
|
||||
"address": "",
|
||||
"created_at": "2023-03-16T14:41:43.613Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "individual",
|
||||
"firstname": "Richard",
|
||||
"middlename": "",
|
||||
"lastname": "Malfaisant",
|
||||
"surnames": ["Mauvaisefoi", "Ricard Malaisant", "Faisantmal"],
|
||||
"day_of_birth": null,
|
||||
"place_of_birth": ""
|
||||
},
|
||||
"label": "Richard \"Mauvaisefoi\" Malfaisant",
|
||||
"updated_at": "2023-03-16T14:45:53.483Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("6413493fdfeec019e731227e"),
|
||||
"address": "Eclipse Tower",
|
||||
"created_at": "2023-03-16T14:41:43.613Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "corporation",
|
||||
"title": "LSHD",
|
||||
"activity": "Hopital",
|
||||
"employees": []
|
||||
},
|
||||
"label": "LSHD",
|
||||
"updated_at": "2023-03-16T16:52:15.119Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("64134981dfeec019e731227f"),
|
||||
"address": "Avenue San Andreas",
|
||||
"created_at": "2023-03-16T14:41:43.613Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "corporation",
|
||||
"title": "BurgerShot",
|
||||
"activity": "Restaurant",
|
||||
"employees": []
|
||||
},
|
||||
"label": "BurgerShot",
|
||||
"updated_at": "2023-03-16T16:53:21.827Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("641349bddfeec019e7312280"),
|
||||
"address": "",
|
||||
"created_at": "2023-03-16T14:41:43.613Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "individual",
|
||||
"firstname": "Angelo",
|
||||
"middlename": "",
|
||||
"lastname": "Martinez",
|
||||
"surnames": [],
|
||||
"day_of_birth": null,
|
||||
"place_of_birth": ""
|
||||
},
|
||||
"label": "Angelo Martinez",
|
||||
"updated_at": "2023-03-16T16:54:21.552Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("64134a22dfeec019e7312281"),
|
||||
"address": "",
|
||||
"created_at": "2023-03-16T14:41:43.613Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "individual",
|
||||
"firstname": "Naytia",
|
||||
"middlename": "",
|
||||
"lastname": "Galloway",
|
||||
"surnames": ["Nana"],
|
||||
"day_of_birth": null,
|
||||
"place_of_birth": ""
|
||||
},
|
||||
"label": "Naytia \"Nana\" Galloway",
|
||||
"updated_at": "2023-03-16T16:56:02.133Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("641390fbdfeec019e7312286"),
|
||||
"address": "",
|
||||
"created_at": "2023-03-16T14:41:43.613Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "individual",
|
||||
"firstname": "Ezrah",
|
||||
"middlename": "",
|
||||
"lastname": "KREIGHTON",
|
||||
"surnames": [],
|
||||
"day_of_birth": null,
|
||||
"place_of_birth": ""
|
||||
},
|
||||
"label": "Ezrah KREIGHTON",
|
||||
"updated_at": "2023-03-16T21:58:19.571Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("6414920ddfeec019e7312288"),
|
||||
"address": "",
|
||||
"created_at": "2023-03-16T14:41:43.613Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "individual",
|
||||
"firstname": "Kono",
|
||||
"middlename": "",
|
||||
"lastname": "Taylor",
|
||||
"surnames": [],
|
||||
"day_of_birth": null,
|
||||
"place_of_birth": ""
|
||||
},
|
||||
"label": "Kono Taylor",
|
||||
"updated_at": "2023-03-17T16:15:09.367Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("6414b4e1dfeec019e731228b"),
|
||||
"address": "",
|
||||
"created_at": "2023-03-16T14:41:43.613Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "individual",
|
||||
"firstname": "Travis",
|
||||
"middlename": "",
|
||||
"lastname": "Ndiaye",
|
||||
"surnames": [],
|
||||
"day_of_birth": null,
|
||||
"place_of_birth": ""
|
||||
},
|
||||
"label": "Travis Ndiaye",
|
||||
"updated_at": "2023-03-17T18:43:45.434Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("6414bcd2dfeec019e731228e"),
|
||||
"address": "Grove Street - Los Santos, SA",
|
||||
"created_at": "2023-03-16T14:41:43.613Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "individual",
|
||||
"firstname": "Junior",
|
||||
"middlename": "",
|
||||
"lastname": "Myles",
|
||||
"surnames": ["Juicy"],
|
||||
"day_of_birth": "1998-09-16T00:00:00.000Z",
|
||||
"place_of_birth": "Los Santos, SA"
|
||||
},
|
||||
"label": "Junior \"Juicy\" Miles",
|
||||
"updated_at": "2023-03-17T19:17:38.654Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("64175041e0e97628a53dc362"),
|
||||
"address": "",
|
||||
"created_at": "2023-03-19T13:00:28.665Z",
|
||||
"created_by": ObjectId("67f248427ad1b215ae859319"),
|
||||
"entity_data": {
|
||||
"type": "individual",
|
||||
"firstname": "Cranston",
|
||||
"middlename": "",
|
||||
"lastname": "Bennett",
|
||||
"surnames": [],
|
||||
"day_of_birth": "1999-02-14T00:00:00.000Z",
|
||||
"place_of_birth": ""
|
||||
},
|
||||
"label": "Cranston Bennett",
|
||||
"updated_at": "2023-03-19T18:11:13.712Z",
|
||||
"updated_by": ObjectId("67f248427ad1b215ae859319")
|
||||
}
|
||||
])
|
||||
@@ -28,7 +28,7 @@ class DraftParty(BaseModel):
|
||||
entity_id: PydanticObjectId = Field(
|
||||
foreignKey={
|
||||
"reference": {
|
||||
"resource": "entity",
|
||||
"resource": "entities",
|
||||
"schema": "Entity",
|
||||
}
|
||||
},
|
||||
@@ -39,7 +39,7 @@ class DraftParty(BaseModel):
|
||||
representative_id: PydanticObjectId = Field(
|
||||
foreignKey={
|
||||
"reference": {
|
||||
"resource": "entity",
|
||||
"resource": "entities",
|
||||
"schema": "Entity",
|
||||
}
|
||||
},
|
||||
@@ -77,7 +77,7 @@ class ContractProvisionTemplateReference(BaseModel):
|
||||
provision_template_id: PydanticObjectId = Field(
|
||||
foreignKey={
|
||||
"reference": {
|
||||
"resource": "template/provision",
|
||||
"resource": "templates/provisions",
|
||||
"schema": "ProvisionTemplate",
|
||||
"displayedFields": ['title', 'body']
|
||||
},
|
||||
|
||||
@@ -42,7 +42,7 @@ class Employee(BaseModel):
|
||||
entity_id: PydanticObjectId = Field(
|
||||
foreignKey={
|
||||
"reference": {
|
||||
"resource": "entity",
|
||||
"resource": "entities",
|
||||
"schema": "Entity",
|
||||
"condition": "entity_data.type=individual"
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class PartyTemplate(BaseModel):
|
||||
entity_id: PydanticObjectId = Field(
|
||||
foreignKey={
|
||||
"reference": {
|
||||
"resource": "entity",
|
||||
"resource": "entities",
|
||||
"schema": "Entity",
|
||||
}
|
||||
},
|
||||
@@ -23,7 +23,7 @@ class PartyTemplate(BaseModel):
|
||||
representative_id: PydanticObjectId = Field(
|
||||
foreignKey={
|
||||
"reference": {
|
||||
"resource": "entity",
|
||||
"resource": "entities",
|
||||
"schema": "Entity",
|
||||
}
|
||||
},
|
||||
@@ -65,7 +65,7 @@ class ProvisionTemplateReference(BaseModel):
|
||||
provision_template_id: PydanticObjectId = Field(
|
||||
foreignKey={
|
||||
"reference": {
|
||||
"resource": "template/provision",
|
||||
"resource": "templates/provisions",
|
||||
"schema": "ProvisionTemplate",
|
||||
"displayedFields": ['title', 'body']
|
||||
},
|
||||
|
||||
@@ -7,11 +7,13 @@ import { useForm } from "@refinedev/core";
|
||||
import CrudTextWidget from "./widgets/crud-text-widget";
|
||||
import UnionEnumField from "./fields/union-enum";
|
||||
import { CircularProgress } from "@mui/material";
|
||||
import { ResourceContext } from "../contexts/ResourceContext";
|
||||
|
||||
type CrudFormProps = {
|
||||
schemaName: string,
|
||||
uiSchema?: UiSchema,
|
||||
resource: string,
|
||||
resourceBasePath?: string,
|
||||
id?: string,
|
||||
//onSubmit: (data: IChangeEvent, event: FormEvent<any>) => void
|
||||
onSuccess?: (data: any) => void
|
||||
@@ -26,9 +28,9 @@ const customFields: RegistryFieldsType = {
|
||||
}
|
||||
|
||||
export const CrudForm: React.FC<CrudFormProps> = (props) => {
|
||||
const { schemaName, uiSchema, resource, id, onSuccess } = props;
|
||||
const { schemaName, uiSchema, resourceBasePath="" ,resource, id, onSuccess } = props;
|
||||
const { onFinish, query, formLoading } = useForm({
|
||||
resource: resource,
|
||||
resource: `${resourceBasePath}/${resource}`,
|
||||
action: id === undefined ? "create" : "edit",
|
||||
redirect: "show",
|
||||
id,
|
||||
@@ -61,16 +63,18 @@ export const CrudForm: React.FC<CrudFormProps> = (props) => {
|
||||
}
|
||||
|
||||
return (
|
||||
<Form
|
||||
schema={schema}
|
||||
uiSchema={uiSchema === undefined ? {} : uiSchema}
|
||||
formData={record}
|
||||
onChange={(e) => setFormData(e.formData)}
|
||||
onSubmit={(e) => onFinish(e.formData)}
|
||||
validator={validator}
|
||||
omitExtraData={true}
|
||||
widgets={customWidgets}
|
||||
fields={customFields}
|
||||
/>
|
||||
<ResourceContext.Provider value={{basePath: resourceBasePath}} >
|
||||
<Form
|
||||
schema={schema}
|
||||
uiSchema={uiSchema === undefined ? {} : uiSchema}
|
||||
formData={record}
|
||||
onChange={(e) => setFormData(e.formData)}
|
||||
onSubmit={(e) => onFinish(e.formData)}
|
||||
validator={validator}
|
||||
omitExtraData={true}
|
||||
widgets={customWidgets}
|
||||
fields={customFields}
|
||||
/>
|
||||
</ResourceContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React from "react";
|
||||
import { getDefaultRegistry } from "@rjsf/core";
|
||||
import { FormContextType, getTemplate, RJSFSchema, WidgetProps } from "@rjsf/utils";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
@@ -11,15 +12,14 @@ export default function CrudTextWidget<T = any, S extends CrudTextRJSFSchema = C
|
||||
props: WidgetProps<T, S, F>
|
||||
) {
|
||||
const { schema } = props;
|
||||
if (schema.hasOwnProperty("foreign_key")) {
|
||||
if (schema.hasOwnProperty("foreignKey")) {
|
||||
return <ForeignKeyWidget {...props} />;
|
||||
} else if (schema.hasOwnProperty("const")) {
|
||||
return <Typography >{schema.const as string}</Typography>;
|
||||
} else if (schema.props?.hasOwnProperty("richtext")) {
|
||||
return <RichtextWidget {...props} />;
|
||||
} else {
|
||||
const { options, registry } = props;
|
||||
const BaseInputTemplate = getTemplate<'BaseInputTemplate', T, S, F>('BaseInputTemplate', registry, options);
|
||||
return <BaseInputTemplate {...props} />;
|
||||
const { widgets: { TextWidget } } = getDefaultRegistry<T,S,F>();
|
||||
return <TextWidget {...props} />;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { Route, Routes } from "react-router";
|
||||
import React, { useContext } from "react";
|
||||
import { FirmContext } from "../../contexts/FirmContext";
|
||||
import List from "./base-page/List";
|
||||
import Edit from "./base-page/Edit";
|
||||
import New from "./base-page/New";
|
||||
@@ -21,19 +19,16 @@ export const ContractRoutes = () => {
|
||||
}
|
||||
|
||||
const ListContract = () => {
|
||||
const { currentFirm } = useContext(FirmContext);
|
||||
const columns = [
|
||||
{ field: "label", headerName: "Label", flex: 1 },
|
||||
];
|
||||
return <List<Contract> resource={`firm/${currentFirm.instance}/${currentFirm.firm}/contracts`} columns={columns} />
|
||||
return <List<Contract> resource={`contracts`} columns={columns} />
|
||||
}
|
||||
|
||||
const EditContract = () => {
|
||||
const { currentFirm } = useContext(FirmContext);
|
||||
return <Edit<Contract> resource={`firm/${currentFirm.instance}/${currentFirm.firm}/contracts`} schemaName={"ContractUpdate"} />
|
||||
return <Edit<Contract> resource={`contracts`} schemaName={"ContractUpdate"} />
|
||||
}
|
||||
|
||||
const CreateContract = () => {
|
||||
const { currentFirm } = useContext(FirmContext);
|
||||
return <New<Contract> resource={`firm/${currentFirm.instance}/${currentFirm.firm}/contracts`} schemaName={"ContractCreate"} />
|
||||
return <New<Contract> resource={`contracts`} schemaName={"ContractCreate"} />
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { Route, Routes } from "react-router";
|
||||
import React, { useContext } from "react";
|
||||
import { FirmContext } from "../../contexts/FirmContext";
|
||||
import List from "./base-page/List";
|
||||
import Edit from "./base-page/Edit";
|
||||
import New from "./base-page/New";
|
||||
@@ -21,19 +19,16 @@ export const DraftRoutes = () => {
|
||||
}
|
||||
|
||||
const ListDraft = () => {
|
||||
const { currentFirm } = useContext(FirmContext);
|
||||
const columns = [
|
||||
{ field: "label", headerName: "Label", flex: 1 },
|
||||
];
|
||||
return <List<Draft> resource={`firm/${currentFirm.instance}/${currentFirm.firm}/contracts/drafts`} columns={columns} />
|
||||
return <List<Draft> resource={`contracts/drafts`} columns={columns} />
|
||||
}
|
||||
|
||||
const EditDraft = () => {
|
||||
const { currentFirm } = useContext(FirmContext);
|
||||
return <Edit<Draft> resource={`firm/${currentFirm.instance}/${currentFirm.firm}/contracts/drafts`} schemaName={"ContractDraftUpdate"} />
|
||||
return <Edit<Draft> resource={`contracts/drafts`} schemaName={"ContractDraftUpdate"} />
|
||||
}
|
||||
|
||||
const CreateDraft = () => {
|
||||
const { currentFirm } = useContext(FirmContext);
|
||||
return <New<Draft> resource={`firm/${currentFirm.instance}/${currentFirm.firm}/contracts/drafts`} schemaName={"ContractDraftCreate"} />
|
||||
return <New<Draft> resource={`contracts/drafts`} schemaName={"ContractDraftCreate"} />
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { Route, Routes } from "react-router";
|
||||
import React, { useContext } from "react";
|
||||
import { FirmContext } from "../../contexts/FirmContext";
|
||||
import List from "./base-page/List";
|
||||
import Edit from "./base-page/Edit";
|
||||
import New from "./base-page/New";
|
||||
@@ -23,20 +21,17 @@ export const EntityRoutes = () => {
|
||||
}
|
||||
|
||||
const ListEntity = () => {
|
||||
const { currentFirm } = useContext(FirmContext);
|
||||
const columns = [
|
||||
{ field: "label", headerName: "Label", flex: 1 },
|
||||
{ field: "entity_data", headerName: "Type", flex: 1, valueFormatter: ({ type }: {type: string}) => type }
|
||||
];
|
||||
return <List<Entity> resource={`firm/${currentFirm.instance}/${currentFirm.firm}/entities`} columns={columns} />
|
||||
return <List<Entity> resource={`entities`} columns={columns} />
|
||||
}
|
||||
|
||||
const EditEntity = () => {
|
||||
const { currentFirm } = useContext(FirmContext);
|
||||
return <Edit<Entity> resource={`firm/${currentFirm.instance}/${currentFirm.firm}/entities`} schemaName={"EntityUpdate"} />
|
||||
return <Edit<Entity> resource={`entities`} schemaName={"EntityUpdate"} />
|
||||
}
|
||||
|
||||
const CreateEntity = () => {
|
||||
const { currentFirm } = useContext(FirmContext);
|
||||
return <New<Entity> resource={`firm/${currentFirm.instance}/${currentFirm.firm}/entities`} schemaName={"EntityCreate"} />
|
||||
return <New<Entity> resource={`entities`} schemaName={"EntityCreate"} />
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { Route, Routes } from "react-router";
|
||||
import React, { useContext } from "react";
|
||||
import { FirmContext } from "../../contexts/FirmContext";
|
||||
import List from "./base-page/List";
|
||||
import Edit from "./base-page/Edit";
|
||||
import New from "./base-page/New";
|
||||
@@ -22,19 +20,16 @@ export const ProvisionRoutes = () => {
|
||||
}
|
||||
|
||||
const ListProvision = () => {
|
||||
const { currentFirm } = useContext(FirmContext);
|
||||
const columns = [
|
||||
{ field: "label", headerName: "Label", flex: 1 },
|
||||
];
|
||||
return <List<Provision> resource={`firm/${currentFirm.instance}/${currentFirm.firm}/templates/provisions`} columns={columns} />
|
||||
return <List<Provision> resource={`templates/provisions`} columns={columns} />
|
||||
}
|
||||
|
||||
const EditProvision = () => {
|
||||
const { currentFirm } = useContext(FirmContext);
|
||||
return <Edit<Provision> resource={`firm/${currentFirm.instance}/${currentFirm.firm}/templates/provisions`} schemaName={"ProvisionTemplateUpdate"} />
|
||||
return <Edit<Provision> resource={`templates/provisions`} schemaName={"ProvisionTemplateUpdate"} />
|
||||
}
|
||||
|
||||
const CreateProvision = () => {
|
||||
const { currentFirm } = useContext(FirmContext);
|
||||
return <New<Provision> resource={`firm/${currentFirm.instance}/${currentFirm.firm}/templates/provisions`} schemaName={"ProvisionTemplateCreate"} />
|
||||
return <New<Provision> resource={`templates/provisions`} schemaName={"ProvisionTemplateCreate"} />
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { Route, Routes } from "react-router";
|
||||
import React, { useContext } from "react";
|
||||
import { FirmContext } from "../../contexts/FirmContext";
|
||||
import List from "./base-page/List";
|
||||
import Edit from "./base-page/Edit";
|
||||
import New from "./base-page/New";
|
||||
@@ -21,19 +19,16 @@ export const TemplateRoutes = () => {
|
||||
}
|
||||
|
||||
const ListTemplate = () => {
|
||||
const { currentFirm } = useContext(FirmContext);
|
||||
const columns = [
|
||||
{ field: "label", headerName: "Label", flex: 1 },
|
||||
];
|
||||
return <List<Template> resource={`firm/${currentFirm.instance}/${currentFirm.firm}/templates/contracts`} columns={columns} />
|
||||
return <List<Template> resource={`templates/contracts`} columns={columns} />
|
||||
}
|
||||
|
||||
const EditTemplate = () => {
|
||||
const { currentFirm } = useContext(FirmContext);
|
||||
return <Edit<Template> resource={`firm/${currentFirm.instance}/${currentFirm.firm}/templates/contracts`} schemaName={"ContractTemplateUpdate"} />
|
||||
return <Edit<Template> resource={`templates/contracts`} schemaName={"ContractTemplateUpdate"} />
|
||||
}
|
||||
|
||||
const CreateTemplate = () => {
|
||||
const { currentFirm } = useContext(FirmContext);
|
||||
return <New<Template> resource={`firm/${currentFirm.instance}/${currentFirm.firm}/templates/contracts`} schemaName={"ContractTemplateCreate"} />
|
||||
return <New<Template> resource={`templates/contracts`} schemaName={"ContractTemplateCreate"} />
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { CrudForm } from "../../../lib/crud/components/crud-form";
|
||||
import { UiSchema } from "@rjsf/utils";
|
||||
import { useParams } from "react-router";
|
||||
import { useContext } from "react";
|
||||
import { FirmContext } from "../../../contexts/FirmContext";
|
||||
|
||||
type EditProps = {
|
||||
resource: string,
|
||||
@@ -10,12 +12,15 @@ type EditProps = {
|
||||
|
||||
const Edit = <T,>(props: EditProps) => {
|
||||
const { schemaName, resource, uiSchema } = props;
|
||||
const { currentFirm } = useContext(FirmContext);
|
||||
const resourceBasePath = `firm/${currentFirm.instance}/${currentFirm.firm}`
|
||||
const { record_id } = useParams();
|
||||
|
||||
return (
|
||||
<CrudForm
|
||||
schemaName={schemaName}
|
||||
uiSchema={uiSchema}
|
||||
resourceBasePath={resourceBasePath}
|
||||
resource={resource}
|
||||
id={record_id}
|
||||
/>
|
||||
|
||||
@@ -2,8 +2,9 @@ import { UiSchema } from "@rjsf/utils";
|
||||
import { List as RefineList, useDataGrid } from "@refinedev/mui";
|
||||
import { DataGrid, GridColDef, GridValidRowModel } from "@mui/x-data-grid";
|
||||
import { Link, useNavigate } from "react-router"
|
||||
import React from "react";
|
||||
import React, { useContext } from "react";
|
||||
import { Button } from "@mui/material";
|
||||
import { FirmContext } from "../../../contexts/FirmContext";
|
||||
|
||||
type ListProps<T extends GridValidRowModel> = {
|
||||
resource: string,
|
||||
@@ -13,8 +14,11 @@ type ListProps<T extends GridValidRowModel> = {
|
||||
}
|
||||
|
||||
const List = <T extends GridValidRowModel>(props: ListProps<T>) => {
|
||||
const { schemaName, resource, uiSchema, columns } = props;
|
||||
const { dataGridProps } = useDataGrid<T>({resource: resource});
|
||||
const { resource, columns } = props;
|
||||
const { currentFirm } = useContext(FirmContext);
|
||||
const resourceBasePath = `firm/${currentFirm.instance}/${currentFirm.firm}`
|
||||
|
||||
const { dataGridProps } = useDataGrid<T>({resource: `${resourceBasePath}/${resource}`});
|
||||
const navigate = useNavigate();
|
||||
|
||||
const cols = React.useMemo<GridColDef<T>[]>(
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { CrudForm } from "../../../lib/crud/components/crud-form";
|
||||
import { UiSchema } from "@rjsf/utils";
|
||||
import { useContext } from "react";
|
||||
import { FirmContext } from "../../../contexts/FirmContext";
|
||||
|
||||
type NewProps = {
|
||||
resource: string,
|
||||
@@ -9,11 +11,14 @@ type NewProps = {
|
||||
|
||||
const New = <T,>(props: NewProps) => {
|
||||
const { schemaName, resource, uiSchema } = props;
|
||||
const { currentFirm } = useContext(FirmContext);
|
||||
const resourceBasePath = `firm/${currentFirm.instance}/${currentFirm.firm}`
|
||||
|
||||
return (
|
||||
<CrudForm
|
||||
schemaName={schemaName}
|
||||
uiSchema={uiSchema}
|
||||
resourceBasePath={resourceBasePath}
|
||||
resource={resource}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -61,7 +61,7 @@ export const dataProvider: DataProvider = {
|
||||
if (filters && filters.length > 0) {
|
||||
filters.forEach((filter) => {
|
||||
if ("field" in filter && filter.value && filter.operator === "contains") {
|
||||
params.append(filter.field + "__like", "%" + filter.value + "%");
|
||||
params.append(filter.field + "__ilike", filter.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user