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,6 @@
import { useInvalidateAuthStore } from "@refinedev/core";
import { useForm, useInvalidateAuthStore } from "@refinedev/core";
import { CrudForm } from "../../lib/crud/components/crud-form";
import {empty_user} from "../../providers/auth-provider";
import { empty_user } from "../../providers/auth-provider";
export const CreateFirm = () => {
const invalidateAuthStore = useInvalidateAuthStore()
@@ -9,11 +9,19 @@ export const CreateFirm = () => {
invalidateAuthStore().then();
}
const resourceBasePath = "hub/users";
const { onFinish } = useForm({
resource: `${resourceBasePath}/firms`,
action: "create",
redirect: "list",
onMutationSuccess: data => refreshUser()
});
return (
<CrudForm
schemaName={"FirmCreate"}
resource={"hub/users/firms/"}
onSuccess={() => { refreshUser() }}
schemaName={"Firm"}
resourceBasePath={resourceBasePath}
onSubmit={(data: any) => onFinish(data)}
/>
)
}