fix: minor

This commit is contained in:
hexastack 2025-02-04 18:46:16 +01:00
parent 044ce6e725
commit fe13e43b66

View File

@ -56,21 +56,6 @@ export const ContentTypeDialog: FC<ContentTypeDialogProps> = ({
closeDialog(); closeDialog();
reset(); reset();
}; };
useEffect(() => {
if (open) reset();
}, [open, reset]);
useEffect(() => {
if (data) {
reset({
name: data.name,
});
} else {
reset();
}
}, [data, reset]);
const { mutate: createContentType } = useCreate(EntityType.CONTENT_TYPE, { const { mutate: createContentType } = useCreate(EntityType.CONTENT_TYPE, {
onError: (error) => { onError: (error) => {
toast.error(error); toast.error(error);
@ -96,10 +81,24 @@ export const ContentTypeDialog: FC<ContentTypeDialogProps> = ({
if (data) { if (data) {
updateContentType({ id: data.id, params }); updateContentType({ id: data.id, params });
} else { } else {
createContentType({ ...params, name: params.name || "" }); createContentType(params);
} }
}; };
useEffect(() => {
if (open) reset();
}, [open, reset]);
useEffect(() => {
if (data) {
reset({
name: data.name,
});
} else {
reset();
}
}, [data, reset]);
return ( return (
<Dialog open={open} fullWidth onClose={CloseAndReset}> <Dialog open={open} fullWidth onClose={CloseAndReset}>
<form onSubmit={handleSubmit(onSubmitForm)}> <form onSubmit={handleSubmit(onSubmitForm)}>