({ product })
| 5 | import React from 'react' |
| 6 | |
| 7 | const ProductCard = ({ product }) => { |
| 8 | |
| 9 | const currency = process.env.NEXT_PUBLIC_CURRENCY_SYMBOL || '$' |
| 10 | |
| 11 | // calculate the average rating of the product |
| 12 | const rating = Math.round(product.rating.reduce((acc, curr) => acc + curr.rating, 0) / product.rating.length); |
| 13 | |
| 14 | return ( |
| 15 | <Link href={`/product/${product.id}`} className=' group max-xl:mx-auto'> |
| 16 | <div className='bg-[#F5F5F5] h-40 sm:w-60 sm:h-68 rounded-lg flex items-center justify-center'> |
| 17 | <Image width={500} height={500} className='max-h-30 sm:max-h-40 w-auto group-hover:scale-115 transition duration-300' src={product.images[0]} alt="" /> |
| 18 | </div> |
| 19 | <div className='flex justify-between gap-3 text-sm text-slate-800 pt-2 max-w-60'> |
| 20 | <div> |
| 21 | <p>{product.name}</p> |
| 22 | <div className='flex'> |
| 23 | {Array(5).fill('').map((_, index) => ( |
| 24 | <StarIcon key={index} size={14} className='text-transparent mt-0.5' fill={rating >= index + 1 ? "#00C950" : "#D1D5DB"} /> |
| 25 | ))} |
| 26 | </div> |
| 27 | </div> |
| 28 | <p>{currency}{product.price}</p> |
| 29 | </div> |
| 30 | </Link> |
| 31 | ) |
| 32 | } |
| 33 | |
| 34 | export default ProductCard |
nothing calls this directly
no outgoing calls
no test coverage detected