diff --git a/.changeset/sixty-kangaroos-accept.md b/.changeset/sixty-kangaroos-accept.md new file mode 100644 index 0000000000..0a47e3f000 --- /dev/null +++ b/.changeset/sixty-kangaroos-accept.md @@ -0,0 +1,5 @@ +--- +"@medusajs/dashboard": patch +--- + +fix(dashboard): Prevent overfetching data diff --git a/packages/admin/dashboard/src/hooks/table/query/use-product-table-query.tsx b/packages/admin/dashboard/src/hooks/table/query/use-product-table-query.tsx index b747efc0c6..77cd3cf5cf 100644 --- a/packages/admin/dashboard/src/hooks/table/query/use-product-table-query.tsx +++ b/packages/admin/dashboard/src/hooks/table/query/use-product-table-query.tsx @@ -6,6 +6,9 @@ type UseProductTableQueryProps = { pageSize?: number } +const DEFAULT_FIELDS = + "id,title,handle,status,*collection,*sales_channels,variants.id" + export const useProductTableQuery = ({ prefix, pageSize = 20, @@ -58,6 +61,7 @@ export const useProductTableQuery = ({ type_id: type_id?.split(","), status: status?.split(",") as HttpTypes.AdminProductStatus[], q, + fields: DEFAULT_FIELDS, } return { diff --git a/packages/admin/dashboard/src/routes/products/product-detail/components/product-variant-section/product-variant-section.tsx b/packages/admin/dashboard/src/routes/products/product-detail/components/product-variant-section/product-variant-section.tsx index fad49a3bf0..d8d56409eb 100644 --- a/packages/admin/dashboard/src/routes/products/product-detail/components/product-variant-section/product-variant-section.tsx +++ b/packages/admin/dashboard/src/routes/products/product-detail/components/product-variant-section/product-variant-section.tsx @@ -75,7 +75,8 @@ export const ProductVariantSection = ({ : undefined, created_at: created_at ? JSON.parse(created_at) : undefined, updated_at: updated_at ? JSON.parse(updated_at) : undefined, - fields: "*inventory_items.inventory.location_levels,+inventory_quantity", + fields: + "title,sku,*options,created_at,updated_at,*inventory_items.inventory.location_levels,inventory_quantity", }, { placeholderData: keepPreviousData, diff --git a/packages/admin/dashboard/src/routes/products/product-prices/product-prices.tsx b/packages/admin/dashboard/src/routes/products/product-prices/product-prices.tsx index 85efaac295..90ea3d888d 100644 --- a/packages/admin/dashboard/src/routes/products/product-prices/product-prices.tsx +++ b/packages/admin/dashboard/src/routes/products/product-prices/product-prices.tsx @@ -7,9 +7,7 @@ import { PricingEdit } from "./pricing-edit" export const ProductPrices = () => { const { id, variant_id } = useParams() - const { product, isLoading, isError, error } = useProduct(id!, { - fields: "+variants,+variants.prices", - }) + const { product, isLoading, isError, error } = useProduct(id!) if (isError) { throw error