How can i create a custom action for a resource?
I want to create an action similar to "edit" but with a different name, is it possible?
resources prop:customAction is added with a custom route. You can implement the logic for this custom action in your application.Note: you can ask me a follow up question by @ mentioning me again useResource hook is designed to work with the predefined actions like list, create, edit, show, and clone. To use a custom action with useResource, you can try the following workaround:resources prop:useResource hook to get the resource object:resource object:customActionPath in your application logic as needed.useResource hook, refer to the useResource documentation (https://refine.dev/docs/api-reference/core/hooks/resource/useResource).Note: you can ask me a follow up question by @ mentioning me again customActionuseResourceuseResourceuseResourceuseResourceshowclonecustomActionPathresources={[
{
name: "products",
list: "/:tenantId/products",
show: "/:tenantId/products/:id",
edit: "/:tenantId/products/:id/edit",
create: "/:tenantId/products/create",
// Add your custom action route here
customAction: "/:tenantId/products/:id/custom-action",
}
]} resources={[
{
name: "products",
list: "/:tenantId/products",
show: "/:tenantId/products/:id",
edit: "/:tenantId/products/:id/edit",
create: "/:tenantId/products/create",
// Add your custom action route here
customAction: "/:tenantId/products/:id/custom-action",
}
]} const { resource } = useResource("products");const customActionPath = resource.customAction;