fix(dashboard, js-sdk): undefined RMA activity items (#9649)
**What** - fix for showing removed items in rma flows --- DEPENDS ON https://github.com/medusajs/medusa/pull/9646 FIXES CC-597
This commit is contained in:
@@ -56,6 +56,10 @@ export const useRequestOrderEdit = (
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ordersQueryKeys.changes(id),
|
||||
})
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ordersQueryKeys.lineItems(id),
|
||||
})
|
||||
options?.onSuccess?.(data, variables, context)
|
||||
},
|
||||
...options,
|
||||
@@ -85,6 +89,10 @@ export const useConfirmOrderEdit = (
|
||||
queryKey: ordersQueryKeys.changes(id),
|
||||
})
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ordersQueryKeys.lineItems(id),
|
||||
})
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: reservationItemsQueryKeys.lists(),
|
||||
})
|
||||
@@ -121,6 +129,10 @@ export const useCancelOrderEdit = (
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ordersQueryKeys.changes(orderId),
|
||||
})
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ordersQueryKeys.lineItems(id),
|
||||
})
|
||||
options?.onSuccess?.(data, variables, context)
|
||||
},
|
||||
...options,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { FetchError } from "@medusajs/js-sdk"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { AdminOrderItemsFilters, HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
QueryKey,
|
||||
useMutation,
|
||||
@@ -12,13 +12,10 @@ import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory, TQueryKey } from "../../lib/query-key-factory"
|
||||
|
||||
const ORDERS_QUERY_KEY = "orders" as const
|
||||
const _orderKeys = queryKeysFactory(ORDERS_QUERY_KEY) as TQueryKey<
|
||||
"orders",
|
||||
any,
|
||||
string
|
||||
> & {
|
||||
const _orderKeys = queryKeysFactory(ORDERS_QUERY_KEY) as TQueryKey<"orders"> & {
|
||||
preview: (orderId: string) => any
|
||||
changes: (orderId: string) => any
|
||||
lineItems: (orderId: string) => any
|
||||
}
|
||||
|
||||
_orderKeys.preview = function (id: string) {
|
||||
@@ -29,6 +26,10 @@ _orderKeys.changes = function (id: string) {
|
||||
return [this.detail(id), "changes"]
|
||||
}
|
||||
|
||||
_orderKeys.lineItems = function (id: string) {
|
||||
return [this.detail(id), "lineItems"]
|
||||
}
|
||||
|
||||
export const ordersQueryKeys = _orderKeys
|
||||
|
||||
export const useOrder = (
|
||||
@@ -97,7 +98,7 @@ export const useOrderChanges = (
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
HttpTypes.AdminOrderChangesResponse,
|
||||
Error,
|
||||
FetchError,
|
||||
HttpTypes.AdminOrderChangesResponse,
|
||||
QueryKey
|
||||
>,
|
||||
@@ -113,6 +114,28 @@ export const useOrderChanges = (
|
||||
return { ...data, ...rest }
|
||||
}
|
||||
|
||||
export const useOrderLineItems = (
|
||||
id: string,
|
||||
query?: HttpTypes.AdminOrderItemsFilters,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
HttpTypes.AdminOrderLineItemsListResponse,
|
||||
FetchError,
|
||||
HttpTypes.AdminOrderLineItemsListResponse,
|
||||
QueryKey
|
||||
>,
|
||||
"queryFn" | "queryKey"
|
||||
>
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryFn: async () => sdk.admin.order.listLineItems(id, query),
|
||||
queryKey: ordersQueryKeys.lineItems(id),
|
||||
...options,
|
||||
})
|
||||
|
||||
return { ...data, ...rest }
|
||||
}
|
||||
|
||||
export const useCreateOrderFulfillment = (
|
||||
orderId: string,
|
||||
options?: UseMutationOptions<
|
||||
|
||||
Reference in New Issue
Block a user