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: {},
};
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<ComponentFormProps<MenuFormData>> = ({
}
}, [reset, data?.row]);
const typeValue = watch("type");
const titleValue = watch("title");
return (
<Wrapper
open={!!WrapperProps?.open}