Disable notifications in useCreateMany and useCreate
Is it possible to turn off notification and setup custom notifications for useCreateMany and useCreate
const { mutate: createMenuItem } = useCreate();
const { mutate: createManyAllergens } = useCreateMany();
const onSubmit = async (formData) => {
createMenuItem(
{
resource: "menuitems",
values: {
name: formData.name,
description: formData.description,
price: formData.price,
category_id: formData.category_id,
},
meta: {
select: "*",
},
},
{
onSuccess: (data) => {
const menuItemId = data.data.id;
// Prepare the allergen associations for bulk creation
const allergenAssociations = (formData.allergens || []).map(
(allergenId: number) => ({
menu_item_id: menuItemId,
allergen_id: allergenId,
})
);
if (allergenAssociations.length > 0) {
createManyAllergens(
{
resource: "menuitemallergens",
values: allergenAssociations,
},
{
onSuccess: () => {
console.log("Allergen associations created successfully.");
},
onError: (error) => {
console.error("Error creating allergen associations:", error);
},
}
);
} else {
console.log("No allergens to associate with the menu item.");
}
},
}
);
};
const { mutate: createMenuItem } = useCreate();
const { mutate: createManyAllergens } = useCreateMany();
const onSubmit = async (formData) => {
createMenuItem(
{
resource: "menuitems",
values: {
name: formData.name,
description: formData.description,
price: formData.price,
category_id: formData.category_id,
},
meta: {
select: "*",
},
},
{
onSuccess: (data) => {
const menuItemId = data.data.id;
// Prepare the allergen associations for bulk creation
const allergenAssociations = (formData.allergens || []).map(
(allergenId: number) => ({
menu_item_id: menuItemId,
allergen_id: allergenId,
})
);
if (allergenAssociations.length > 0) {
createManyAllergens(
{
resource: "menuitemallergens",
values: allergenAssociations,
},
{
onSuccess: () => {
console.log("Allergen associations created successfully.");
},
onError: (error) => {
console.error("Error creating allergen associations:", error);
},
}
);
} else {
console.log("No allergens to associate with the menu item.");
}
},
}
);
};
