fix(medusa-react): Use correct type for hook useAdminCreateDraftOrder (#1832)
This commit is contained in:
committed by
GitHub
parent
fb82d3dd22
commit
fb4cfc3c3c
5
.changeset/lovely-ladybugs-own.md
Normal file
5
.changeset/lovely-ladybugs-own.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"medusa-react": patch
|
||||
---
|
||||
|
||||
Fixes useAdminCreateDraftOrder so it uses the correct payload type, and updates relevant test.
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
AdminPostDraftOrdersDraftOrderLineItemsReq,
|
||||
AdminPostDraftOrdersDraftOrderRegisterPaymentRes,
|
||||
AdminPostDraftOrdersDraftOrderReq,
|
||||
AdminPostDraftOrdersReq,
|
||||
} from "@medusajs/medusa"
|
||||
import { Response } from "@medusajs/medusa-js"
|
||||
import { useMutation, UseMutationOptions, useQueryClient } from "react-query"
|
||||
@@ -16,13 +17,13 @@ export const useAdminCreateDraftOrder = (
|
||||
options?: UseMutationOptions<
|
||||
Response<AdminDraftOrdersRes>,
|
||||
Error,
|
||||
AdminPostDraftOrdersDraftOrderReq
|
||||
AdminPostDraftOrdersReq
|
||||
>
|
||||
) => {
|
||||
const { client } = useMedusa()
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation(
|
||||
(payload: AdminPostDraftOrdersDraftOrderReq) =>
|
||||
(payload: AdminPostDraftOrdersReq) =>
|
||||
client.admin.draftOrders.create(payload),
|
||||
buildOptions(queryClient, adminDraftOrderKeys.lists(), options)
|
||||
)
|
||||
|
||||
@@ -1,20 +1,33 @@
|
||||
import { renderHook } from "@testing-library/react-hooks"
|
||||
import { fixtures } from "../../../../mocks/data"
|
||||
import {
|
||||
useAdminCreateDraftOrder,
|
||||
useAdminUpdateDraftOrder,
|
||||
useAdminDeleteDraftOrder,
|
||||
useAdminDraftOrderAddLineItem,
|
||||
useAdminDraftOrderRegisterPayment,
|
||||
useAdminDraftOrderRemoveLineItem,
|
||||
useAdminDraftOrderUpdateLineItem,
|
||||
useAdminUpdateDraftOrder,
|
||||
} from "../../../../src/"
|
||||
import { renderHook } from "@testing-library/react-hooks"
|
||||
import { fixtures } from "../../../../mocks/data"
|
||||
import { createWrapper } from "../../../utils"
|
||||
|
||||
describe("useAdminCreateDraftOrder hook", () => {
|
||||
test("creates a draft order and returns it", async () => {
|
||||
const draftOrder = {
|
||||
email: "lebron@james.com",
|
||||
items: [
|
||||
{
|
||||
variant_id: "variant_01FGKMYKJVY3DYDZWCRB2GZS0G",
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
shipping_methods: [
|
||||
{
|
||||
option_id: "opt_01FGKMYKJWQZCZANRNHR3XVRN3",
|
||||
price: 0,
|
||||
},
|
||||
],
|
||||
region_id: "reg_01FGKMYKKG6ACZANRNHR3XVRN3",
|
||||
}
|
||||
|
||||
const { result, waitFor } = renderHook(() => useAdminCreateDraftOrder(), {
|
||||
|
||||
Reference in New Issue
Block a user