yasuro99
Explore posts from serversRRefine
•Created by rare-sapphire on 10/27/2024 in #ask-any-question
`redirect` useForm(@refinedev/antd) with nextjs-router doesn't work
Refine:
Create component
Routing
<Refine
routerProvider={routerProvider}
dataProvider={{
default: dataProvider(PIM_MS),
[PIM_MS]: dataProvider(PIM_MS),
}}
resources={[
{
name: "Category",
list: PRODUCT_CATEGORIES_PATH,
create: PRODUCT_CATEGORIES_PATH + "/create",
edit: PRODUCT_CATEGORIES_PATH + "/edit/:id",
show: PRODUCT_CATEGORIES_PATH + "/show/:id",
meta: {
canDelete: true,
},
},
]}
options={{
syncWithLocation: true,
warnWhenUnsavedChanges: true,
useNewQueryKeys: true,
}}>
</Refine>
<Refine
routerProvider={routerProvider}
dataProvider={{
default: dataProvider(PIM_MS),
[PIM_MS]: dataProvider(PIM_MS),
}}
resources={[
{
name: "Category",
list: PRODUCT_CATEGORIES_PATH,
create: PRODUCT_CATEGORIES_PATH + "/create",
edit: PRODUCT_CATEGORIES_PATH + "/edit/:id",
show: PRODUCT_CATEGORIES_PATH + "/show/:id",
meta: {
canDelete: true,
},
},
]}
options={{
syncWithLocation: true,
warnWhenUnsavedChanges: true,
useNewQueryKeys: true,
}}>
</Refine>
export default function CategoryCreate() {
const {formProps, saveButtonProps, form} = useForm({
resource: PRODUCT_CATEGORIES_RESOURCE,
dataProviderName: PIM_MS,
action: "create",
redirect: "list"
});
return (
<Create saveButtonProps={saveButtonProps}>
<Form {...formProps} layout="vertical">
</Form>
</Create>
);
}
export default function CategoryCreate() {
const {formProps, saveButtonProps, form} = useForm({
resource: PRODUCT_CATEGORIES_RESOURCE,
dataProviderName: PIM_MS,
action: "create",
redirect: "list"
});
return (
<Create saveButtonProps={saveButtonProps}>
<Form {...formProps} layout="vertical">
</Form>
</Create>
);
}
List: src/app/product-categories/page.tsx
Create: src/app/product-categories/create/page.tsx
List: src/app/product-categories/page.tsx
Create: src/app/product-categories/create/page.tsx
5 replies