Skip to content

Question about structuring data providers and resources #6421

Answered by alicanerdurmaz
jcelmeta14 asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @jcelmeta14,

You can use useCreate like this to achieve your case:

// ... Resource definition
resources={[
  {
    name: "case",
    create: "/opportunity/:id/case",
    meta: {
        dataProviderName: "CaseDataProvider",
    }
  },
]}


// ... Route definition

<Route path="/opportunity/:id/case" element={<CreateCase />} />

/// ... Component code

import { useCreate, useParsed } from "@refinedev/core";

export const CreateCase = () => {
  const { id } = useParsed();

  const { mutate } = useCreate({
    resource: `opportunity/${id}/case`,
  });

  return (
    <div>
      <h1>Create case for opportunity</h1>
      <button
        onClick={() => {
          mutate({
            v…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by BatuhanW
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants