From a7574b1276d751824b0c16c0696133ea1517223a Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Thu, 3 Aug 2023 17:06:09 +0700
Subject: voucher

---
 src/lib/checkout/components/Checkout.jsx | 161 +++++++++++++++++++------------
 1 file changed, 97 insertions(+), 64 deletions(-)

(limited to 'src/lib/checkout/components/Checkout.jsx')

diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx
index 53ac63e1..9ffac61a 100644
--- a/src/lib/checkout/components/Checkout.jsx
+++ b/src/lib/checkout/components/Checkout.jsx
@@ -301,7 +301,7 @@ const Checkout = () => {
       voucher: activeVoucher,
       type: 'sale_order'
     }
-    if(query){
+    if (query) {
       data.source = 'buy'
     }
     if (poNumber.current.value) data.po_number = poNumber.current.value
@@ -491,6 +491,81 @@ const Checkout = () => {
                   )}
 
                   <div className={`border border-solid mb-5 w-full hover:cursor-pointer  p-4 `}>
+                    {item.canApply && (
+                      <div
+                        class='p-2 mb-4 text-sm text-green-800 rounded-lg bg-green-50 dark:text-green-400'
+                        role='alert'
+                      >
+                        <p>
+                          Potensi potongan sebesar{' '}
+                          <span className='text-red-500'>
+                            {currencyFormat(item.discountVoucher)}
+                          </span>
+                        </p>
+                      </div>
+                    )}
+                    {!item.canApply && item.applyStatus === 'UM' && (
+                      <div
+                        class='p-2 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400'
+                        role='alert'
+                      >
+                        <p>
+                          Tambah produk{' '}
+                          <span className='text-red-500'>{item.manufactureNames}</span> senilai{' '}
+                          <span className='text-red-500'>
+                            {currencyFormat(item.minPurchaseAmount)}
+                          </span>{' '}
+                          untuk pakai promo ini
+                        </p>
+                      </div>
+                    )}
+
+                    {!item.canApply &&
+                      item.applyStatus === 'MPA' &&
+                      item.manufactureNames != '' && (
+                        <div
+                          class='p-2 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400'
+                          role='alert'
+                        >
+                          <p>
+                            Tambah produk{' '}
+                            <span className='text-red-500'>{item.manufactureNames}</span> senilai{' '}
+                            <span className='text-red-500'>
+                              {currencyFormat(item.differenceToApply)}
+                            </span>{' '}
+                            untuk pakai promo ini
+                          </p>
+                        </div>
+                      )}
+
+                    {!item.canApply &&
+                      item.applyStatus === 'MPA' &&
+                      item.manufactureNames === '' && (
+                        <div
+                          class='p-2 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400'
+                          role='alert'
+                        >
+                          <p>
+                            Tambah{' '}
+                            <span className='text-red-500'>
+                              {currencyFormat(item.differenceToApply)}
+                            </span>{' '}
+                            untuk pakai promo ini{' '}
+                          </p>
+                        </div>
+                      )}
+
+                    {!item.canApply &&
+                      item.has_flashsale_products &&
+                      item.apply_status === 'UM' && (
+                        <div
+                          class='p-2 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400'
+                          role='alert'
+                        >
+                          <p>Voucher tidak dapat di gabung dengan</p>
+                        </div>
+                      )}
+
                     <div className={`flex gap-x-3`}>
                       <div className='hidden md:w-[250px] md:block'>
                         <Image src={item.image} alt={item.name} className={`object-cover`} />
@@ -516,7 +591,7 @@ const Checkout = () => {
                             </label>
                           </div>
                         </div>
-                        <hr className='mt-3 my-4 border-gray_r-8' />
+                        <hr className='mt-2 my-2 border-gray_r-8' />
                         <div className='flex justify-between items-center'>
                           <p className='text-justify text-sm md:text-xs'>
                             Kode Voucher :{' '}
@@ -528,51 +603,30 @@ const Checkout = () => {
                             )}
                           </p>
                         </div>
