fix package analyses count should include variant count
This commit is contained in:
@@ -122,8 +122,9 @@ async function analysisPackagesWithVariantLoader({
|
|||||||
return [
|
return [
|
||||||
...acc,
|
...acc,
|
||||||
{
|
{
|
||||||
|
variant,
|
||||||
variantId: variant.id,
|
variantId: variant.id,
|
||||||
nrOfAnalyses: getAnalysisElementMedusaProductIds([product]).length,
|
nrOfAnalyses: getAnalysisElementMedusaProductIds([{ ...product, variant }]).length,
|
||||||
price: variant.calculated_price?.calculated_amount ?? 0,
|
price: variant.calculated_price?.calculated_amount ?? 0,
|
||||||
title: product.title,
|
title: product.title,
|
||||||
subtitle: product.subtitle,
|
subtitle: product.subtitle,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { useState } from 'react';
|
|||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
|
|
||||||
import { StoreProduct } from '@medusajs/types';
|
import type { AdminProductVariant, StoreProduct } from '@medusajs/types';
|
||||||
import { Button } from '@medusajs/ui';
|
import { Button } from '@medusajs/ui';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { handleAddToCart } from '../../../../lib/services/medusaCart.service';
|
import { handleAddToCart } from '../../../../lib/services/medusaCart.service';
|
||||||
@@ -30,6 +30,7 @@ export type AnalysisPackageWithVariant = Pick<StoreProduct, 'title' | 'descripti
|
|||||||
isStandard: boolean;
|
isStandard: boolean;
|
||||||
isStandardPlus: boolean;
|
isStandardPlus: boolean;
|
||||||
isPremium: boolean;
|
isPremium: boolean;
|
||||||
|
variant: Pick<AdminProductVariant, 'metadata'>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function SelectAnalysisPackage({
|
export default function SelectAnalysisPackage({
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { StoreProduct } from "@medusajs/types";
|
import type { AdminProductVariant, StoreProduct } from "@medusajs/types";
|
||||||
|
|
||||||
type Product = {
|
type Product = {
|
||||||
metadata?: {
|
metadata?: {
|
||||||
@@ -11,7 +11,7 @@ type Product = {
|
|||||||
} | null;
|
} | null;
|
||||||
} | null;
|
} | null;
|
||||||
|
|
||||||
export const getAnalysisElementMedusaProductIds = (products: Pick<StoreProduct, 'metadata'>[]) => {
|
export const getAnalysisElementMedusaProductIds = (products: (Pick<StoreProduct, 'metadata'> & { variant?: Pick<AdminProductVariant, 'metadata'> })[]) => {
|
||||||
if (!products) {
|
if (!products) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user