Files
hoanghapc_nextJs/src/components/product/detail/index.tsx

137 lines
5.5 KiB
TypeScript
Raw Normal View History

2026-02-03 17:20:38 +07:00
import parse from 'html-react-parser';
2026-01-28 17:26:02 +07:00
import { formatPrice } from "@/lib/utils";
2026-02-05 17:22:56 +07:00
2026-02-02 16:42:40 +07:00
import ProductImage from "./images";
2026-01-28 17:26:02 +07:00
import Static from "./static";
import ProductDescription from "./description"
2026-02-02 16:42:40 +07:00
import Comment from "./comments";
import Review from "./reviews";
2026-01-28 17:26:02 +07:00
import ProductSpec from "./specifications";
2026-02-02 16:42:40 +07:00
import Article from "./articles";
2026-01-28 17:26:02 +07:00
import ProductPrice from "./price";
import ProductOffer from "./offer";
2026-02-02 16:42:40 +07:00
import Buttons from "./buttons";
2026-01-28 17:26:02 +07:00
import ProductSummary from "./summary";
2026-02-03 17:20:38 +07:00
import ScrollToReviewButton from "./buttons/ScrollToReviewButton";
import ProductTab from "./products";
2025-12-30 18:05:53 +07:00
2026-02-02 16:42:40 +07:00
import { ReviewData } from "@/data/reviews";
2026-01-28 17:26:02 +07:00
export default async function ProductDetail({ slug }: any) {
2026-02-02 16:42:40 +07:00
const imageList = {
productImage : slug.productImage,
imageCollection : slug.imageCollection
2026-01-30 17:09:41 +07:00
}
const priceData = {
2026-02-02 16:42:40 +07:00
price : slug.price,
marketPrice : slug.marketPrice,
deal_list : slug.deal_list,
price_off : slug.price_off,
sale_rules : slug.sale_rules,
hasVAT : slug.hasVAT,
warranty : slug.warranty,
quantity : slug.quantity
2026-01-30 17:09:41 +07:00
}
2025-12-29 17:43:31 +07:00
return (
<>
<div className="product-detail-page container">
<div className="pd-info-container static bg-white rounded-[24px] p-6 mb-6">
<h1 className="leading-8 text-[#004BA4] text-24 mb-6 font-600">
2026-02-02 16:42:40 +07:00
{slug.productName}
2025-12-29 17:43:31 +07:00
</h1>
2026-01-28 17:26:02 +07:00
2025-12-29 17:43:31 +07:00
<div className="gap-6 flex flex-wrap items-start leading-[18px]">
2026-01-28 17:26:02 +07:00
<div className="col-left-group w-[424px] sticky top-[90px]">
2026-02-02 16:42:40 +07:00
<ProductImage data={imageList} />
2025-12-29 17:43:31 +07:00
</div>
2026-01-28 17:26:02 +07:00
<div className="col-middle-group w-[464px]">
2026-02-03 17:20:38 +07:00
<div className="pb-3 mb-3 border-b border-[#DEE4EC] flex flex-wrap items-center gap-2">
<ScrollToReviewButton
avgRate={ReviewData.summary.avgRate}
total={ReviewData.summary.total}
/>
2026-01-28 17:26:02 +07:00
<i className="w-[1px] h-4 bg-[#DEE4EC]" />
<p className="m-0">
Lượt xem:
2026-02-03 17:20:38 +07:00
<span className="text-[#004BA4] font-500">{formatPrice(slug.visit) }</span>
2026-01-28 17:26:02 +07:00
</p>
<i className="w-[1px] h-4 bg-[#DEE4EC]" />
<p className="m-0">
Tình trạng:
2026-02-03 17:20:38 +07:00
{ slug.quantity > 0
? parse('<span class="font-500 text-[#00AD4F]">Còn hàng</span>')
: parse('<span class="font-500 red">Liên hệ</span>')
}
2026-01-28 17:26:02 +07:00
</p>
2025-12-29 17:43:31 +07:00
</div>
2026-01-28 17:26:02 +07:00
2026-02-02 16:42:40 +07:00
{ slug.productSummary &&
<ProductSummary item={slug.productSummary} />
2026-01-28 17:26:02 +07:00
}
2026-01-30 17:09:41 +07:00
<ProductPrice item={priceData} />
2026-01-28 17:26:02 +07:00
2026-02-02 16:42:40 +07:00
<ProductOffer item={slug.specialOffer}/>
2026-01-28 17:26:02 +07:00
2026-02-02 16:42:40 +07:00
<Buttons item={slug.productId} />
2026-01-28 17:26:02 +07:00
<p className="m-0 flex items-center gap-3 text-16 leading-[22px]">
<i className="icons icon-truck-2 !w-6" />
<span> Miễn phí giao hàng trên toàn quốc </span>
2025-12-29 17:43:31 +07:00
</p>
</div>
2026-01-28 17:26:02 +07:00
<div className="col-right-group w-[264px] sticky top-[90px]">
<Static />
2025-12-29 17:43:31 +07:00
</div>
</div>
</div>
2026-01-28 17:26:02 +07:00
2025-12-29 17:43:31 +07:00
<div className="pd-content-container flex flex-wrap items-baseline gap-6">
<div className="col-left w-[784px]">
2026-02-02 16:42:40 +07:00
{ slug.productDescription &&
<ProductDescription
name={slug.productName}
description={slug.productDescription}
/>
}
2026-01-28 17:26:02 +07:00
2026-02-03 17:20:38 +07:00
<div className="pd-comment-container bg-white mb-6 p-8 pt-6 rounded-[24px] text-16 leading-[22px]" id="js-comment-container">
2026-02-02 16:42:40 +07:00
<p className="leading-[31px] font-600 text-24 mb-4 pb-4">
Đánh giá bình luận
</p>
<Review item={ReviewData}/>
2026-01-28 17:26:02 +07:00
<Comment />
2025-12-29 17:43:31 +07:00
</div>
</div>
2026-01-28 17:26:02 +07:00
2025-12-29 17:43:31 +07:00
<div className="col-right w-[440px]">
2026-02-02 16:42:40 +07:00
{slug.productSpec &&
<ProductSpec item={slug.productSpec} />
2026-01-31 12:00:43 +07:00
}
2026-01-28 17:26:02 +07:00
2026-02-02 16:42:40 +07:00
{ slug.related['article-article'].length > 0 &&
<Article item={ slug.related['article-article'] } />
}
2025-12-29 17:43:31 +07:00
</div>
</div>
2026-01-28 17:26:02 +07:00
2025-12-29 17:43:31 +07:00
{/* Sản phẩm tương tự + Sản phẩm đã xem */}
2026-02-03 17:20:38 +07:00
<ProductTab item={slug.related} />
2026-01-28 17:26:02 +07:00
</div>
2025-12-29 17:43:31 +07:00
</>
);
}