Moving Refine Form logic from crud lib to implementation

This commit is contained in:
2025-05-01 19:41:08 +02:00
parent f4c6cdab3b
commit 178f27cfe2
5 changed files with 69 additions and 35 deletions

View File

@@ -1,6 +1,7 @@
import { CrudForm } from "../../../lib/crud/components/crud-form";
import { UiSchema } from "@rjsf/utils";
import { useContext } from "react";
import { useForm } from "@refinedev/core";
import { CrudForm } from "../../../lib/crud/components/crud-form";
import { FirmContext } from "../../../contexts/FirmContext";
type NewProps = {
@@ -15,6 +16,12 @@ const New = <T,>(props: NewProps) => {
const { currentFirm } = useContext(FirmContext);
const resourceBasePath = `firm/${currentFirm.instance}/${currentFirm.firm}`
const { onFinish } = useForm({
resource: `${resourceBasePath}/${resource}`,
action: "create",
redirect: "show",
});
return (
<CrudForm
schemaName={schemaName}
@@ -22,6 +29,7 @@ const New = <T,>(props: NewProps) => {
resourceBasePath={resourceBasePath}
resource={resource}
defaultValue={defaultValue}
onSubmit={(data: any) => onFinish(data)}
/>
)
}