Feat(medusa, medusa-js, medusa-react): order edit item update (#2246)
**what** Support `updateLineItem` which does the following: - If no item change exist then create a new one and attaches the clone item with the adjustments and tax lines - if an item change exists then delete/create adjustments and tax lines and update the cloned item quantity **Tests** - Unit tests core + client - integration tests - When no item change already exists - When an item change already exists FIXES CORE-497
This commit is contained in:
committed by
GitHub
parent
1807bff029
commit
474e97252c
@@ -5,6 +5,7 @@ import {
|
||||
AdminOrderEditDeleteRes,
|
||||
AdminOrderEditItemChangeDeleteRes,
|
||||
AdminOrderEditsRes,
|
||||
AdminPostOrderEditsEditLineItemsLineItemReq,
|
||||
AdminPostOrderEditsOrderEditReq,
|
||||
AdminPostOrderEditsReq,
|
||||
} from "@medusajs/medusa"
|
||||
@@ -68,6 +69,29 @@ export const useAdminDeleteOrderEditItemChange = (
|
||||
)
|
||||
}
|
||||
|
||||
export const useAdminOrderEditUpdateLineItem = (
|
||||
orderEditId: string,
|
||||
itemId: string,
|
||||
options?: UseMutationOptions<
|
||||
Response<AdminOrderEditsRes>,
|
||||
Error,
|
||||
AdminPostOrderEditsEditLineItemsLineItemReq
|
||||
>
|
||||
) => {
|
||||
const { client } = useMedusa()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation(
|
||||
(payload: AdminPostOrderEditsEditLineItemsLineItemReq) =>
|
||||
client.admin.orderEdits.updateLineItem(orderEditId, itemId, payload),
|
||||
buildOptions(
|
||||
queryClient,
|
||||
[adminOrderEditsKeys.detail(orderEditId), adminOrderEditsKeys.lists()],
|
||||
options
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
export const useAdminUpdateOrderEdit = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<
|
||||
|
||||
Reference in New Issue
Block a user