fix(frontend): remove extra menu payload fields

This commit is contained in:
yassinedorbozgithub 2025-02-07 17:04:31 +01:00
parent 7510e3572a
commit 253d917fd7

View File

@ -73,14 +73,19 @@ export const MenuForm: FC<ComponentFormProps<MenuFormData>> = ({
}, },
payload: {}, payload: {},
}; };
const typeValue = watch("type");
const titleValue = watch("title");
const onSubmitForm = (params: IMenuItemAttributes) => { const onSubmitForm = (params: IMenuItemAttributes) => {
const { url, ...rest } = params;
const payload = typeValue === "web_url" ? { ...rest, url } : rest;
if (data?.row?.id) { if (data?.row?.id) {
updateMenu({ updateMenu({
id: data.row.id, id: data.row.id,
params, params: payload,
}); });
} else { } else {
createMenu({ ...params, parent: data?.parentId }); createMenu({ ...payload, parent: data?.parentId });
} }
}; };
@ -92,9 +97,6 @@ export const MenuForm: FC<ComponentFormProps<MenuFormData>> = ({
} }
}, [reset, data?.row]); }, [reset, data?.row]);
const typeValue = watch("type");
const titleValue = watch("title");
return ( return (
<Wrapper <Wrapper
open={!!WrapperProps?.open} open={!!WrapperProps?.open}