sunny-green
sunny-green2y ago

Incorrect redirect behavior?

Refine app utilizing Mantine. I have resources within App.tsx defined as,
{
name: 'directory',
options: {
label: "DIRECTORY"
},
icon: <></>
},
{
parentName: "directory",
name: "users",
options: {
label: 'USERS'
},
list: UserList,
edit: UserEdit,
create: UserCreate
},
...
{
name: 'directory',
options: {
label: "DIRECTORY"
},
icon: <></>
},
{
parentName: "directory",
name: "users",
options: {
label: 'USERS'
},
list: UserList,
edit: UserEdit,
create: UserCreate
},
...
have an edit view that uses the 'useForm' hook and manually specifying the resource,
const {
saveButtonProps,
refineCore: { queryResult, onFinish, formLoading, redirect },
getInputProps,
values,
} = useForm< HttpError>({
refineCoreProps: {
resource: 'user',
id,
metaData: {
fields
},
},
initialValues: filteredInitialValues,
});
const {
saveButtonProps,
refineCore: { queryResult, onFinish, formLoading, redirect },
getInputProps,
values,
} = useForm< HttpError>({
refineCoreProps: {
resource: 'user',
id,
metaData: {
fields
},
},
initialValues: filteredInitialValues,
});
Navigate to list view at 'directory/user', click edit or create button to navigate to another view, submit the form for that view, but the navigation goes back to 'user' instead of 'directory/user'. How would I specify the 'directory/user' resource to navigate to after a successful mutation?
2 Replies
conscious-sapphire
conscious-sapphire2y ago
Hey @UsererOfName when you set a custom resource, that resource is also used to determine the redirection path. You can set redirect: false in your useForm hook and in onMutationSuccess callback property, you can handle the redirect manually using useNavigation hook, check out the docs for it here https://refine.dev/docs/api-reference/core/hooks/navigation/useNavigation/
useNavigation | refine
refine uses routerProvider and comes with all redirects out of the box. It allows you to manage your routing operations in refine. Using this hook, you can manage all the routing operations of your application very easily.
sunny-green
sunny-green2y ago
Was able to proceed thanks to your help... FWIW, the list button on the standard show/edit views works as expected w/o modification