flat-fuchsia
flat-fuchsia9mo ago

Resources not marking route as active

@kapa.ai why is it that why I navigate to creator-details list route, the campaigns in my dash menu doesnt show as active route?
<Route
path="/campaigns/details/creator/:id"
element={
<CreatorDetailsPage/>
}
/>
<Route
path="/campaigns/details/creator/:id"
element={
<CreatorDetailsPage/>
}
/>
export const resources: IResourceItem[] = [
{
name: "campaigns",
list: "/campaigns",
create: "/campaigns/create",
edit: "/campaign/sales/edit/:id",
show: "/campaigns/details/:id",
meta: {
label: "Campaigns",
icon: <ProjectOutlined />,
},
},
{
name: "campaign-details",
list: "/campaigns/details/:id",
create: "/campaigns/details/:id/create",
edit: "/campaign/sales/edit/:id",
meta: {
hide: true,
parent: "campaigns",
},
},
{
name: "creator-details",
list: "/campaigns/details/creator/:id",
create: "/campaigns/details/:id/create",
edit: "/campaign/sales/edit/:id",
meta: {
hide: true,
parent: "campaigns",
},
},
]
export const resources: IResourceItem[] = [
{
name: "campaigns",
list: "/campaigns",
create: "/campaigns/create",
edit: "/campaign/sales/edit/:id",
show: "/campaigns/details/:id",
meta: {
label: "Campaigns",
icon: <ProjectOutlined />,
},
},
{
name: "campaign-details",
list: "/campaigns/details/:id",
create: "/campaigns/details/:id/create",
edit: "/campaign/sales/edit/:id",
meta: {
hide: true,
parent: "campaigns",
},
},
{
name: "creator-details",
list: "/campaigns/details/creator/:id",
create: "/campaigns/details/:id/create",
edit: "/campaign/sales/edit/:id",
meta: {
hide: true,
parent: "campaigns",
},
},
]
5 Replies
kapa.ai
kapa.ai9mo ago
Hi @script4559. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The issue you're experiencing might be due to the way Refine handles active routes for resources. In Refine, the active route is determined by the list property of the resource. If the current route matches the list property of a resource, that resource is marked as active in the menu. In your case, the list property of your creator-details resource is set to "/campaigns/details/creator/:id". However, when you navigate to this route, the campaigns resource is not marked as active because its list property is set to "/campaigns", which doesn't match the current route. One way to solve this issue is to set the list property of your campaigns resource to a route that matches all the routes under it. For example, you could set it to "/campaigns/*". This way, any route that starts with "/campaigns" will mark the campaigns resource as active. Here's how you can do this:
export const resources: IResourceItem[] = [
{
name: "campaigns",
list: "/campaigns/*", // Change this line
create: "/campaigns/create",
edit: "/campaign/sales/edit/:id",
show: "/campaigns/details/:id",
meta: {
label: "Campaigns",
icon: <ProjectOutlined />,
},
},
// ... other resources ...
];
export const resources: IResourceItem[] = [
{
name: "campaigns",
list: "/campaigns/*", // Change this line
create: "/campaigns/create",
edit: "/campaign/sales/edit/:id",
show: "/campaigns/details/:id",
meta: {
label: "Campaigns",
icon: <ProjectOutlined />,
},
},
// ... other resources ...
];
Please note that this is a workaround and might not work in all cases. If this doesn't solve your issue, I recommend checking the Refine documentation (https://refine.dev/docs) or asking for help in the Refine Discord community (https://discord.com/channels/837692625737613362/). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai9mo ago
<@584066183989428345> kapa.ai is still learning and improving, please let us know how it did by reacting below
flat-fuchsia
flat-fuchsia9mo ago
@kapa.ai it didnt work
kapa.ai
kapa.ai9mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- I'm sorry to hear that the suggested solution didn't work. Unfortunately, based on the information provided in the extracts, I don't have enough information to provide a more specific solution to your problem. Refine's routing and resource configuration can be complex, and issues like this can be caused by a variety of factors. It might be helpful to double-check your resource configuration and routing setup, and ensure that they're set up correctly according to the Refine documentation (https://refine.dev/docs). If you're still having trouble, I recommend reaching out to the Refine Discord community (https://discord.com/channels/837692625737613362/). The community is very active and you're likely to get help from other Refine users who may have encountered similar issues. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai9mo ago
<@584066183989428345> kapa.ai is still learning and improving, please let us know how it did by reacting below