From df8f4169e56ea38ea186ebecce3aaf0dbb6f14cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frane=20Poli=C4=87?= <16856471+fPolic@users.noreply.github.com> Date: Fri, 17 May 2024 10:18:36 +0200 Subject: [PATCH] fix(dashboard): variants list query key (#7354) --- packages/admin-next/dashboard/src/hooks/api/products.tsx | 2 +- .../create-product-option-form.tsx | 4 ++-- .../product-variant-section/product-variant-section.tsx | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/admin-next/dashboard/src/hooks/api/products.tsx b/packages/admin-next/dashboard/src/hooks/api/products.tsx index 6a648e2ec7..eab730d100 100644 --- a/packages/admin-next/dashboard/src/hooks/api/products.tsx +++ b/packages/admin-next/dashboard/src/hooks/api/products.tsx @@ -110,7 +110,7 @@ export const useProductVariants = ( ) => { const { data, ...rest } = useQuery({ queryFn: () => client.products.listVariants(productId, query), - queryKey: variantsQueryKeys.list(query), + queryKey: variantsQueryKeys.list({ productId, ...query }), ...options, }) diff --git a/packages/admin-next/dashboard/src/v2-routes/products/product-create-option/components/create-product-option-form/create-product-option-form.tsx b/packages/admin-next/dashboard/src/v2-routes/products/product-create-option/components/create-product-option-form/create-product-option-form.tsx index 837ed1e1e7..b645a7f171 100644 --- a/packages/admin-next/dashboard/src/v2-routes/products/product-create-option/components/create-product-option-form/create-product-option-form.tsx +++ b/packages/admin-next/dashboard/src/v2-routes/products/product-create-option/components/create-product-option-form/create-product-option-form.tsx @@ -40,10 +40,10 @@ export const CreateProductOptionForm = ({ const handleSubmit = form.handleSubmit(async (values) => { mutateAsync(values, { - onSuccess: ({ option }) => { + onSuccess: () => { toast.success(t("general.success"), { description: t("products.options.create.successToast", { - title: option.title, + title: values.title, }), dismissLabel: t("general.close"), }) diff --git a/packages/admin-next/dashboard/src/v2-routes/products/product-detail/components/product-variant-section/product-variant-section.tsx b/packages/admin-next/dashboard/src/v2-routes/products/product-detail/components/product-variant-section/product-variant-section.tsx index 331e461491..b27cf5e0e0 100644 --- a/packages/admin-next/dashboard/src/v2-routes/products/product-detail/components/product-variant-section/product-variant-section.tsx +++ b/packages/admin-next/dashboard/src/v2-routes/products/product-detail/components/product-variant-section/product-variant-section.tsx @@ -1,7 +1,8 @@ import { PencilSquare, Plus } from "@medusajs/icons" -import { Product } from "@medusajs/medusa" import { Container, Heading } from "@medusajs/ui" import { useTranslation } from "react-i18next" +import { ProductDTO } from "@medusajs/types" +import { keepPreviousData } from "@tanstack/react-query" import { ActionMenu } from "../../../../../components/common/action-menu" import { DataTable } from "../../../../../components/table/data-table" @@ -12,7 +13,7 @@ import { useProductVariantTableQuery } from "./use-variant-table-query" import { useProductVariants } from "../../../../../hooks/api/products" type ProductVariantSectionProps = { - product: Product + product: ProductDTO } const PAGE_SIZE = 10 @@ -31,7 +32,7 @@ export const ProductVariantSection = ({ ...searchParams, }, { - keepPreviousData: true, + placeholderData: keepPreviousData, } )