feat(medusa): Implement premises of the creation flow of an order edit (#2187)
**What** - Implements the admin create end point - Service implementation of the create method and the retrieveActive as well as the totals computation - Improve compute line items - client - medusa-js api - medusa-react mutations hooks **Tests** - Unit tests of the create end points - Unit tests of the service create method - Integration tests for admin that also take into account totals computations - client - medusa-js tests - medusa-react hooks tests FIXES CORE-491
This commit is contained in:
@@ -1,11 +1,29 @@
|
||||
import {
|
||||
AdminOrderEditDeleteRes,
|
||||
AdminOrderEditsRes,
|
||||
AdminPostOrderEditsReq,
|
||||
} from "@medusajs/medusa"
|
||||
import { Response } from "@medusajs/medusa-js"
|
||||
import { useMutation, UseMutationOptions, useQueryClient } from "react-query"
|
||||
import { adminOrderEditsKeys } from "."
|
||||
import { useMedusa } from "../../../contexts/medusa"
|
||||
import { buildOptions } from "../../utils/buildOptions"
|
||||
import { useMedusa } from "../../../contexts"
|
||||
|
||||
export const useAdminCreateOrderEdit = (
|
||||
options?: UseMutationOptions<
|
||||
Response<AdminOrderEditsRes>,
|
||||
Error,
|
||||
AdminPostOrderEditsReq
|
||||
>
|
||||
) => {
|
||||
const { client } = useMedusa()
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation(
|
||||
(payload: AdminPostOrderEditsReq) =>
|
||||
client.admin.orderEdits.create(payload),
|
||||
buildOptions(queryClient, adminOrderEditsKeys.lists(), options)
|
||||
)
|
||||
}
|
||||
|
||||
export const useAdminDeleteOrderEdit = (
|
||||
id: string,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AdminOrdersEditsRes } from "@medusajs/medusa"
|
||||
import { AdminOrderEditsRes } from "@medusajs/medusa"
|
||||
import { queryKeysFactory } from "../../utils"
|
||||
import { UseQueryOptionsWrapper } from "../../../types"
|
||||
import { Response } from "@medusajs/medusa-js"
|
||||
@@ -13,7 +13,7 @@ type OrderEditQueryKeys = typeof adminOrderEditsKeys
|
||||
export const useAdminOrderEdit = (
|
||||
id: string,
|
||||
options?: UseQueryOptionsWrapper<
|
||||
Response<AdminOrdersEditsRes>,
|
||||
Response<AdminOrderEditsRes>,
|
||||
Error,
|
||||
ReturnType<OrderEditQueryKeys["detail"]>
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user