Sub Resources
How can i create sub resources? I have teams and tasks resources. I want to relate the tasks with teams. How can i do that?
2 Replies
Hi @rasitcolakel. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
In refine, you can create sub-resources or nested resources by defining custom routes for your resources. This can be done by defining actions (
list
, create
, edit
, show
, clone
) as paths rather than components in the resources
prop of the <Refine>
component. This allows you to define custom routes for individual actions and use your router’s full potential without being restricted to the automatically created routes.
For your case, you can define the tasks
resource as a sub-resource of teams
by using a nested route. Here's an example:
In this example, :teamId
is a parameter that you can use to specify the team that the tasks belong to. This way, the tasks are related to the teams.
Remember, this is only a resource definition, which must be handled within your router structure. The detail page of a task can have a nested structure and additional parameters, which can be passed along with the meta
properties in hooks and components. When constructing the navigation path, existing parameters in the URL will also be used.
For more information, you can refer to the refine documentation (https://refine.dev/docs/tutorial/understanding-resources/index) and the refine blog (https://refine.dev/blog/refine-v4-announcement).
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@698992415486246944> kapa.ai is still learning and improving, please let us how it did by reacting below