feat(dashboard): create shipment flow (#7898)
**What** - add "Mark shipped" to Fulfillment section --- CLOSES CORE-2427
This commit is contained in:
@@ -2,9 +2,10 @@ import { useMutation, UseMutationOptions } from "@tanstack/react-query"
|
||||
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
|
||||
import { client } from "../../lib/client"
|
||||
import { client, sdk } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { ordersQueryKeys } from "./orders"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
const FULFILLMENTS_QUERY_KEY = "fulfillments" as const
|
||||
export const fulfillmentsQueryKeys = queryKeysFactory(FULFILLMENTS_QUERY_KEY)
|
||||
@@ -41,3 +42,24 @@ export const useCancelFulfillment = (
|
||||
...options,
|
||||
})
|
||||
}
|
||||
|
||||
export const useCreateShipment = (
|
||||
fulfillmentId: string,
|
||||
options?: UseMutationOptions<
|
||||
{ order: HttpTypes.AdminOrder },
|
||||
Error,
|
||||
HttpTypes.AdminCreateFulfillmentShipment
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload: HttpTypes.AdminCreateFulfillmentShipment) =>
|
||||
sdk.admin.fulfillment.createShipment(fulfillmentId, payload),
|
||||
onSuccess: (data: any, variables: any, context: any) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ordersQueryKeys.details(),
|
||||
})
|
||||
options?.onSuccess?.(data, variables, context)
|
||||
},
|
||||
...options,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user