Dynamic Schema names for crud
This commit is contained in:
@@ -37,6 +37,7 @@ export const CrudForm: React.FC<CrudFormProps> = (props) => {
|
||||
onMutationSuccess: (data: any) => { if (onSuccess) { onSuccess(data) } },
|
||||
});
|
||||
|
||||
const schemaValue = id === undefined ? `${schemaName}Create` : `${schemaName}Update`;
|
||||
const record = query?.data?.data;
|
||||
const [formData, setFormData] = useState(record);
|
||||
|
||||
@@ -46,7 +47,7 @@ export const CrudForm: React.FC<CrudFormProps> = (props) => {
|
||||
useEffect(() => {
|
||||
const fetchSchema = async () => {
|
||||
try {
|
||||
const resourceSchema = await jsonschemaProvider.getResourceSchema(schemaName);
|
||||
const resourceSchema = await jsonschemaProvider.getResourceSchema(schemaValue);
|
||||
setSchema(resourceSchema);
|
||||
setLoading(false);
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user