+
{
[1, 2, 3, 4, 5].map((item) => (
>
)
diff --git a/src/components/buildpc/modal/Products.tsx b/src/components/buildpc/modal/Products.tsx
index 8f65027..b4a2ce5 100644
--- a/src/components/buildpc/modal/Products.tsx
+++ b/src/components/buildpc/modal/Products.tsx
@@ -1,15 +1,9 @@
'use client';
import Link from "next/link";
-import { Fancybox } from "@fancyapps/ui/dist/fancybox/";
-export default function ProductItem({ item, rowId }: any) {
+export default function ProductItem({ item, rowId, onSelect }: any) {
- const handleBuy = () => {
- if (typeof window === "undefined") return;
-
- const storageKey = "buildpc";
- const oldData = localStorage.getItem(storageKey);
- const parsed = oldData ? JSON.parse(oldData) : [];
+ const handleSelect = () => {
const productData = {
id : item.productId,
@@ -22,24 +16,7 @@ export default function ProductItem({ item, rowId }: any) {
warranty : item.warranty || ''
};
- const buildIndex = parsed.findIndex((b: any) => b.rowId === rowId);
-
- if (buildIndex !== -1) {
- parsed[buildIndex].info = [productData];
- } else {
- parsed.push({
- rowId: rowId,
- info: [productData]
- });
- }
-
- localStorage.setItem(storageKey, JSON.stringify(parsed));
-
- // báo cho component cha
- window.dispatchEvent(new Event("buildpcUpdated"));
-
- // đóng popup
- Fancybox.close();
+ onSelect(productData);
};
@@ -89,7 +66,7 @@ export default function ProductItem({ item, rowId }: any) {