Moving Refine Form logic from crud lib to implementation
This commit is contained in:
@@ -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)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user