systematic-tanS
Refine2y ago
8 replies
systematic-tan

How does one supported nested resource

Considering the following resources
const resources = [
    {
      name: "customers",
      list: "/customers",
      create: "/customers/create",
      edit: "/customers/:id/edit",
      show: "/customers/:id/show",
      meta: {
        canDelete: true,
      },
    },
    {
      name: "customer-products",
      list: "/customers/:customer_id/products",
      create: "/customers/:customer_id/products/create",
      edit: "/customers/:customer_id/products/:id/edit",
      show: "/customers/:customer_id/products/:id/show",
      meta: {
        canDelete: true,
      },
      options: {
        hide: true,
      },
    },
];


How can this be achieved ? If I change from :customer_id to :id for list and create of customer-products then all is fine with the list and create functionality, but I can't use it for edit and show buttons. As it will be the same as the product_id, not the desired customer_id

How do you deal with this problem ?
Was this page helpful?