Implementing all cht classic routes

This commit is contained in:
2025-04-19 01:32:26 +02:00
parent 8766be57d0
commit 2249791267
11 changed files with 221 additions and 26 deletions

View File

@@ -2,16 +2,18 @@ import { CrudForm } from "../../../lib/crud/components/crud-form";
import { UiSchema } from "@rjsf/utils";
import { useParams } from "react-router";
type CardProps = {
type EditProps = {
resource: string,
schemaName: string,
uiSchema?: UiSchema,
}
const Card = (props: CardProps) => {
const Edit = <T,>(props: EditProps) => {
const { schemaName, resource, uiSchema } = props;
const { record_id } = useParams();
console.log(record_id);
return (
<CrudForm
schemaName={schemaName}
@@ -22,4 +24,4 @@ const Card = (props: CardProps) => {
)
}
export default Card;
export default Edit;

View File

@@ -1,7 +1,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 { Button } from "@mui/material";
type ListProps<T extends GridValidRowModel> = {
resource: string,
@@ -13,16 +15,26 @@ 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 navigate = useNavigate();
const cols = React.useMemo<GridColDef<T>[]>(
() => columns,
[],
);
const handleRowClick = (params: any, event: any) => {
navigate(`edit/${params.id}`)
}
return (
<RefineList
canCreate={true}
>
<DataGrid {...dataGridProps} columns={cols} />
<RefineList>
<Link to={"create"} >
<Button>Create</Button>
</Link>
<DataGrid
{...dataGridProps}
columns={cols}
onRowClick={handleRowClick} />
</RefineList>
)
}

View File

@@ -7,7 +7,7 @@ type NewProps = {
uiSchema?: UiSchema,
}
const New = (props: NewProps) => {
const New = <T,>(props: NewProps) => {
const { schemaName, resource, uiSchema } = props;
return (