How to correctly display nested resource name in create hook notification ?

I am getting a notification like "Successfully created orderes/1/items" when using the useCreateMany hook with nested resource orders/1/items, any ideas on how to fix this.
2 Replies
kapa.ai
kapa.ai2y ago
Hi @stevenhg. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The useCreateMany hook in Refine provides a successNotification prop that allows you to customize the success notification that shows up when the data is fetched successfully. By default, the success message is "Successfully created resources". In your case, the resource is orders/1/items, hence the message "Successfully created orders/1/items". To customize this message, you can pass a function to the successNotification prop. This function receives the data, values, and resource as arguments and should return an object with message, description, and type properties. Here's an example of how you can customize the success notification:
const { mutate } = useCreateMany();

mutate({
successNotification: (data, values, resource) => {
return {
message: `${data.title} Successfully created.`,
description: "Success with no errors",
type: "success",
};
},
});
const { mutate } = useCreateMany();

mutate({
successNotification: (data, values, resource) => {
return {
message: `${data.title} Successfully created.`,
description: "Success with no errors",
type: "success",
};
},
});
In the message property, you can format the string as you wish, using the data, values, and resource arguments as needed. For more information, you can refer to the useCreateMany documentation (https://refine.dev/docs/api-reference/core/hooks/data/useCreateMany). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2y ago
<@360760354671689728> kapa.ai is still learning and improving, please let us how it did by reacting below

Did you find this page helpful?