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:
Adrien de Peretti authored and GitHub committed 2022-09-28 09:09:33 +00:00
1 parent 1807bff029
commit 474e97252c
24 files changed
+1247 -63

No files matched your search

@@ -2,6 +2,7 @@ import {
AdminOrderEditDeleteRes,
AdminOrderEditItemChangeDeleteRes,
AdminOrderEditsRes,
AdminPostOrderEditsEditLineItemsLineItemReq,
AdminPostOrderEditsOrderEditReq,
AdminPostOrderEditsReq,
} from "@medusajs/medusa"
@@ -50,7 +51,7 @@ class AdminOrderEditsResource extends BaseResource {
const path = `/admin/order-edits/${orderEditId}/changes/${itemChangeId}`
return this.client.request("DELETE", path, undefined, {}, customHeaders)
}
requestConfirmation(
id: string,
customHeaders: Record<string, any> = {}
@@ -58,7 +59,7 @@ class AdminOrderEditsResource extends BaseResource {
const path = `/admin/order-edits/${id}/request`
return this.client.request("POST", path, undefined, {}, customHeaders)
}
cancel(
id: string,
customHeaders: Record<string, any> = {}
@@ -66,6 +67,16 @@ class AdminOrderEditsResource extends BaseResource {
const path = `/admin/order-edits/${id}/cancel`
return this.client.request("POST", path, undefined, {}, customHeaders)
}
updateLineItem(
orderEditId: string,
itemId: string,
payload: AdminPostOrderEditsEditLineItemsLineItemReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrderEditsRes> {
const path = `/admin/order-edits/${orderEditId}/items/${itemId}`
return this.client.request("POST", path, payload, {}, customHeaders)
}
}
export default AdminOrderEditsResource