feat(core-flows,medusa,utils,types): adds delivered_quantity to order (#9130)
what: - adds delivered_quantity to order https://github.com/user-attachments/assets/709b1727-08ed-4a88-ae29-38f13540e301
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { FetchError } from "@medusajs/js-sdk"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
QueryKey,
|
||||
useMutation,
|
||||
@@ -5,8 +7,6 @@ import {
|
||||
useQuery,
|
||||
UseQueryOptions,
|
||||
} from "@tanstack/react-query"
|
||||
import { FetchError } from "@medusajs/js-sdk"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { sdk } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory, TQueryKey } from "../../lib/query-key-factory"
|
||||
@@ -184,6 +184,33 @@ export const useCreateOrderShipment = (
|
||||
})
|
||||
}
|
||||
|
||||
export const useMarkOrderFulfillmentAsDelivered = (
|
||||
orderId: string,
|
||||
fulfillmentId: string,
|
||||
options?: UseMutationOptions<
|
||||
{ order: HttpTypes.AdminOrder },
|
||||
FetchError,
|
||||
HttpTypes.AdminMarkOrderFulfillmentAsDelivered
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload: HttpTypes.AdminMarkOrderFulfillmentAsDelivered) =>
|
||||
sdk.admin.order.markAsDelivered(orderId, fulfillmentId, payload),
|
||||
onSuccess: (data: any, variables: any, context: any) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ordersQueryKeys.all,
|
||||
})
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ordersQueryKeys.preview(orderId),
|
||||
})
|
||||
|
||||
options?.onSuccess?.(data, variables, context)
|
||||
},
|
||||
...options,
|
||||
})
|
||||
}
|
||||
|
||||
export const useCancelOrder = (
|
||||
orderId: string,
|
||||
options?: UseMutationOptions<any, FetchError, any>
|
||||
|
||||
Reference in New Issue
Block a user