diff --git a/frontend/src/components/Menu/MenuForm.tsx b/frontend/src/components/Menu/MenuForm.tsx index 71152966..cc8ae113 100644 --- a/frontend/src/components/Menu/MenuForm.tsx +++ b/frontend/src/components/Menu/MenuForm.tsx @@ -73,14 +73,19 @@ export const MenuForm: FC> = ({ }, payload: {}, }; + const typeValue = watch("type"); + const titleValue = watch("title"); const onSubmitForm = (params: IMenuItemAttributes) => { + const { url, ...rest } = params; + const payload = typeValue === "web_url" ? { ...rest, url } : rest; + if (data?.row?.id) { updateMenu({ id: data.row.id, - params, + params: payload, }); } else { - createMenu({ ...params, parent: data?.parentId }); + createMenu({ ...payload, parent: data?.parentId }); } }; @@ -92,9 +97,6 @@ export const MenuForm: FC> = ({ } }, [reset, data?.row]); - const typeValue = watch("type"); - const titleValue = watch("title"); - return (