55} from '@fluentui/react-components' ;
66import {
77 Sparkle20Regular ,
8+ Box20Regular ,
89} from '@fluentui/react-icons' ;
910import type { Product } from '../types' ;
1011
@@ -28,13 +29,6 @@ export function ProductReview({
2829 const displayProducts = availableProducts . length > 0 ? availableProducts : products ;
2930 const selectedProductIds = new Set ( products . map ( p => p . sku || p . product_name ) ) ;
3031
31- const getProductColor = ( product : Product ) : string => {
32- if ( product . hex_value ) return product . hex_value ;
33- const hash = product . product_name . split ( '' ) . reduce ( ( acc , char ) => acc + char . charCodeAt ( 0 ) , 0 ) ;
34- const hue = hash % 360 ;
35- return `hsl(${ hue } , 30%, 85%)` ;
36- } ;
37-
3832 const isProductSelected = ( product : Product ) : boolean => {
3933 return selectedProductIds . has ( product . sku || product . product_name ) ;
4034 } ;
@@ -73,7 +67,6 @@ export function ProductReview({
7367 < ProductCardGrid
7468 key = { product . sku || index }
7569 product = { product }
76- color = { getProductColor ( product ) }
7770 isSelected = { isProductSelected ( product ) }
7871 onClick = { ( ) => handleProductClick ( product ) }
7972 />
@@ -129,12 +122,11 @@ export function ProductReview({
129122
130123interface ProductCardGridProps {
131124 product : Product ;
132- color : string ;
133125 isSelected : boolean ;
134126 onClick : ( ) => void ;
135127}
136128
137- function ProductCardGrid ( { product, color , isSelected, onClick } : ProductCardGridProps ) {
129+ function ProductCardGrid ( { product, isSelected, onClick } : ProductCardGridProps ) {
138130 return (
139131 < div
140132 className = { `product-card ${ isSelected ? 'selected' : '' } ` }
@@ -152,17 +144,36 @@ function ProductCardGrid({ product, color, isSelected, onClick }: ProductCardGri
152144 transition : 'all 0.15s ease-in-out' ,
153145 } }
154146 >
155- < div
156- className = "product-color-swatch"
157- style = { {
158- width : '80px' ,
159- height : '80px' ,
160- borderRadius : '8px' ,
161- backgroundColor : color ,
162- border : `1px solid ${ tokens . colorNeutralStroke2 } ` ,
163- flexShrink : 0 ,
164- } }
165- />
147+ { product . image_url ? (
148+ < img
149+ src = { product . image_url }
150+ alt = { product . product_name }
151+ style = { {
152+ width : '80px' ,
153+ height : '80px' ,
154+ objectFit : 'cover' ,
155+ borderRadius : '8px' ,
156+ border : `1px solid ${ tokens . colorNeutralStroke2 } ` ,
157+ flexShrink : 0 ,
158+ } }
159+ />
160+ ) : (
161+ < div
162+ style = { {
163+ width : '80px' ,
164+ height : '80px' ,
165+ borderRadius : '8px' ,
166+ backgroundColor : tokens . colorNeutralBackground3 ,
167+ border : `1px solid ${ tokens . colorNeutralStroke2 } ` ,
168+ flexShrink : 0 ,
169+ display : 'flex' ,
170+ alignItems : 'center' ,
171+ justifyContent : 'center' ,
172+ } }
173+ >
174+ < Box20Regular style = { { color : tokens . colorNeutralForeground3 , fontSize : '24px' } } />
175+ </ div >
176+ ) }
166177
167178 < div className = "product-info" style = { { flex : 1 , minWidth : 0 } } >
168179 < Text
0 commit comments