fix(dashboard): Load product variant edit page and fix product detail query key (#10029)
**What** - Fixes Edit Variant form so it properly loads the product variant - Fixes the query key for product details to prevent the cache from being shared between queries for the same ID but with different params. Resolves CMRC-685 Co-authored-by: Frane Polić <16856471+fPolic@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
81208b6e1d
commit
904f0926f1
@@ -87,16 +87,21 @@ export const useDeleteProductOption = (
|
||||
export const useProductVariant = (
|
||||
productId: string,
|
||||
variantId: string,
|
||||
query?: Record<string, any>,
|
||||
query?: HttpTypes.AdminProductVariantParams,
|
||||
options?: Omit<
|
||||
UseQueryOptions<any, FetchError, any, QueryKey>,
|
||||
UseQueryOptions<
|
||||
HttpTypes.AdminProductVariantResponse,
|
||||
FetchError,
|
||||
HttpTypes.AdminProductVariantResponse,
|
||||
QueryKey
|
||||
>,
|
||||
"queryFn" | "queryKey"
|
||||
>
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryFn: () =>
|
||||
sdk.admin.product.retrieveVariant(productId, variantId, query),
|
||||
queryKey: variantsQueryKeys.detail(variantId),
|
||||
queryKey: variantsQueryKeys.detail(variantId, query),
|
||||
...options,
|
||||
})
|
||||
|
||||
@@ -238,7 +243,7 @@ export const useProduct = (
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryFn: () => sdk.admin.product.retrieve(id, query),
|
||||
queryKey: productsQueryKeys.detail(id),
|
||||
queryKey: productsQueryKeys.detail(id, query),
|
||||
...options,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user