From 253d917fd7c52cee32439db58068140b1fb5c945 Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Fri, 7 Feb 2025 17:04:31 +0100 Subject: [PATCH] fix(frontend): remove extra menu payload fields --- frontend/src/components/Menu/MenuForm.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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 (