Feat(medusa, medusa-js, medusa-react): order edit confirmation (#2264)

**what**

Support confirm of an order edit:

Upon confirmation, the items of the original order are detached and the items from the order edit are attached to the order.
The order total is recomputed with the correct total which can defer from the paid_total and refundable_amount (based on the paid_total)


**Tests**

- Unit tests medusa-js and medusa-react as well as the core
- Integration test of the confirmation flow which check that the order edit is properly confirmed and can be confirmed idempotently. Also validate the totals and that the order items correspond to the order edit items. Also validate the order totals.

FIXES CORE-498
This commit is contained in:
Adrien de Peretti
2022-09-29 10:00:48 +02:00
committed by GitHub
parent 87ad29dda4
commit 2be00007b2
22 changed files with 736 additions and 198 deletions
@@ -153,24 +153,36 @@ export const useAdminRequestOrderEditConfirmation = (
)
}
export const useAdminCancelOrderEdit = (
id: string,
options?: UseMutationOptions<
Response<AdminOrderEditsRes>,
Error
>
options?: UseMutationOptions<Response<AdminOrderEditsRes>, Error>
) => {
const { client } = useMedusa()
const queryClient = useQueryClient()
return useMutation(
() =>
client.admin.orderEdits.cancel(id),
() => client.admin.orderEdits.cancel(id),
buildOptions(
queryClient,
[adminOrderEditsKeys.lists(), adminOrderEditsKeys.detail(id)],
options
)
)
}
}
export const useAdminConfirmOrderEdit = (
id: string,
options?: UseMutationOptions<Response<AdminOrderEditsRes>, Error>
) => {
const { client } = useMedusa()
const queryClient = useQueryClient()
return useMutation(
() => client.admin.orderEdits.confirm(id),
buildOptions(
queryClient,
[adminOrderEditsKeys.lists(), adminOrderEditsKeys.detail(id)],
options
)
)
}