diff --git a/src/components/common/product/DealProductItem.tsx b/src/components/common/product/DealProductItem.tsx new file mode 100644 index 0000000..771ed13 --- /dev/null +++ b/src/components/common/product/DealProductItem.tsx @@ -0,0 +1,163 @@ +import React from 'react'; +import Image from 'next/image'; +import Link from 'next/link'; +import { TypeListProductDeal } from '@types/TypeListProductDeal'; + +const formatCurrency = (price: number | string) => { + return Number(price).toLocaleString('vi-VN'); +}; + +const DealProductItem = ({ item }: { item: TypeListProductDeal }) => { + const product = item.product_info; + const quantityLeft = item.quantity - item.sale_quantity; + + return ( +
{product.marketPrice.toLocaleString()} ₫
++ {product.sale_rules.normal_price.toLocaleString()} ₫ +
+Giá niêm yết
+ ) : ( + product.sale_rules?.type === 'deal' &&Giá gốc
+ )} +Giá bán
+ {product.warranty !== '' &&Bảo hành
} +Tình trạng
++ {product.marketPrice.toLocaleString()}₫ + +
+ + -{product.price_off}% + ++ {product.sale_rules.normal_price.toLocaleString()} ₫ + +
+ + - + {Math.floor( + 100 - + (Number(product.sale_rules.price) / product.sale_rules.normal_price) * 100, + )} + % + +{Number(product.price) > 0 ? `${formatCurrency(product.price)}đ` : 'Liên hệ'}
+{product.warranty}
+{quantityLeft > 0 ? 'Còn DEAL' : 'Hết DEAL'}
++ Khuyến mãi +
+