mirror of
https://github.com/hexastack/hexabot
synced 2025-02-23 12:59:14 +00:00
fix: minor
This commit is contained in:
parent
044ce6e725
commit
fe13e43b66
@ -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)}>
|
||||||
|
Loading…
Reference in New Issue
Block a user