From f62b2345f463695ef0f8f79830cd76b6e0332821 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Sat, 13 Jan 2024 10:35:22 +0700
Subject: Refactor src migrate folder

---
 src-migrate/pages/shop/cart/index.tsx | 93 +++++++++++++++++++++++++++++++++++
 1 file changed, 93 insertions(+)
 create mode 100644 src-migrate/pages/shop/cart/index.tsx

(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
new file mode 100644
index 00000000..397852f9
--- /dev/null
+++ b/src-migrate/pages/shop/cart/index.tsx
@@ -0,0 +1,93 @@
+import style from './cart.module.css'
+
+import React, { useEffect, useMemo } from 'react'
+import Link from 'next/link'
+import { Button, Tooltip } from '@chakra-ui/react'
+
+import { getAuth } from '~/libs/auth'
+import { useCartStore } from '~/modules/cart/stores/useCartStore'
+
+import CartItem from '~/modules/cart/components/Item'
+import CartSummary from '~/modules/cart/components/Summary'
+
+const CartPage = () => {
+  const auth = getAuth()
+
+  const { loadCart, cart, summary } = useCartStore()
+
+  useEffect(() => {
+    if (typeof auth === 'object' && !cart) loadCart(auth.id)
+  }, [auth, loadCart, cart])
+
+  const hasSelectedPromo = useMemo(() => {
+    if (!cart) return false
+    for (const item of cart.products) {
+      if (item.cart_type === 'promotion' && item.selected) return true
+    }
+    return false
+  }, [cart])
+
+  const hasSelected = useMemo(() => {
+    if (!cart) return false
+    for (const item of cart.products) {
+      if (item.selected) return true
+    }
+    return false
+  }, [cart])
+
+  return (
+    <>
+      <div className={style['title']}>
+        Keranjang Belanja
+      </div>
+
+      <div className='h-6' />
+
+      <div className={style['content']}>
+        <div className={style['item-wrapper']}>
+          <div className={style['item-skeleton']}>
+            {!cart && <CartItem.Skeleton count={5} height='120px' />}
+          </div>
+
+          <div className={style['items']}>
+            {cart?.products.map((item) => <CartItem key={item.id} item={item} />)}
+          </div>
+        </div>
+
+        <div className={style['summary-wrapper']}>
+          <div className={style['summary']}>
+            <CartSummary {...summary} isLoaded={!!cart} />
+
+            <div className={style['summary-buttons']}>
+              <Tooltip label={hasSelectedPromo && 'Barang promo tidak dapat dibuat quotation'}>
+                <Button
+                  colorScheme='yellow'
+                  w='full'
+                  isDisabled={hasSelectedPromo || !hasSelected}
+                  as={Link}
+                  href='/shop/quotation'
+                >
+                  Quotation
+                </Button>
+              </Tooltip>
+
+              <Tooltip label={!hasSelected && 'Tidak ada item yang dipilih'}>
+                <Button
+                  colorScheme='red'
+                  w='full'
+                  isDisabled={!hasSelected}
+                  as={Link}
+                  href='/shop/checkout'
+                >
+                  Checkout
+                </Button>
+              </Tooltip>
+            </div>
+          </div>
+        </div>
+      </div>
+    </>
+  )
+}
+
+export default CartPage
\ No newline at end of file
-- 
cgit v1.2.3


From fb80b92d502437160e45b237b380071ab102c838 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Mon, 22 Jan 2024 10:41:53 +0700
Subject: Update disable checkout when has product price 0 and fix filter brand

---
 src-migrate/pages/shop/cart/index.tsx | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 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 397852f9..9ec58a48 100644
--- a/src-migrate/pages/shop/cart/index.tsx
+++ b/src-migrate/pages/shop/cart/index.tsx
@@ -9,6 +9,7 @@ import { useCartStore } from '~/modules/cart/stores/useCartStore'
 
 import CartItem from '~/modules/cart/components/Item'
 import CartSummary from '~/modules/cart/components/Summary'
+import clsxm from '~/libs/clsxm'
 
 const CartPage = () => {
   const auth = getAuth()
@@ -35,6 +36,14 @@ const CartPage = () => {
     return false
   }, [cart])
 
+  const hasSelectNoPrice = useMemo(() => {
+    if (!cart) return false
+    for (const item of cart.products) {
+      if (item.selected && item.price.price_discount == 0) return true
+    }
+    return false
+  }, [cart])
+
   return (
     <>
       <div className={style['title']}>
@@ -71,11 +80,14 @@ const CartPage = () => {
                 </Button>
               </Tooltip>
 
-              <Tooltip label={!hasSelected && 'Tidak ada item yang dipilih'}>
+              <Tooltip label={clsxm({
+                'Tidak ada item yang dipilih': !hasSelected,
+                'Terdapat item yang tidak ada harga': hasSelectNoPrice
+              })}>
                 <Button
                   colorScheme='red'
                   w='full'
-                  isDisabled={!hasSelected}
+                  isDisabled={!hasSelected || hasSelectNoPrice}
                   as={Link}
                   href='/shop/checkout'
                 >
-- 
cgit v1.2.3


From 9661bcf006332508084d4fdf5c0e2041fdfe9162 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Fri, 8 Mar 2024 17:11:36 +0700
Subject: Update empty state on cart page

---
 src-migrate/pages/shop/cart/index.tsx | 10 ++++++++++
 1 file changed, 10 insertions(+)

(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 9ec58a48..5c047af4 100644
--- a/src-migrate/pages/shop/cart/index.tsx
+++ b/src-migrate/pages/shop/cart/index.tsx
@@ -10,6 +10,7 @@ import { useCartStore } from '~/modules/cart/stores/useCartStore'
 import CartItem from '~/modules/cart/components/Item'
 import CartSummary from '~/modules/cart/components/Summary'
 import clsxm from '~/libs/clsxm'
+import Image from '~/components/ui/image'
 
 const CartPage = () => {
   const auth = getAuth()
@@ -60,6 +61,15 @@ const CartPage = () => {
 
           <div className={style['items']}>
             {cart?.products.map((item) => <CartItem key={item.id} item={item} />)}
+
+            {cart?.products?.length === 0 && (
+              <div className='flex flex-col items-center'>
+                <Image src='/images/empty_cart.svg' alt='Empty Cart' width={450} height={450} />
+                <div className='text-title-sm md:text-title-lg text-center font-semibold'>Keranjangnya masih kosong nih</div>
+                <div className='text-body-2 md:text-body-1 text-center mt-3'>Yuk, tambahin barang-barang yang kamu mau ke keranjang sekarang!<br />Ada banyak potongan belanjanya pakai kode voucher</div>
+                <Link href='/' className='btn-solid-red rounded-full text-body-1 mt-6'>Mulai Belanja</Link>
+              </div>
+            )}
           </div>
         </div>
 
-- 
cgit v1.2.3


From 9a52d9f835e2f30480142c6197fdf14b3fee5ead Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Tue, 12 Mar 2024 09:17:01 +0700
Subject: feedback kerajang di mobile

---
 src-migrate/pages/shop/cart/index.tsx | 7 ++++++-
 1 file changed, 6 insertions(+), 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 9ec58a48..6c37b434 100644
--- a/src-migrate/pages/shop/cart/index.tsx
+++ b/src-migrate/pages/shop/cart/index.tsx
@@ -10,11 +10,15 @@ import { useCartStore } from '~/modules/cart/stores/useCartStore'
 import CartItem from '~/modules/cart/components/Item'
 import CartSummary from '~/modules/cart/components/Summary'
 import clsxm from '~/libs/clsxm'
+import useDevice from '@/core/hooks/useDevice'
+import CartSummaryMobile from '~/modules/cart/components/CartSummaryMobile'
 
 const CartPage = () => {
   const auth = getAuth()
 
   const { loadCart, cart, summary } = useCartStore()
+  
+  const useDivvice = useDevice();
 
   useEffect(() => {
     if (typeof auth === 'object' && !cart) loadCart(auth.id)
@@ -65,7 +69,8 @@ const CartPage = () => {
 
         <div className={style['summary-wrapper']}>
           <div className={style['summary']}>
-            <CartSummary {...summary} isLoaded={!!cart} />
+            {useDivvice.isMobile && <CartSummaryMobile {...summary} isLoaded={!!cart} />}
+            {!useDivvice.isMobile && <CartSummary {...summary} isLoaded={!!cart} />}
 
             <div className={style['summary-buttons']}>
               <Tooltip label={hasSelectedPromo && 'Barang promo tidak dapat dibuat quotation'}>
-- 
cgit v1.2.3


From 5234b7c85ac984bc76d8945934a90b75f4a0d8c0 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Tue, 12 Mar 2024 15:07:56 +0700
Subject: feeback review

---
 src-migrate/pages/shop/cart/index.tsx | 129 +++++++++++++++++++++-------------
 1 file changed, 80 insertions(+), 49 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 d1a6a6ff..4b4de92b 100644
--- a/src-migrate/pages/shop/cart/index.tsx
+++ b/src-migrate/pages/shop/cart/index.tsx
@@ -1,59 +1,57 @@
-import style from './cart.module.css'
+import style from './cart.module.css';
 
-import React, { useEffect, useMemo } from 'react'
-import Link from 'next/link'
-import { Button, Tooltip } from '@chakra-ui/react'
+import React, { useEffect, useMemo } from 'react';
+import Link from 'next/link';
+import { Button, Tooltip } from '@chakra-ui/react';
 
-import { getAuth } from '~/libs/auth'
-import { useCartStore } from '~/modules/cart/stores/useCartStore'
+import { getAuth } from '~/libs/auth';
+import { useCartStore } from '~/modules/cart/stores/useCartStore';
 
-import CartItem from '~/modules/cart/components/Item'
-import CartSummary from '~/modules/cart/components/Summary'
-import clsxm from '~/libs/clsxm'
-import useDevice from '@/core/hooks/useDevice'
-import CartSummaryMobile from '~/modules/cart/components/CartSummaryMobile'
-import Image from '~/components/ui/image'
+import CartItem from '~/modules/cart/components/Item';
+import CartSummary from '~/modules/cart/components/Summary';
+import clsxm from '~/libs/clsxm';
+import useDevice from '@/core/hooks/useDevice';
+import CartSummaryMobile from '~/modules/cart/components/CartSummaryMobile';
+import Image from '~/components/ui/image';
 
 const CartPage = () => {
-  const auth = getAuth()
+  const auth = getAuth();
+
+  const { loadCart, cart, summary } = useCartStore();
 
-  const { loadCart, cart, summary } = useCartStore()
-  
   const useDivvice = useDevice();
 
   useEffect(() => {
-    if (typeof auth === 'object' && !cart) loadCart(auth.id)
-  }, [auth, loadCart, cart])
+    if (typeof auth === 'object' && !cart) loadCart(auth.id);
+  }, [auth, loadCart, cart]);
 
   const hasSelectedPromo = useMemo(() => {
-    if (!cart) return false
+    if (!cart) return false;
     for (const item of cart.products) {
-      if (item.cart_type === 'promotion' && item.selected) return true
+      if (item.cart_type === 'promotion' && item.selected) return true;
     }
-    return false
-  }, [cart])
+    return false;
+  }, [cart]);
 
   const hasSelected = useMemo(() => {
-    if (!cart) return false
+    if (!cart) return false;
     for (const item of cart.products) {
-      if (item.selected) return true
+      if (item.selected) return true;
     }
-    return false
-  }, [cart])
+    return false;
+  }, [cart]);
 
   const hasSelectNoPrice = useMemo(() => {
-    if (!cart) return false
+    if (!cart) return false;
     for (const item of cart.products) {
-      if (item.selected && item.price.price_discount == 0) return true
+      if (item.selected && item.price.price_discount == 0) return true;
     }
-    return false
-  }, [cart])
+    return false;
+  }, [cart]);
 
   return (
     <>
-      <div className={style['title']}>
-        Keranjang Belanja
-      </div>
+      <div className={style['title']}>Keranjang Belanja</div>
 
       <div className='h-6' />
 
@@ -64,26 +62,57 @@ const CartPage = () => {
           </div>
 
           <div className={style['items']}>
-            {cart?.products.map((item) => <CartItem key={item.id} item={item} />)}
+            {cart?.products.map((item) => (
+              <CartItem key={item.id} item={item} />
+            ))}
 
             {cart?.products?.length === 0 && (
               <div className='flex flex-col items-center'>
-                <Image src='/images/empty_cart.svg' alt='Empty Cart' width={450} height={450} />
-                <div className='text-title-sm md:text-title-lg text-center font-semibold'>Keranjangnya masih kosong nih</div>
-                <div className='text-body-2 md:text-body-1 text-center mt-3'>Yuk, tambahin barang-barang yang kamu mau ke keranjang sekarang!<br />Ada banyak potongan belanjanya pakai kode voucher</div>
-                <Link href='/' className='btn-solid-red rounded-full text-body-1 mt-6'>Mulai Belanja</Link>
+                <Image
+                  src='/images/empty_cart.svg'
+                  alt='Empty Cart'
+                  width={450}
+                  height={450}
+                />
+                <div className='text-title-sm md:text-title-lg text-center font-semibold'>
+                  Keranjangnya masih kosong nih
+                </div>
+                <div className='text-body-2 md:text-body-1 text-center mt-3'>
+                  Yuk, tambahin barang-barang yang kamu mau ke keranjang
+                  sekarang!
+                  <br />
+                  Ada banyak potongan belanjanya pakai kode voucher
+                </div>
+                <Link
+                  href='/'
+                  className='btn-solid-red rounded-full text-body-1 mt-6'
+                >
+                  Mulai Belanja
+                </Link>
               </div>
             )}
           </div>
         </div>
-
-        <div className={style['summary-wrapper']}>
+        <div
+          className={`${style['summary-wrapper']} ${
+            useDivvice.isMobile && cart?.product_total === 0 ? 'hidden' : ''
+          }`}
+        >
           <div className={style['summary']}>
-            {useDivvice.isMobile && <CartSummaryMobile {...summary} isLoaded={!!cart} />}
-            {!useDivvice.isMobile && <CartSummary {...summary} isLoaded={!!cart} />}
+            {useDivvice.isMobile && (
+              <CartSummaryMobile {...summary} isLoaded={!!cart} />
+            )}
+            {!useDivvice.isMobile && (
+              <CartSummary {...summary} isLoaded={!!cart} />
+            )}
 
             <div className={style['summary-buttons']}>
-              <Tooltip label={hasSelectedPromo && 'Barang promo tidak dapat dibuat quotation'}>
+              <Tooltip
+                label={
+                  hasSelectedPromo &&
+                  'Barang promo tidak dapat dibuat quotation'
+                }
+              >
                 <Button
                   colorScheme='yellow'
                   w='full'
@@ -95,10 +124,12 @@ const CartPage = () => {
                 </Button>
               </Tooltip>
 
-              <Tooltip label={clsxm({
-                'Tidak ada item yang dipilih': !hasSelected,
-                'Terdapat item yang tidak ada harga': hasSelectNoPrice
-              })}>
+              <Tooltip
+                label={clsxm({
+                  'Tidak ada item yang dipilih': !hasSelected,
+                  'Terdapat item yang tidak ada harga': hasSelectNoPrice,
+                })}
+              >
                 <Button
                   colorScheme='red'
                   w='full'
@@ -114,7 +145,7 @@ const CartPage = () => {
         </div>
       </div>
     </>
-  )
-}
+  );
+};
 
-export default CartPage
\ No newline at end of file
+export default CartPage;
-- 
cgit v1.2.3


From ed0d0293f88adf3c5312cb556bc464e330b3672a Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Fri, 26 Apr 2024 09:44:31 +0700
Subject: hide button checkout if is step approval is true

---
 src-migrate/pages/shop/cart/index.tsx | 39 ++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 17 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 4b4de92b..9866be46 100644
--- a/src-migrate/pages/shop/cart/index.tsx
+++ b/src-migrate/pages/shop/cart/index.tsx
@@ -16,13 +16,17 @@ import Image from '~/components/ui/image';
 
 const CartPage = () => {
   const auth = getAuth();
+  const [isStepApproval, setIsStepApproval] = React.useState(false);
 
   const { loadCart, cart, summary } = useCartStore();
 
   const useDivvice = useDevice();
 
   useEffect(() => {
-    if (typeof auth === 'object' && !cart) loadCart(auth.id);
+    if (typeof auth === 'object' && !cart) {
+      loadCart(auth.id);
+      setIsStepApproval(auth?.feature?.soApproval);
+    }
   }, [auth, loadCart, cart]);
 
   const hasSelectedPromo = useMemo(() => {
@@ -123,23 +127,24 @@ const CartPage = () => {
                   Quotation
                 </Button>
               </Tooltip>
-
-              <Tooltip
-                label={clsxm({
-                  'Tidak ada item yang dipilih': !hasSelected,
-                  'Terdapat item yang tidak ada harga': hasSelectNoPrice,
-                })}
-              >
-                <Button
-                  colorScheme='red'
-                  w='full'
-                  isDisabled={!hasSelected || hasSelectNoPrice}
-                  as={Link}
-                  href='/shop/checkout'
+              {!isStepApproval && (
+                <Tooltip
+                  label={clsxm({
+                    'Tidak ada item yang dipilih': !hasSelected,
+                    'Terdapat item yang tidak ada harga': hasSelectNoPrice,
+                  })}
                 >
-                  Checkout
-                </Button>
-              </Tooltip>
+                  <Button
+                    colorScheme='red'
+                    w='full'
+                    isDisabled={!hasSelected || hasSelectNoPrice}
+                    as={Link}
+                    href='/shop/checkout'
+                  >
+                    Checkout
+                  </Button>
+                </Tooltip>
+              )}
             </div>
           </div>
         </div>
-- 
cgit v1.2.3


From 145f9edfd32b385771483b9b95a9fa0fa24c2dec Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Fri, 26 Apr 2024 13:57:55 +0700
Subject: css

---
 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 9866be46..e101b5ad 100644
--- a/src-migrate/pages/shop/cart/index.tsx
+++ b/src-migrate/pages/shop/cart/index.tsx
@@ -110,7 +110,7 @@ const CartPage = () => {
               <CartSummary {...summary} isLoaded={!!cart} />
             )}
 
-            <div className={style['summary-buttons']}>
+            <div className={style['summary-buttons'] + isStepApproval ? '!grid-cols-1 mt-4' : ''}>
               <Tooltip
                 label={
                   hasSelectedPromo &&
-- 
cgit v1.2.3


From 556cbc1e5ea1c1ef0170c9a1b8f470a3d92d888e Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Tue, 2 Jul 2024 10:40:06 +0700
Subject: IS SO APPROVAL

---
 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 e101b5ad..d89707d2 100644
--- a/src-migrate/pages/shop/cart/index.tsx
+++ b/src-migrate/pages/shop/cart/index.tsx
@@ -110,7 +110,7 @@ const CartPage = () => {
               <CartSummary {...summary} isLoaded={!!cart} />
             )}
 
-            <div className={style['summary-buttons'] + isStepApproval ? '!grid-cols-1 mt-4' : ''}>
+            <div className={isStepApproval ? style['summary-buttons-step-approval'] : style['summary-buttons']  }>
               <Tooltip
                 label={
                   hasSelectedPromo &&
-- 
cgit v1.2.3

