Prefilled drafts

This commit is contained in:
2025-04-26 01:07:39 +02:00
parent 6c3f6c8d03
commit 6c2047033b
4 changed files with 116 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
import { useEffect, useState } from "react";
import { ReactNode, useEffect, useState } from "react";
import { CircularProgress } from "@mui/material";
import { useForm } from "@refinedev/core";
import { UiSchema } from "@rjsf/utils";
@@ -12,11 +12,12 @@ type CrudFormProps = {
resource: string,
id?: string,
onSuccess?: (data: any) => void,
defaultValue?: any
defaultValue?: any,
children?: ReactNode
}
export const CrudForm: React.FC<CrudFormProps> = (props) => {
const { schemaName, uiSchema, resourceBasePath="" ,resource, id, onSuccess, defaultValue } = props;
const { schemaName, uiSchema, resourceBasePath="" ,resource, id, onSuccess, defaultValue, children } = props;
const { onFinish, query, formLoading } = useForm({
resource: resourceBasePath == "" ? resource : `${resourceBasePath}/${resource}`,
@@ -57,6 +58,7 @@ export const CrudForm: React.FC<CrudFormProps> = (props) => {
onSubmit={
(data: any) => onFinish(data)
}
children={children}
/>
)
}