feat(dashboard, core-flows, js-sdk, types, medusa): listing order's shipping options (#13242)
* feat(dashboard, core-flows,js-sdk,types,medusa): listing order's shipping option * fix: typo * chore: migrate claim form * fix: cleanup rule logic * feat: add test case, rm params * fix: expand location name
This commit is contained in:
@@ -18,6 +18,7 @@ const _orderKeys = queryKeysFactory(ORDERS_QUERY_KEY) as TQueryKey<"orders"> & {
|
||||
preview: (orderId: string) => any
|
||||
changes: (orderId: string) => any
|
||||
lineItems: (orderId: string) => any
|
||||
shippingOptions: (orderId: string) => any
|
||||
}
|
||||
|
||||
_orderKeys.preview = function (id: string) {
|
||||
@@ -32,6 +33,10 @@ _orderKeys.lineItems = function (id: string) {
|
||||
return [this.detail(id), "lineItems"]
|
||||
}
|
||||
|
||||
_orderKeys.shippingOptions = function (id: string) {
|
||||
return [this.detail(id), "shippingOptions"]
|
||||
}
|
||||
|
||||
export const ordersQueryKeys = _orderKeys
|
||||
|
||||
export const useOrder = (
|
||||
@@ -125,6 +130,28 @@ export const useOrders = (
|
||||
return { ...data, ...rest }
|
||||
}
|
||||
|
||||
export const useOrderShippingOptions = (
|
||||
id: string,
|
||||
query?: HttpTypes.AdminGetOrderShippingOptionList,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
{ shipping_options: HttpTypes.AdminShippingOption[] },
|
||||
FetchError,
|
||||
{ shipping_options: HttpTypes.AdminShippingOption[] },
|
||||
QueryKey
|
||||
>,
|
||||
"queryFn" | "queryKey"
|
||||
>
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryFn: async () => sdk.admin.order.listShippingOptions(id, query),
|
||||
queryKey: ordersQueryKeys.shippingOptions(id),
|
||||
...options,
|
||||
})
|
||||
|
||||
return { ...data, ...rest }
|
||||
}
|
||||
|
||||
export const useOrderChanges = (
|
||||
id: string,
|
||||
query?: HttpTypes.AdminOrderChangesFilters,
|
||||
|
||||
Reference in New Issue
Block a user