diff --git a/src/app/layout.tsx b/src/app/layout.tsx index b2661be..eecbcff 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -2,6 +2,7 @@ import type { Metadata } from "next"; import type { ReactNode } from 'react'; import Header from "@/components/other/header"; import Footer from "@/components/other/footer"; +import TooltipProvider from "@/components/providers/TooltipProvider"; import '../styles/globals.css'; export const metadata: Metadata = { @@ -18,8 +19,11 @@ export default function RootLayout({
Tổng tiền hàng ({totalItems} sản phẩm): - {totalPrice}đ + {formatPrice(totalPrice)}đ
THANH TOÁN NGAY diff --git a/src/components/providers/TooltipProvider.tsx b/src/components/providers/TooltipProvider.tsx new file mode 100644 index 0000000..98b68d7 --- /dev/null +++ b/src/components/providers/TooltipProvider.tsx @@ -0,0 +1,18 @@ +'use client'; + +import { ReactNode } from 'react'; +import { useTooltip } from '../../hooks/useTooltip'; + +export default function TooltipProvider({ + children, +}: { + children: ReactNode; +}) { + useTooltip(); + + return ( + <> + {children} + > + ); +} diff --git a/src/components/shared/ProductItem.tsx b/src/components/shared/ProductItem.tsx index 54ebc95..726c39b 100644 --- a/src/components/shared/ProductItem.tsx +++ b/src/components/shared/ProductItem.tsx @@ -1,56 +1,86 @@ 'use client'; import Link from "next/link"; -import { formatPrice } from "@/lib/utils"; +import { formatPrice } from "@/lib/utils"; +import { useProductItem } from "@/hooks/useProductItem" +import { useCart } from '@/hooks/useCart'; export default function ProductItem({item}:any){ - console.log('ProductItem: ', item) + const product = useProductItem(item); + if (!product) return null; + + const { addToCart, isInCart } = useCart(); + + const { + productId, + productUrl, + productImage, + productName, + quantity, + price, + marketPrice, + discount, + displayOffer, + warranty, + displaySummary + } = product; + + const checkIncart = isInCart(productId); + const priceView = price > 0 ? formatPrice(price) + 'đ' : 'Liên hệ'; + return ( -22.000.000 đ
+ {discount > 0 && + <> +{priceView}
- - Sẵn hàng -
+ {quantity > 0 ? + ( ++ + Sẵn hàng +
+ ) : ( ++ + Liên hệ +
+ ) + } - {/*- - Liên hệ -
*/} - -- - Quà tặng -
+ {displayOffer && ++ + Quà tặng +
+ }- [Tặng bàn phím] HHPC ULTRA 7 265K | 32GB DDR5 | NVIDIA RTX 3060 12GB + {productName}
Giá bán:
- 48.990.000 đ
- 52.000.000 đ
- -6%
+ {priceView}
+
+ {discount > 0 &&
+ <>
+ {formatPrice(marketPrice)} đ
+
+ -{discount}%
+
+ >
+ }
- Bảo hành: - Theo từng linh kiện -
+ {warranty && ++ Bảo hành: + {warranty} +
+ }+ + Thông số sản phẩm +
-- - Thông số sản phẩm -
- -- - Khuyến mại hấp dẫn -
+ { displayOffer && ++ + Khuyến mại hấp dẫn +
-⭐ Bảo Hành Tại Nơi Sử Dụng (Áp Dụng Nội Thành Hà Nội và Hồ Chí Minh)
⭐ Bảo Hành Siêu Tốc 1 Đổi 1 Trong 24h
⭐ Miễn Phí 100% Vận Chuyển Toàn Quốc