From 4ee24671bc23979d7ac18a5390082c0007928540 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 16 Jul 2024 15:17:17 +0700
Subject: <iman> add select all cart

---
 src-migrate/pages/shop/cart/index.tsx | 33 +++++++++++++++++++++++++++------
 1 file changed, 27 insertions(+), 6 deletions(-)

(limited to 'src-migrate/pages/shop/cart/index.tsx')

diff --git a/src-migrate/pages/shop/cart/index.tsx b/src-migrate/pages/shop/cart/index.tsx
index 7de96425..1f89c7a3 100644
--- a/src-migrate/pages/shop/cart/index.tsx
+++ b/src-migrate/pages/shop/cart/index.tsx
@@ -1,8 +1,8 @@
 import style from './cart.module.css';
 
-import React, { useEffect, useMemo } from 'react';
+import React, { useEffect, useMemo, useState } from 'react';
 import Link from 'next/link';
-import { Button, Toast, Tooltip } from '@chakra-ui/react';
+import { Button, Checkbox, Toast, Tooltip } from '@chakra-ui/react';
 import { toast } from 'react-hot-toast';
 import { useRouter } from 'next/router';
 import { getAuth } from '~/libs/auth';
@@ -19,6 +19,9 @@ const CartPage = () => {
   const router = useRouter();
   const auth = getAuth();
   const [isStepApproval, setIsStepApproval] = React.useState(false);
+  const [isSelectedAll, setIsSelectedAll] = useState<boolean>(false);
+  const [isButtonChek, setIsButtonChek] = useState<boolean>(false);
+  const [buttonSelectNow, setButtonSelectNow] = useState<boolean>(true);
 
   const { loadCart, cart, summary } = useCartStore();
 
@@ -29,8 +32,9 @@ const CartPage = () => {
       loadCart(auth.id);
       setIsStepApproval(auth?.feature?.soApproval);
     }
-  }, [auth, loadCart, cart]);
-
+  }, [auth, loadCart, cart, isButtonChek, ]);
+  
+  
   const hasSelectedPromo = useMemo(() => {
     if (!cart) return false;
     for (const item of cart.products) {
@@ -67,10 +71,26 @@ const CartPage = () => {
     }
   })
 
+  const handleChange = (()=>{
+    setButtonSelectNow(!buttonSelectNow)
+    setIsSelectedAll(!isSelectedAll)
+    setIsButtonChek(!isButtonChek)
+  })
+
   return (
     <>
       <div className={style['title']}>Keranjang Belanja</div>
-
+        <div className='flex items-center object-center mt-2'>
+          <Checkbox
+            borderColor='gray.600'
+            colorScheme='red'
+            size='lg'
+            isChecked={isButtonChek}
+            onChange={handleChange}
+          /> <p className='p-2 text-caption-2'>
+              {buttonSelectNow? "Select all" : "Unchek all" } 
+            </p> 
+        </div>
       <div className='h-6' />
 
       <div className={style['content']}>
@@ -81,8 +101,9 @@ const CartPage = () => {
 
           <div className={style['items']}>
             {cart?.products.map((item) => (
-              <CartItem key={item.id} item={item} />
+              <CartItem key={item.id} item={item} pilihSemuaCart={isSelectedAll}  />
             ))}
+            
 
             {cart?.products?.length === 0 && (
               <div className='flex flex-col items-center'>
-- 
cgit v1.2.3


From 0f62655a7fa63a27f3af418108f44e3bc4bab980 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 16 Jul 2024 16:56:58 +0700
Subject: <iman> update location select all

---
 src-migrate/pages/shop/cart/index.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src-migrate/pages/shop/cart/index.tsx')

diff --git a/src-migrate/pages/shop/cart/index.tsx b/src-migrate/pages/shop/cart/index.tsx
index 1f89c7a3..2ecf1c03 100644
--- a/src-migrate/pages/shop/cart/index.tsx
+++ b/src-migrate/pages/shop/cart/index.tsx
@@ -80,6 +80,7 @@ const CartPage = () => {
   return (
     <>
       <div className={style['title']}>Keranjang Belanja</div>
+      <div className='h-2' />
         <div className='flex items-center object-center mt-2'>
           <Checkbox
             borderColor='gray.600'
@@ -91,7 +92,6 @@ const CartPage = () => {
               {buttonSelectNow? "Select all" : "Unchek all" } 
             </p> 
         </div>
-      <div className='h-6' />
 
       <div className={style['content']}>
         <div className={style['item-wrapper']}>
-- 
cgit v1.2.3

