Files
nguyencongpc_nextjs/src/components/product/ProductDetail/BoxInfoRight/index.tsx

157 lines
5.8 KiB
TypeScript
Raw Normal View History

2025-12-29 17:29:51 +07:00
'use client';
import { useRouter } from 'next/navigation';
2025-12-27 10:03:53 +07:00
import type { ProductDetailData } from '@/types';
import Link from 'next/link';
import { BoxPrice } from './BoxPrice';
2025-12-27 12:01:54 +07:00
import { BoxBought } from './BoxBought';
2025-12-27 10:03:53 +07:00
2025-12-29 17:29:51 +07:00
// thêm giỏ hàng
import { addToCart } from '@/lib/ButtonCart';
2025-12-27 10:03:53 +07:00
export const BoxInfoRight = (item: ProductDetailData) => {
2025-12-29 17:29:51 +07:00
const router = useRouter();
const handleBuyNow = () => {
router.push('/cart');
addToCart(item.product_info.productId);
};
2025-12-27 10:03:53 +07:00
return (
<>
2025-12-27 12:01:54 +07:00
<h1 className="product-name color-black line-clamp-3 font-bold">
{item.product_info.productName}
</h1>
2025-12-27 10:03:53 +07:00
<div className="list-basic-product-info flex flex-wrap items-center">
<div className="item-basic">
SP: <span className="color-primary">{item.product_info.productSKU}</span>
</div>
<div className="item-basic">
Đánh giá: <span className="color-primary">{item.product_info.review.summary.total}</span>
</div>
<div className="item-basic">
Bình luận:{' '}
<span className="color-primary">{item.product_info.comment.summary.total}</span>
</div>
<div className="item-basic">
Lượt xem: <span className="color-primary">{item.product_info.visit}</span>
</div>
{item.product_info.extend.buy_count?.length > 0 && (
<div className="item-basic last-item-basic position-relative">
Đã bán: <span className="color-primary">{item.product_info.extend.buy_count}</span>
</div>
)}
</div>
{/* tình trạng */}
<div className="list-basic-product-info flex flex-wrap items-center gap-6">
<div className="item-basic">
Bảo hành: <span className="color-red">{item.product_info.warranty}</span>
</div>
{item.product_info.quantity > '0' && (
<div className="item-basic last-item-basic position-relative">
Tình trạng: <span className="color-green">Còn hàng</span>
</div>
)}
</div>
{/* giá */}
<BoxPrice {...item} />
{item.product_info.specialOffer.all.length > 0 && (
<div className="box-offer-detail border-radius-10">
<div className="title-offer-detail flex items-center">
<i className="sprite sprite-gift-detail"></i>
<p className="font-weight-600">Khuyến mãi</p>
</div>
<div className="list-info-offter">
{item.product_info.specialOffer.all.map((_item, idx) => (
<div key={idx} className="item-offer">
<i className="icon"></i>
<div dangerouslySetInnerHTML={{ __html: _item.title }} />
</div>
))}
</div>
</div>
)}
{/* mua hàng */}
{(item.product_info.quantity > '0' || item.product_info.price > '0') && (
<>
<div className="product-buy-quantity flex items-center">
<p className="title-quantity">Số lượng:</p>
<div className="cart-quantity-select flex items-center justify-center">
<p className="js-quantity-change" data-value="-1">
{' '}
{' '}
</p>
<input
type="text"
className="js-buy-quantity js-quantity-change bk-product-qty font-bold"
defaultValue={1}
/>
<p className="js-quantity-change" data-value="1">
{' '}
+{' '}
</p>
</div>
2025-12-29 17:29:51 +07:00
<button
className="addCart flex cursor-pointer flex-wrap items-center justify-center gap-3"
onClick={() => {
addToCart(item.product_info.productId);
alert('Sản phẩm đã được thêm vào giỏ hàng!');
}}
>
2025-12-27 10:03:53 +07:00
<i className="sprite sprite-cart-detail"></i>
<p className="title-cart">Thêm vào giỏ hàng</p>
2025-12-29 17:29:51 +07:00
</button>
2025-12-27 10:03:53 +07:00
<input type="hidden" className="js-buy-quantity-temp" value="1" />
</div>
2025-12-29 17:29:51 +07:00
<div
id="detail-buy-ads"
className="detail-buy grid grid-cols-2 gap-2"
onClick={() => handleBuyNow()}
>
<button className="detail-buy-now col-span-2 cursor-pointer">
2025-12-27 10:03:53 +07:00
<span>ĐT MUA NGAY</span>
Giao hàng tận nơi nhanh chóng
2025-12-29 17:29:51 +07:00
</button>
2025-12-27 10:03:53 +07:00
2025-12-29 17:29:51 +07:00
<button className="detail-add-cart">
2025-12-27 10:03:53 +07:00
<span>TRẢ GÓP QUA HỒ </span>
Chỉ từ 2.665.000/ tháng
2025-12-29 17:29:51 +07:00
</button>
2025-12-27 10:03:53 +07:00
2025-12-29 17:29:51 +07:00
<button className="detail-add-cart">
2025-12-27 10:03:53 +07:00
<span>TRẢ GÓP QUA THẺ</span>
Chỉ từ 1.332.500/ tháng
2025-12-29 17:29:51 +07:00
</button>
2025-12-27 10:03:53 +07:00
</div>
</>
)}
2025-12-29 17:29:51 +07:00
{/* yên tâm mua hàng */}
2025-12-27 12:01:54 +07:00
<div className="box-product-policy-detal boder-radius-10" style={{ marginTop: '24px' }}>
<h2 className="title font-[600]">Yên tâm mua hàng</h2>
<div className="list-showroom-detail flex flex-wrap justify-between">
<div className="item flex items-center gap-2">
<i className="sprite sprite-camket-detail"></i>
<p>Cam kết giá tốt nhất thị trường.</p>
</div>
<div className="item flex items-center gap-2">
<i className="sprite sprite-sanphammoi-detail"></i>
<p>Sản phẩm mới 100%.</p>
</div>
<div className="item flex items-center gap-2">
<i className="sprite sprite-1doi1-detail"></i>
<p>Lỗi 1 đi 1 ngay lập tức.</p>
</div>
<div className="item flex items-center gap-2">
<i className="sprite sprite-hotrotragop-detail"></i>
<p>Hỗ trợ trả góp - Thủ tục nhanh gọn.</p>
</div>
</div>
</div>
<BoxBought />
2025-12-27 10:03:53 +07:00
</>
);
};