+                        <div className='flex items-center mt-3'>
+                          <svg
+                            aria-hidden='true'
+                            fill='none'
+                            stroke='currentColor'
+                            stroke-width='1.5'
+                            viewBox='0 0 24 24'
+                            className='w-5 text-black'
+                          >
+                            <path
+                              d='M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z'
+                              stroke-linecap='round'
+                              stroke-linejoin='round'
+                            ></path>
+                          </svg>
+                          <span className='text-left ml-3 text-sm '>
+                            Berakhir dalam{' '}
+                            <span className='text-red-600'>{item.remainingTime}</span> lagi{' '}
+                          </span>
+                        </div>
                       </div>
                     </div>
                     <div className='mt-3'>
                       <p className='text-justify text-sm '>
-                        {!item.canApply &&
-                          item.applyStatus === 'MPA' &&
-                          item.manufactureNames != '' && (
-                            <p>
-                              Tambah produk{' '}
-                              <span className='text-red-500'>{item.manufactureNames}</span> senilai{' '}
-                              <span className='text-red-500'>
-                                {currencyFormat(item.differenceToApply)}
-                              </span>{' '}
-                              untuk pakai promo ini
-                            </p>
-                          )}
-                        {!item.canApply &&
-                          item.applyStatus === 'MPA' &&
-                          item.manufactureNames === '' && (
-                            <p>
-                              Tambah{' '}
-                              <span className='text-red-500'>
-                                {currencyFormat(item.differenceToApply)}
-                              </span>{' '}
-                              untuk pakai promo ini{' '}
-                            </p>
-                          )}
-                        {!item.canApply && item.applyStatus === 'UM' && (
-                          <p>
-                            Tambah produk{' '}
-                            <span className='text-red-500'>{item.manufactureNames}</span> senilai{' '}
-                            <span className='text-red-500'>
-                              {currencyFormat(item.minPurchaseAmount)}
-                            </span>{' '}
-                            untuk pakai promo ini
-                          </p>
-                        )}
-                        {item.canApply && (
-                          <p>
-                            Potensi potongan sebesar{' '}
-                            <span className='text-red-500'>
-                              {currencyFormat(item.discountVoucher)}
-                            </span>
-                          </p>
-                        )}
                         {/* {item.canApply === false
                           ? 'Tambah ' +
                             currencyFormat(item.differenceToApply) +
@@ -580,27 +634,6 @@ const Checkout = () => {
                           : 'Potensi potongan sebesar ' +
                             currencyFormat(hitungDiscountVoucher(item.code))} */}
                       </p>
-                      <hr className='mt-2 my-4 border-gray_r-8' />
-                      <div className='flex items-center'>
-                        <svg
-                          aria-hidden='true'
-                          fill='none'
-                          stroke='currentColor'
-                          stroke-width='1.5'
-                          viewBox='0 0 24 24'
-                          className='w-5 text-black'
-                        >
-                          <path
-                            d='M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z'
-                            stroke-linecap='round'
-                            stroke-linejoin='round'
-                          ></path>
-                        </svg>
-                        <span className='text-left ml-3 text-sm '>
-                          Berakhir dalam <span className='text-red-600'>{item.remainingTime}</span>{' '}
-                          lagi{' '}
-                        </span>
-                      </div>
                     </div>
                   </div>
                 </div>
-- 
cgit v1.2.3


From 77a5ab2d7dd9967e41d9c365e6e5dd45a2d32db2 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Fri, 4 Aug 2023 13:31:19 +0700
Subject: bugs fix voucher

---
 src/lib/checkout/components/Checkout.jsx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'src/lib/checkout/components/Checkout.jsx')

diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx
index 53ac63e1..c6ea73f2 100644
--- a/src/lib/checkout/components/Checkout.jsx
+++ b/src/lib/checkout/components/Checkout.jsx
@@ -107,7 +107,7 @@ const Checkout = () => {
   const voucher = async () => {
     if (!listVouchers) {
       try {
-        let dataVoucher = await getVoucher(auth?.id)
+        let dataVoucher = await getVoucher(auth?.id, query)
         SetListVoucher(dataVoucher)
       } finally {
         setLoadingVoucher(false)
@@ -115,7 +115,7 @@ const Checkout = () => {
     }
   }
   const VoucherCode = async (code) => {
-    let dataVoucher = await findVoucher(code, auth.id)
+    let dataVoucher = await findVoucher(code, auth.id, query)
     if (dataVoucher.length <= 0) {
       SetFindVoucher(1)
       return
@@ -427,7 +427,7 @@ const Checkout = () => {
 
           <hr className='mt-10 my-4 border-gray_r-10' />
           <div className=''>
-            {!loadingVoucher && listVouchers.length === 0 ? (
+            {!loadingVoucher && listVouchers?.length === 0 ? (
               <div className='flex items-center justify-center mt-4 mb-4'>
                 <div className='text-center'>
                   <h1 className='font-bold mb-4'>Tidak ada voucher tersedia</h1>
-- 
cgit v1.2.3


From 71748842100e833472c56194e57c309539478dd3 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Fri, 4 Aug 2023 14:30:21 +0700
Subject: cr voucher

---
 src/lib/checkout/components/Checkout.jsx | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

(limited to 'src/lib/checkout/components/Checkout.jsx')

diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx
index 9ffac61a..5265a794 100644
--- a/src/lib/checkout/components/Checkout.jsx
+++ b/src/lib/checkout/components/Checkout.jsx
@@ -490,7 +490,7 @@ const Checkout = () => {
                     <div className='absolute w-full h-full bg-gray_r-3/40 top-0 left-0 z-50' />
                   )}
 
-                  <div className={`border border-solid mb-5 w-full hover:cursor-pointer  p-4 `}>
+                  <div className={`border border-solid mb-5 w-full hover:cursor-pointer  p-2 pl-4 pr-4 `}>
                     {item.canApply && (
                       <div
                         class='p-2 mb-4 text-sm text-green-800 rounded-lg bg-green-50 dark:text-green-400'
@@ -504,12 +504,20 @@ const Checkout = () => {
                         </p>
                       </div>
                     )}
+                    {!item.canApply && item.applyStatus === 'MPA-HF' && (
+                      <div
+                        class='p-2 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400'
+                        role='alert'
+                      >
+                        <p className='text-xs'>Voucher tidak bisa digabung dengan promo lainya</p>
+                      </div>
+                    )}
                     {!item.canApply && item.applyStatus === 'UM' && (
                       <div
                         class='p-2 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400'
                         role='alert'
                       >
-                        <p>
+                        <p className='text-xs'>
                           Tambah produk{' '}
                           <span className='text-red-500'>{item.manufactureNames}</span> senilai{' '}
                           <span className='text-red-500'>
@@ -527,7 +535,7 @@ const Checkout = () => {
                           class='p-2 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400'
                           role='alert'
                         >
-                          <p>
+                          <p className='text-xs'>
                             Tambah produk{' '}
                             <span className='text-red-500'>{item.manufactureNames}</span> senilai{' '}
                             <span className='text-red-500'>
@@ -545,7 +553,7 @@ const Checkout = () => {
                           class='p-2 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400'
                           role='alert'
                         >
-                          <p>
+                          <p className='text-xs'>
                             Tambah{' '}
                             <span className='text-red-500'>
                               {currencyFormat(item.differenceToApply)}
@@ -554,18 +562,6 @@ const Checkout = () => {
                           </p>
                         </div>
                       )}
-
-                    {!item.canApply &&
-                      item.has_flashsale_products &&
-                      item.apply_status === 'UM' && (
-                        <div
-                          class='p-2 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400'
-                          role='alert'
-                        >
-                          <p>Voucher tidak dapat di gabung dengan</p>
-                        </div>
-                      )}
-
                     <div className={`flex gap-x-3`}>
                       <div className='hidden md:w-[250px] md:block'>
                         <Image src={item.image} alt={item.name} className={`object-cover`} />
-- 
cgit v1.2.3

