@@ -29,6 +29,37 @@ export function ProductCard({
2929 "10*10" : "10*10" ,
3030 } ;
3131
32+ // Obtener el precio base para stickers para la variante 3*3
33+ const getBasePrice = ( ) => {
34+ if ( categorySlug === "stickers" && product . stickersVariants ?. length ) {
35+ const baseVariant = product . stickersVariants . find (
36+ ( variant ) => variant . measure === "3*3"
37+ ) ;
38+ return baseVariant ? baseVariant . price : product . price ;
39+ }
40+ return product . price ;
41+ } ;
42+
43+ // Obtener rango de precios para las variantes filtradas
44+ const getPriceRange = ( ) => {
45+ if ( categorySlug === "stickers" && product . stickersVariants ?. length && variants . length > 0 ) {
46+ const filteredVariants = product . stickersVariants . filter ( variant =>
47+ variants . includes ( variant . measure )
48+ ) ;
49+
50+ if ( filteredVariants . length > 0 ) {
51+ const minPrice = Math . min ( ...filteredVariants . map ( v => v . price ) ) ;
52+ const maxPrice = Math . max ( ...filteredVariants . map ( v => v . price ) ) ;
53+
54+ if ( minPrice === maxPrice ) {
55+ return `S/${ minPrice } ` ;
56+ }
57+ return `S/${ minPrice } - S/${ maxPrice } ` ;
58+ }
59+ }
60+ return null ;
61+ } ;
62+
3263 if ( categorySlug === "polos" ) {
3364 variantTitle = "Elige la talla" ;
3465 variants = [ "Small" , "Medium" , "Large" ] ;
@@ -49,6 +80,9 @@ export function ProductCard({
4980 variantParamName = "measure" ;
5081 }
5182
83+ const basePrice = getBasePrice ( ) ;
84+ const priceRange = getPriceRange ( ) ;
85+
5286 const handleVariantClick = (
5387 e : React . MouseEvent < HTMLButtonElement > ,
5488 variant : string
@@ -115,7 +149,7 @@ export function ProductCard({
115149 < h2 className = "text-sm font-medium" > { product . title } </ h2 >
116150 < p className = "text-sm text-muted-foreground" > { product . description } </ p >
117151 < p className = "mt-auto text-base font-medium" >
118- S/ { hoveredPrice !== null ? hoveredPrice : product . price }
152+ { hoveredPrice !== null ? `S/ ${ hoveredPrice } ` : ( priceRange ? priceRange : `S/ ${ basePrice } ` ) }
119153 </ p >
120154 </ div >
121155 { product . isOnSale && (
0 commit comments