rare-sapphire
rare-sapphire6mo ago

Sub resource in antd tabs

I'm trying to get a component as a "SubResource" of some sort. I implemented a resource for "projects" with a show page, and on that page I put antd tabs. On the first tab there is the show component for products. On the second tab, I'd like a list component for that subresource (project admins) and the url to reflect something along the lines of "projects/:id/projects-admin".
5 Replies
kapa.ai
kapa.ai6mo ago
Hi @Raekh. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the extracts, you can use the resource prop in the Show, Edit, Create, and List components to specify a custom resource. However, the extracts do not provide specific information on how to implement a subresource in antd tabs. Here's a basic example of how you can use the resource prop in the Show and List components:
import { Show, List } from "@refinedev/antd";

const CustomPage: React.FC = () => {
return (
<Show resource="projects">
<p>Rest of your page here</p>
</Show>
<List resource="projects-admin">
<p>Rest of your page here</p>
</List>
);
};
import { Show, List } from "@refinedev/antd";

const CustomPage: React.FC = () => {
return (
<Show resource="projects">
<p>Rest of your page here</p>
</Show>
<List resource="projects-admin">
<p>Rest of your page here</p>
</List>
);
};
In this example, the Show component is used to display the "projects" resource, and the List component is used to display the "projects-admin" resource. However, this does not reflect the URL structure you mentioned. For more complex scenarios like the one you described, you might need to use more advanced features of Refine and Ant Design, which are not covered in the provided extracts. I recommend checking the official documentation for more information: - Refine documentation (https://refine.dev/docs) - Ant Design documentation (https://ant.design/docs/react/introduce) Please note that the information provided is based on the extracts and may not fully answer your question. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai6mo ago
<@111054132537741312> kapa.ai is still learning and improving, please let us know how it did by reacting below
rare-sapphire
rare-sapphire6mo ago
@kapa.ai What is weird is that I declared project-admins as a resource with a specific url for the list component : list: "/projects/show/:id/project-admins" And it still tries to get "/project-admins" instead.
kapa.ai
kapa.ai6mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- Based on the information provided in the extracts, it seems like you're experiencing an issue where the URL for the "project-admins" resource is not being set correctly. In Refine, the list property in the resources array is used to define the route path for the resource. For example:
resources={[
{
name: "projects-admin",
list: "/projects/show/:id/project-admins",
},
]}
resources={[
{
name: "projects-admin",
list: "/projects/show/:id/project-admins",
},
]}
However, it's important to note that the list property is used to define the route path, not the API endpoint. If your application is trying to fetch data from "/project-admins" instead of "/projects/show/:id/project-admins", it might be because the API endpoint is set incorrectly. If you're using a custom dataProvider, you might need to adjust the logic in your dataProvider to correctly handle the "project-admins" resource. Unfortunately, the provided extracts do not contain enough information to provide a more specific solution. I recommend checking the Refine documentation (https://refine.dev/docs) for more information on how to work with resources and dataProviders. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai6mo ago
<@111054132537741312> kapa.ai is still learning and improving, please let us know how it did by reacting below