feat: carry over promotions toggle on exchanges (#14128)
* feat: carry over promotions toggle on exchanges * fix: inital flag value, return the flag on preview * fix: validation of allocation type * fix: revert client changes * fix: invert condition * feat: recompute adjustments when outbound item is updated * fix: condition again * fix: display more accurate inbound/outbound totals for exchanges * fix: make exchanges specs green * feat: more testing cases * wip: pr feedback * fix: use plural for the flag on Admin * fix: schema test, route refactor * feat: tooltip * feat: refactor to use update workflow * feat: display applied promotion per item on order details, show copy sku on hover * feat: refactor edits and exchanges to have common flag toggle flow * fix: delete empty file * fix: exchange_id param query
This commit is contained in:
@@ -10,8 +10,8 @@ import {
|
||||
import { sdk } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory, TQueryKey } from "../../lib/query-key-factory"
|
||||
import { inventoryItemsQueryKeys } from "./inventory"
|
||||
import { reservationItemsQueryKeys } from "./reservations"
|
||||
import { inventoryItemsQueryKeys } from "./inventory"
|
||||
|
||||
const ORDERS_QUERY_KEY = "orders" as const
|
||||
const _orderKeys = queryKeysFactory(ORDERS_QUERY_KEY) as TQueryKey<"orders"> & {
|
||||
@@ -406,3 +406,35 @@ export const useCreateOrderCreditLine = (
|
||||
...options,
|
||||
})
|
||||
}
|
||||
|
||||
export const useUpdateOrderChange = (
|
||||
orderChangeId: string,
|
||||
options?: UseMutationOptions<
|
||||
HttpTypes.AdminOrderChangeResponse,
|
||||
FetchError,
|
||||
{ carry_over_promotions: boolean }
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload: { carry_over_promotions: boolean }) =>
|
||||
sdk.admin.order.updateOrderChange(orderChangeId, payload),
|
||||
onSuccess: (data, variables, context) => {
|
||||
const orderId = data.order_change.order_id
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ordersQueryKeys.details(),
|
||||
})
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ordersQueryKeys.preview(orderId),
|
||||
})
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ordersQueryKeys.changes(orderId),
|
||||
})
|
||||
|
||||
options?.onSuccess?.(data, variables, context)
|
||||
},
|
||||
...options,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user