From e72c16eb549488e1ed847b022880f542d2a9c525 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Thu, 5 Oct 2023 09:32:12 +0700 Subject: add component list product for cart, quotation, and checkout --- .../elements/Product/cartProductsList.jsx | 260 +++++++++++++++++++++ 1 file changed, 260 insertions(+) create mode 100644 src/core/components/elements/Product/cartProductsList.jsx (limited to 'src/core/components') diff --git a/src/core/components/elements/Product/cartProductsList.jsx b/src/core/components/elements/Product/cartProductsList.jsx new file mode 100644 index 00000000..c1d96d96 --- /dev/null +++ b/src/core/components/elements/Product/cartProductsList.jsx @@ -0,0 +1,260 @@ +import Link from '@/core/components/elements/Link/Link' +import Image from '@/core/components/elements/Image/Image' +import LogoSpinner from '../Spinner/LogoSpinner' +import { TrashIcon } from '@heroicons/react/24/outline' +import { useEffect } from 'react' +import { createSlug } from '@/core/utils/slug' +import currencyFormat from '@/core/utils/currencyFormat' + +const CardProdcuctsList = ({ + isLoading, + products, + source, + handlePopUpPromo = () => {}, + toggleSelected = () => {}, + updateQuantity = () => {}, + setDeleteConfirmation = () => {} +}) => { + return ( + + + + + + + + {source == 'cart' && } + + + + {isLoading && ( + + + + )} + {!isLoading && (!products || products?.length == 0) && ( + + + + )} + {products && + products?.map((product) => ( + <> + {product.hasProgram && ( + + + + )} + + + + + + + {source == 'cart' && ( + + )} + + {product?.program?.items && ( + + {product.program.items.map((item) => ( + <> + + + + + + + + ))} + + )} + + ))} + +
Nama ProdukJumlahHargaSubtotalAction
+
+ +
+
Keranjang belanja anda masih kosong
+
+ {product.program ? ( + <> +
+ {product.program.type.label} +
+
+ {product.program.type.value == 'merchandise' ? ( + <>Selamat anda mendapatkan merchandise indoteknik.com + ) : ( + <> + Selamat! Pembelian anda lebih hemat + + {' '} + {currencyFormat(product.program?.totalSavings)} + + + )} +
+ + ) : ( + <> +
+ Promo +
+
Pilih Promo Yang Tersedia Bisa lebih Hemat
+ + )} +
+ handlePopUpPromo(product.id, product.quantity, product.program?.id) + } + className='ml-auto text-red-500 flex gap-x-1 cursor-pointer' + > +
Cek Promo
+
+ +
+
+
+
+ + toggleSelected(product.id)} + checked={product?.selected} + className='accent-danger-500 w-4' + /> + + + + {product?.name} + +
+ + {product?.parent?.name} + +
+ {product?.code}{' '} + {product?.attributes.length > 0 ? `| ${product?.attributes.join(', ')}` : ''} +
+
+
+ + updateQuantity(e.target.value, product?.id)} + onBlur={(e) => updateQuantity(e.target.value, product?.id, 'BLUR')} + /> + + + {product?.hasFlashsale ? ( + <> +
+
+ {currencyFormat(product?.price?.price)} +
+
{product?.price?.discountPercentage}%
+
+
+ {currencyFormat(product?.price?.priceDiscount)} +
+ + ) : ( +
{currencyFormat(product?.price?.price)}
+ )} +
+ +
+ {currencyFormat(product?.price?.priceDiscount * product?.quantity)} +
+
+
+ +
+
+ + + +
+ {item.name} +
+
+
+ + {product.program.type.label} + +
+
{item.name}
+
+
+ + + + + {item?.price?.discountPercentage > 0 && ( +
+
+ {currencyFormat(product?.price?.price)} +
+
+ )} +
+ {item?.price.priceDiscount > 0 ? 'Gratis' : ''} +
+
+ +
+ {item.price.priceDiscount > 0 ? 'Gratis' : ''} +
+
+ ) +} + +const ComponentCanBuy = ({ canBuy }) => + !canBuy &&
+ +export default CardProdcuctsList -- cgit v1.2.3 From 760a7199aafb1d7f995611f9b6bca1379dfc4b65 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Thu, 5 Oct 2023 09:54:22 +0700 Subject: hide checkbox if source != cart --- .../components/elements/Product/cartProductsList.jsx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/core/components') diff --git a/src/core/components/elements/Product/cartProductsList.jsx b/src/core/components/elements/Product/cartProductsList.jsx index c1d96d96..7a95f1f1 100644 --- a/src/core/components/elements/Product/cartProductsList.jsx +++ b/src/core/components/elements/Product/cartProductsList.jsx @@ -108,13 +108,17 @@ const CardProdcuctsList = ({ className={`${product.hasProgram ? '!border-t-0 !border-b-0' : ''}`} > - - toggleSelected(product.id)} - checked={product?.selected} - className='accent-danger-500 w-4' - /> + {source == 'cart' && ( + <> + + toggleSelected(product.id)} + checked={product?.selected} + className='accent-danger-500 w-4' + /> + + )} @@ -139,6 +143,7 @@ const CardProdcuctsList = ({ {product?.code}{' '} {product?.attributes.length > 0 ? `| ${product?.attributes.join(', ')}` : ''}
+
Berat item : {product?.weight} Kg
@@ -189,6 +194,7 @@ const CardProdcuctsList = ({ )} + {/* Component for promotion program product */} {product?.program?.items && ( {product.program.items.map((item) => ( -- cgit v1.2.3 From e9f65fadbfcf319db1f2f73e0984acad4f9aa505 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Thu, 5 Oct 2023 10:35:30 +0700 Subject: error query params --- src/core/components/elements/Product/cartProductsList.jsx | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core/components') diff --git a/src/core/components/elements/Product/cartProductsList.jsx b/src/core/components/elements/Product/cartProductsList.jsx index 7a95f1f1..5887b425 100644 --- a/src/core/components/elements/Product/cartProductsList.jsx +++ b/src/core/components/elements/Product/cartProductsList.jsx @@ -15,6 +15,7 @@ const CardProdcuctsList = ({ updateQuantity = () => {}, setDeleteConfirmation = () => {} }) => { + return ( -- cgit v1.2.3