harsh-harlequin
harsh-harlequin7mo ago

Redirect On Click

Hi! I have a delete button for which I want to implement the onSuccess for. How could I redirect the user to the /orders page?
2 Replies
kapa.ai
kapa.ai7mo ago
Hi @avangeous. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To redirect the user to the /orders page after a successful delete operation, you can use the onSuccess prop of the DeleteButton component in conjunction with the useNavigation hook from refine. Here's an example of how you can do this:
import { DeleteButton, useNavigation } from "@refinedev/antd";

const MyDeleteComponent = () => {
const { navigate } = useNavigation();

return (
<DeleteButton
resourceNameOrRouteName="posts"
recordItemId="1"
onSuccess={() => {
navigate("/orders");
}}
/>
);
};
import { DeleteButton, useNavigation } from "@refinedev/antd";

const MyDeleteComponent = () => {
const { navigate } = useNavigation();

return (
<DeleteButton
resourceNameOrRouteName="posts"
recordItemId="1"
onSuccess={() => {
navigate("/orders");
}}
/>
);
};
In this example, the navigate function from the useNavigation hook is used to redirect the user to the /orders page after the delete operation is successful. You can find more information about the DeleteButton component and its onSuccess prop in the refine documentation (https://refine.dev/docs/api-reference/antd/components/buttons/delete-button/). The useNavigation hook is also documented here (https://discord.com/channels/837692625737613362/1120545328664412211). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai7mo ago
<@1122927158348763206> kapa.ai is still learning and improving, please let us know how it did by reacting below