fix(dashboard): display location details address (#7491)
**What** - display the address of the location on the details page - use address formatting utils - fix caching keys for shipping options --- CLOSES CORE-2127
This commit is contained in:
@@ -17,6 +17,12 @@ import {
|
||||
ShippingOptionRes,
|
||||
} from "../../types/api-responses"
|
||||
import { stockLocationsQueryKeys } from "./stock-locations"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
|
||||
const SHIPPING_OPTIONS_QUERY_KEY = "shipping_options" as const
|
||||
export const shippingOptionsQueryKeys = queryKeysFactory(
|
||||
SHIPPING_OPTIONS_QUERY_KEY
|
||||
)
|
||||
|
||||
export const useShippingOptions = (
|
||||
query?: Record<string, any>,
|
||||
@@ -27,7 +33,7 @@ export const useShippingOptions = (
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryFn: () => client.shippingOptions.list(query),
|
||||
queryKey: stockLocationsQueryKeys.all,
|
||||
queryKey: shippingOptionsQueryKeys.list(query),
|
||||
...options,
|
||||
})
|
||||
|
||||
@@ -47,6 +53,9 @@ export const useCreateShippingOptions = (
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: stockLocationsQueryKeys.all,
|
||||
})
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: shippingOptionsQueryKeys.all,
|
||||
})
|
||||
options?.onSuccess?.(data, variables, context)
|
||||
},
|
||||
...options,
|
||||
@@ -67,6 +76,9 @@ export const useUpdateShippingOptions = (
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: stockLocationsQueryKeys.all,
|
||||
})
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: shippingOptionsQueryKeys.all,
|
||||
})
|
||||
options?.onSuccess?.(data, variables, context)
|
||||
},
|
||||
...options,
|
||||
@@ -83,6 +95,9 @@ export const useDeleteShippingOption = (
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: stockLocationsQueryKeys.all,
|
||||
})
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: shippingOptionsQueryKeys.all,
|
||||
})
|
||||
|
||||
options?.onSuccess?.(data, variables, context)
|
||||
},
|
||||
|
||||
@@ -40,7 +40,7 @@ export const useStockLocation = (
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryFn: () => client.stockLocations.retrieve(id, query),
|
||||
queryKey: stockLocationsQueryKeys.details(),
|
||||
queryKey: stockLocationsQueryKeys.detail(id, query),
|
||||
...options,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user