From 463a051646fe1dc70bebd05359381c393b951fff Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Thu, 2 May 2024 09:30:54 +0700
Subject: hotfix - validate stepapproval on mobile version

---
 src/lib/transaction/components/Transaction.jsx | 124 +++++++++++++++----------
 1 file changed, 77 insertions(+), 47 deletions(-)

(limited to 'src/lib/transaction/components/Transaction.jsx')

diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index 8f4b2038..b68bb4cd 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -37,8 +37,8 @@ import rejectApi from '../api/rejectApi';
 const Transaction = ({ id }) => {
   const auth = useAuth();
   const { transaction } = useTransaction({ id });
-  
-  const statusApprovalWeb = transaction.data?.approvalStep
+
+  const statusApprovalWeb = transaction.data?.approvalStep;
 
   const { queryAirwayBill } = useAirwayBill({ orderId: id });
   const [airwayBillPopup, setAirwayBillPopup] = useState(null);
@@ -78,7 +78,7 @@ const Transaction = ({ id }) => {
   const closeCancelTransaction = () => setCancelTransaction(false);
 
   const [rejectTransaction, setRejectTransaction] = useState(false);
-  
+
   const openRejectTransaction = () => setRejectTransaction(true);
   const closeRejectTransaction = () => setRejectTransaction(false);
   const submitCancelTransaction = async () => {
@@ -106,13 +106,13 @@ const Transaction = ({ id }) => {
     await aprpoveApi({ id });
     toast.success('Berhasil melanjutkan approval');
     transaction.refetch();
-  }
+  };
 
   const handleReject = async () => {
-   await rejectApi({ id });
-   closeRejectTransaction()
-   transaction.refetch();
-  }
+    await rejectApi({ id });
+    closeRejectTransaction();
+    transaction.refetch();
+  };
 
   const memoizeVariantGroupCard = useMemo(
     () => (
@@ -238,7 +238,13 @@ const Transaction = ({ id }) => {
 
         <MobileView>
           <div className='p-4'>
-            <StepApproval layer={2} status={'cancel'} className='ml-auto' />
+            {auth?.feature?.soApproval && (
+              <StepApproval
+                layer={statusApprovalWeb}
+                status={transaction?.data?.status}
+                className='ml-auto'
+              />
+            )}
           </div>
           <div className='flex flex-col gap-y-4 p-4'>
             <DescriptionRow label='Status Transaksi'>
@@ -359,33 +365,43 @@ const Transaction = ({ id }) => {
           <Divider />
 
           <div className='p-4 pt-0'>
-            {transaction.data?.status == 'draft' && auth?.feature.soApproval && (
-              <div className='flex gap-x-2'>
-                <button
-                  className='btn-yellow w-full'
-                  onClick={checkout}
-                  disabled={
-                    transaction.data?.status === 'cancel' ? true : false  || auth?.webRole === statusApprovalWeb ? true : false
-                  }
-                >
-                  Approve
-                </button>
-                <button
-                  className='btn-solid-red px-7 w-full'
-                  onClick={checkout}
-                  disabled={
-                    transaction.data?.status === 'cancel' ? true : false  || auth?.webRole === statusApprovalWeb ? true : false
-                  }
-                >
-                  Reject
+            {transaction.data?.status == 'draft' &&
+              auth?.feature.soApproval && (
+                <div className='flex gap-x-2'>
+                  <button
+                    className='btn-yellow w-full'
+                    onClick={checkout}
+                    disabled={
+                      transaction.data?.status === 'cancel'
+                        ? true
+                        : false || auth?.webRole === statusApprovalWeb
+                        ? true
+                        : false
+                    }
+                  >
+                    Approve
+                  </button>
+                  <button
+                    className='btn-solid-red px-7 w-full'
+                    onClick={checkout}
+                    disabled={
+                      transaction.data?.status === 'cancel'
+                        ? true
+                        : false || auth?.webRole === statusApprovalWeb
+                        ? true
+                        : false
+                    }
+                  >
+                    Reject
+                  </button>
+                </div>
+              )}
+            {transaction.data?.status == 'draft' &&
+              !auth?.feature?.soApproval && (
+                <button className='btn-yellow w-full mt-4' onClick={checkout}>
+                  Lanjutkan Transaksi
                 </button>
-              </div>
-            )}
-            {transaction.data?.status == 'draft' && !auth?.feature?.soApproval && (
-              <button className='btn-yellow w-full mt-4' onClick={checkout}>
-                Lanjutkan Transaksi
-              </button>
-            )}
+              )}
             <button
               className='btn-light w-full mt-4'
               disabled={transaction.data?.status != 'draft'}
@@ -439,13 +455,20 @@ const Transaction = ({ id }) => {
                   Download
                 </button>
                 {transaction.data?.status == 'draft' &&
-                  auth?.feature?.soApproval && auth?.webRole && (
+                  auth?.feature?.soApproval &&
+                  auth?.webRole && (
                     <div className='flex gap-x-2'>
                       <button
                         className='btn-yellow'
                         onClick={handleApproval}
                         disabled={
-                          transaction.data?.status === 'cancel' ? true : false || auth?.webRole === statusApprovalWeb ? true : false || statusApprovalWeb < 1 ? true : false
+                          transaction.data?.status === 'cancel'
+                            ? true
+                            : false || auth?.webRole === statusApprovalWeb
+                            ? true
+                            : false || statusApprovalWeb < 1
+                            ? true
+                            : false
                         }
                       >
                         Approve
@@ -454,7 +477,13 @@ const Transaction = ({ id }) => {
                         className='btn-solid-red px-7'
                         onClick={openRejectTransaction}
                         disabled={
-                          transaction.data?.status === 'cancel' ? true : false || auth?.webRole === statusApprovalWeb ? true : false  || statusApprovalWeb < 1 ? true : false
+                          transaction.data?.status === 'cancel'
+                            ? true
+                            : false || auth?.webRole === statusApprovalWeb
+                            ? true
+                            : false || statusApprovalWeb < 1
+                            ? true
+                            : false
                         }
                       >
                         Reject
@@ -467,15 +496,16 @@ const Transaction = ({ id }) => {
                       Lanjutkan Transaksi
                     </button>
                   )}
-                {transaction.data?.status != 'draft' &&  !auth?.feature.soApproval &&  (
-                  <button
-                    className='btn-light'
-                    disabled={transaction.data?.status != 'waiting'}
-                    onClick={openCancelTransaction}
-                  >
-                    Batalkan Transaksi
-                  </button>
-                )}
+                {transaction.data?.status != 'draft' &&
+                  !auth?.feature.soApproval && (
+                    <button
+                      className='btn-light'
+                      disabled={transaction.data?.status != 'waiting'}
+                      onClick={openCancelTransaction}
+                    >
+                      Batalkan Transaksi
+                    </button>
+                  )}
               </div>
 
               <div className='grid grid-cols-2 gap-x-6 mt-6'>
-- 
cgit v1.2.3


From 21d3c9cdc25477f5d07ff395a65f89430b7c9924 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Tue, 21 May 2024 14:54:08 +0700
Subject: delete discount field

---
 src/lib/transaction/components/Transaction.jsx | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'src/lib/transaction/components/Transaction.jsx')

diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index 8f4b2038..9b11f5bb 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -562,7 +562,7 @@ const Transaction = ({ id }) => {
                 <thead>
                   <tr>
                     <th>Nama Produk</th>
-                    <th>Diskon</th>
+                    {/* <th>Diskon</th> */}
                     <th>Jumlah</th>
                     <th>Harga</th>
                     <th>Subtotal</th>
@@ -605,18 +605,18 @@ const Transaction = ({ id }) => {
                           </div>
                         </div>
                       </td>
-                      <td>
+                      {/* <td>
                         {product.price.discountPercentage > 0
                           ? `${product.price.discountPercentage}%`
                           : ''}
-                      </td>
+                      </td> */}
                       <td>{product.quantity}</td>
                       <td>
-                        {product.price.discountPercentage > 0 && (
+                        {/* {product.price.discountPercentage > 0 && (
                           <div className='line-through mb-1 text-caption-1 text-gray_r-12/70'>
                             {currencyFormat(product.price.price)}
                           </div>
-                        )}
+                        )} */}
                         <div>{currencyFormat(product.price.priceDiscount)}</div>
                       </td>
                       <td>{currencyFormat(product.price.subtotal)}</td>
-- 
cgit v1.2.3


From f9f1fdf83c2b6ed5c1d85d7418d45aeed9b05c77 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 5 Jun 2024 15:24:42 +0700
Subject: <iman> add feature SNI-TKDR

---
 src/lib/transaction/components/Transaction.jsx | 71 +++++++++++++++++++++++++-
 1 file changed, 69 insertions(+), 2 deletions(-)

(limited to 'src/lib/transaction/components/Transaction.jsx')

diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index b68bb4cd..fb5fd0dd 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -2,7 +2,8 @@ import Spinner from '@/core/components/elements/Spinner/Spinner';
 import useTransaction from '../hooks/useTransaction';
 import TransactionStatusBadge from './TransactionStatusBadge';
 import Divider from '@/core/components/elements/Divider/Divider';
-import { useMemo, useRef, useState } from 'react';
+import { useEffect, useMemo, useRef, useState } from 'react';
+import ImageNext from 'next/image';
 import {
   downloadPurchaseOrder,
   downloadQuotation,
@@ -49,6 +50,44 @@ const Transaction = ({ id }) => {
   const [idAWB, setIdAWB] = useState(null);
   const openUploadPo = () => setUploadPo(true);
   const closeUploadPo = () => setUploadPo(false);
+  const [isSni, setIsSni] = useState(false);
+  const [isTkdn, setTkdn] = useState(false);
+
+  useEffect(() => {
+    const fetchSniData = async () => {
+      try {
+        const response = await fetch('URL_API_SNI');
+        const data = await response.json();
+        if (data && data.sni) {
+          setIsSni(true);
+        } else {
+          setIsSni(false);
+        }
+      } catch (error) {
+        console.error('Error fetching SNI data:', error);
+        setIsSni(false);
+      }
+    };
+    const fetchTkdnData = async () => {
+      try {
+        const response = await fetch('URL_API_TKDN');
+        const data = await response.json();
+        if (data && data.tkdn) {
+          setTkdn(true);
+        } else {
+          setTkdn(false);
+        }
+      } catch (error) {
+        console.error('Error fetching TKDN data:', error);
+        setTkdn(false);
+      }
+    };
+    fetchSniData();
+    fetchTkdnData();
+    return () => {
+    };
+  }, []);
+
   const submitUploadPo = async () => {
     const file = poFile.current.files[0];
     const name = poNumber.current.value;
@@ -610,11 +649,39 @@ const Transaction = ({ id }) => {
                           )}
                           className='w-[20%] flex-shrink-0'
                         >
-                          <Image
+                          
+                        <div className="relative">
+                        <Image
                             src={product?.parent?.image}
                             alt={product?.name}
                             className='object-contain object-center border border-gray_r-6 h-32 w-full rounded-md'
                           />
+            <div className="absolute top-0 right-4 flex  mt-3">
+              <div className="gambarB ">
+                {!isSni && (
+                  <ImageNext
+                    src="/images/sni-logo.png"
+                    alt="SNI Logo"
+                    className="w-2 h-4 object-contain object-top   sm:h-4"
+                    width={50}
+                    height={50}
+                  />
+                )}
+              </div>
+              <div className="gambarC  ">
+                {!isTkdn && (
+                  <ImageNext
+                    src="/images/TKDN.png"
+                    alt="TKDN"
+                    className="w-5 h-4 object-contain object-top  ml-1 sm:h-4"
+                    width={50}
+                    height={50}
+                  />
+                )}
+              </div>
+            </div>
+        </div>
+                          
                         </Link>
                         <div className='px-2 text-left'>
                           <Link
-- 
cgit v1.2.3


From 755b61a8a7a082cc13f7ecb4a79807f90e60b3d6 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 5 Jun 2024 16:50:38 +0700
Subject: <iman> add feature SNI-TKDN

---
 src/lib/transaction/components/Transaction.jsx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'src/lib/transaction/components/Transaction.jsx')

diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index fb5fd0dd..f3e2afb9 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -658,7 +658,7 @@ const Transaction = ({ id }) => {
                           />
             <div className="absolute top-0 right-4 flex  mt-3">
               <div className="gambarB ">
-                {!isSni && (
+                {product.isSni && (
                   <ImageNext
                     src="/images/sni-logo.png"
                     alt="SNI Logo"
@@ -669,7 +669,7 @@ const Transaction = ({ id }) => {
                 )}
               </div>
               <div className="gambarC  ">
-                {!isTkdn && (
+                {product.isTkdn && (
                   <ImageNext
                     src="/images/TKDN.png"
                     alt="TKDN"
-- 
cgit v1.2.3


From 68a3c897edef3f42a339d92ed8d663039f3ddfc7 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 6 Jun 2024 09:39:01 +0700
Subject: <iman> add feature SNI-TKDN

---
 src/lib/transaction/components/Transaction.jsx | 40 ++------------------------
 1 file changed, 3 insertions(+), 37 deletions(-)

(limited to 'src/lib/transaction/components/Transaction.jsx')

diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index f3e2afb9..9962b46e 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -50,43 +50,9 @@ const Transaction = ({ id }) => {
   const [idAWB, setIdAWB] = useState(null);
   const openUploadPo = () => setUploadPo(true);
   const closeUploadPo = () => setUploadPo(false);
-  const [isSni, setIsSni] = useState(false);
-  const [isTkdn, setTkdn] = useState(false);
-
-  useEffect(() => {
-    const fetchSniData = async () => {
-      try {
-        const response = await fetch('URL_API_SNI');
-        const data = await response.json();
-        if (data && data.sni) {
-          setIsSni(true);
-        } else {
-          setIsSni(false);
-        }
-      } catch (error) {
-        console.error('Error fetching SNI data:', error);
-        setIsSni(false);
-      }
-    };
-    const fetchTkdnData = async () => {
-      try {
-        const response = await fetch('URL_API_TKDN');
-        const data = await response.json();
-        if (data && data.tkdn) {
-          setTkdn(true);
-        } else {
-          setTkdn(false);
-        }
-      } catch (error) {
-        console.error('Error fetching TKDN data:', error);
-        setTkdn(false);
-      }
-    };
-    fetchSniData();
-    fetchTkdnData();
-    return () => {
-    };
-  }, []);
+ 
+
+  
 
   const submitUploadPo = async () => {
     const file = poFile.current.files[0];
-- 
cgit v1.2.3


From f287fc062c4ceb5039b5ca946da2e6854c27b007 Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Tue, 2 Jul 2024 14:55:14 +0700
Subject: add site on transactions list and transaction detial

---
 src/lib/transaction/components/Transaction.jsx | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

(limited to 'src/lib/transaction/components/Transaction.jsx')

diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index 9b11f5bb..30f1d902 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -37,7 +37,7 @@ import rejectApi from '../api/rejectApi';
 const Transaction = ({ id }) => {
   const auth = useAuth();
   const { transaction } = useTransaction({ id });
-  
+
   const statusApprovalWeb = transaction.data?.approvalStep
 
   const { queryAirwayBill } = useAirwayBill({ orderId: id });
@@ -78,7 +78,7 @@ const Transaction = ({ id }) => {
   const closeCancelTransaction = () => setCancelTransaction(false);
 
   const [rejectTransaction, setRejectTransaction] = useState(false);
-  
+
   const openRejectTransaction = () => setRejectTransaction(true);
   const closeRejectTransaction = () => setRejectTransaction(false);
   const submitCancelTransaction = async () => {
@@ -109,9 +109,9 @@ const Transaction = ({ id }) => {
   }
 
   const handleReject = async () => {
-   await rejectApi({ id });
-   closeRejectTransaction()
-   transaction.refetch();
+    await rejectApi({ id });
+    closeRejectTransaction()
+    transaction.refetch();
   }
 
   const memoizeVariantGroupCard = useMemo(
@@ -365,7 +365,7 @@ const Transaction = ({ id }) => {
                   className='btn-yellow w-full'
                   onClick={checkout}
                   disabled={
-                    transaction.data?.status === 'cancel' ? true : false  || auth?.webRole === statusApprovalWeb ? true : false
+                    transaction.data?.status === 'cancel' ? true : false || auth?.webRole === statusApprovalWeb ? true : false
                   }
                 >
                   Approve
@@ -374,7 +374,7 @@ const Transaction = ({ id }) => {
                   className='btn-solid-red px-7 w-full'
                   onClick={checkout}
                   disabled={
-                    transaction.data?.status === 'cancel' ? true : false  || auth?.webRole === statusApprovalWeb ? true : false
+                    transaction.data?.status === 'cancel' ? true : false || auth?.webRole === statusApprovalWeb ? true : false
                   }
                 >
                   Reject
@@ -454,7 +454,7 @@ const Transaction = ({ id }) => {
                         className='btn-solid-red px-7'
                         onClick={openRejectTransaction}
                         disabled={
-                          transaction.data?.status === 'cancel' ? true : false || auth?.webRole === statusApprovalWeb ? true : false  || statusApprovalWeb < 1 ? true : false
+                          transaction.data?.status === 'cancel' ? true : false || auth?.webRole === statusApprovalWeb ? true : false || statusApprovalWeb < 1 ? true : false
                         }
                       >
                         Reject
@@ -467,7 +467,7 @@ const Transaction = ({ id }) => {
                       Lanjutkan Transaksi
                     </button>
                   )}
-                {transaction.data?.status != 'draft' &&  !auth?.feature.soApproval &&  (
+                {transaction.data?.status != 'draft' && !auth?.feature.soApproval && (
                   <button
                     className='btn-light'
                     disabled={transaction.data?.status != 'waiting'}
@@ -490,7 +490,7 @@ const Transaction = ({ id }) => {
                   <div>Ketentuan Pembayaran</div>
                   <div>: {transaction?.data?.paymentTerm}</div>
 
-                  {!auth?.feature?.soApproval && (
+                  {!auth?.feature?.soApproval ? (
                     <>
                       <div>Purchase Order</div>
                       <div>
@@ -510,6 +510,11 @@ const Transaction = ({ id }) => {
                         </button>
                       </div>
                     </>
+                  ) : (
+                    <>
+                      <div>Site</div>
+                      <div>: {transaction?.data?.sitePartner}</div>
+                    </>
                   )}
                 </div>
               </div>
-- 
cgit v1.2.3


From dc204e9cdbcf7faf81dba825db608be2c918589d Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 9 Jul 2024 16:31:30 +0700
Subject: <iman? add button reject & logic

---
 src/lib/transaction/components/Transaction.jsx | 92 +++++++++++++++++++++++++-
 1 file changed, 90 insertions(+), 2 deletions(-)

(limited to 'src/lib/transaction/components/Transaction.jsx')

diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index 9b11f5bb..03c94ded 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -33,13 +33,17 @@ import useAuth from '@/core/hooks/useAuth';
 import StepApproval from './stepper';
 import aprpoveApi from '../api/approveApi';
 import rejectApi from '../api/rejectApi';
+import rejectProductApi from '../api/rejectProductApi';
+import { useRouter } from 'next/router';
 
 const Transaction = ({ id }) => {
+  const router = useRouter()
+  const [isModalOpen, setIsModalOpen] = useState(false);
+  const [selectedProduct, setSelectedProduct] = useState(null);
+  const [reason, setReason] = useState('');
   const auth = useAuth();
   const { transaction } = useTransaction({ id });
-  
   const statusApprovalWeb = transaction.data?.approvalStep
-
   const { queryAirwayBill } = useAirwayBill({ orderId: id });
   const [airwayBillPopup, setAirwayBillPopup] = useState(null);
 
@@ -151,6 +155,38 @@ const Transaction = ({ id }) => {
     setIdAWB(null);
   };
 
+  const openModal = (product) => {
+    setSelectedProduct(product);
+    setIsModalOpen(true);
+  };
+
+  const closeModal = () => {
+    setIsModalOpen(false);
+    setSelectedProduct(null);
+    setReason('');
+  };
+
+  const handleRejectProduct = async () => {
+    try{
+      if (!reason.trim()) {
+        toast.error('Masukkan alasan terlebih dahulu');
+        return;
+      }else{
+        let idSo = transaction?.data.id
+        let idProduct = selectedProduct?.id
+        await rejectProductApi({ idSo, idProduct, reason}); 
+        closeModal();
+        toast.success("Produk berhasil di reaject")
+        setTimeout(() => {
+          window.location.reload();
+        }, 1500); 
+      }
+    }catch(error){
+      toast.error('Gagal reject produk. Silakan coba lagi.');
+    }
+  };
+
+
   return (
     transaction.data?.name && (
       <>
@@ -566,6 +602,7 @@ const Transaction = ({ id }) => {
                     <th>Jumlah</th>
                     <th>Harga</th>
                     <th>Subtotal</th>
+                    <th></th>
                   </tr>
                 </thead>
                 <tbody>
@@ -620,10 +657,61 @@ const Transaction = ({ id }) => {
                         <div>{currencyFormat(product.price.priceDiscount)}</div>
                       </td>
                       <td>{currencyFormat(product.price.subtotal)}</td>
+                      {/* {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (transaction.data.isReaject == false) && ( */}
+                      {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (router.asPath.includes("/my/quotations/"))  && (
+                        <td>
+                          <button
+                            className="bg-red-500 text-white py-1 px-3 rounded"
+                            onClick={() => openModal(product)}
+                          >
+                            Reject
+                          </button>
+                        </td>
+                      )}
+                      {/* {transaction.data.isReaject && (
+                        <td>
+                          <button
+                            className="bg-gray-400 text-white py-1 px-3 rounded"
+                            onClick={() => openModal(product)}
+                            disabled
+                          >
+                            Direject
+                          </button>
+                        </td>
+                      )} */}
                     </tr>
                   ))}
                 </tbody>
               </table>
+              {isModalOpen && (
+                <div className='fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center'>
+                  <div className='bg-white p-4 rounded w-96
+                     ease-in-out opacity-100
+                    transform transition-transform duration-300  scale-100'>
+                    <h2 className='text-lg mb-2'>Berikan Alasan</h2>
+                    <textarea
+                      value={reason}
+                      onChange={(e) => setReason(e.target.value)}
+                      className='w-full p-2 border rounded'
+                      rows='4'
+                    ></textarea>
+                    <div className='mt-4 flex justify-end'>
+                      <button
+                        className='bg-gray-300 text-black py-1 px-3 rounded mr-2'
+                        onClick={closeModal}
+                      >
+                        Batal
+                      </button>
+                      <button
+                        className='bg-red-500 text-white py-1 px-3 rounded'
+                        onClick={handleRejectProduct}
+                      >
+                        Reject
+                      </button>
+                    </div>
+                  </div>
+                </div>
+              )}
 
               <div className='flex justify-end mt-4'>
                 <div className='w-1/4 grid grid-cols-2 gap-y-3 text-gray_r-12/80'>
-- 
cgit v1.2.3


From e3d0de0ba20eee9d53e95c5525907b099d2b5b04 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 10 Jul 2024 14:20:29 +0700
Subject: <iman> update reaject button & component position

---
 src/lib/transaction/components/Transaction.jsx | 316 ++++++++++++++++---------
 1 file changed, 207 insertions(+), 109 deletions(-)

(limited to 'src/lib/transaction/components/Transaction.jsx')

diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index 03c94ded..8e7cede0 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -143,6 +143,15 @@ const Transaction = ({ id }) => {
     [transaction.data]
   );
 
+  const memoizeVariantGroupCardReject = useMemo(
+    () => (
+      <div className='p-4 pt-0 flex flex-col gap-y-3'>
+        <VariantGroupCard variants={transaction.data?.productsRejectLine} buyMore />
+      </div>
+    ),
+    [transaction.data]
+  );
+
   if (transaction.isLoading) {
     return (
       <div className='flex justify-center my-6'>
@@ -176,7 +185,7 @@ const Transaction = ({ id }) => {
         let idProduct = selectedProduct?.id
         await rejectProductApi({ idSo, idProduct, reason}); 
         closeModal();
-        toast.success("Produk berhasil di reaject")
+        toast.success("Produk berhasil di reject")
         setTimeout(() => {
           window.location.reload();
         }, 1500); 
@@ -329,6 +338,37 @@ const Transaction = ({ id }) => {
 
           <Divider />
 
+          <div className='p-4'>
+            <p className='font-medium'>Invoice</p>
+            <div className='flex flex-col gap-y-3 mt-4'>
+              {transaction.data?.invoices?.map((invoice, index) => (
+                <Link href={`/my/invoices/${invoice.id}`} key={index}>
+                  <div className='shadow rounded-md p-4 text-gray_r-12 font-normal flex justify-between'>
+                    <div>
+                      <p className='mb-2'>{invoice?.name}</p>
+                      <div className='flex items-center gap-x-1'>
+                        {invoice.amountResidual > 0 ? (
+                          <div className='badge-red'>Belum Lunas</div>
+                        ) : (
+                          <div className='badge-green'>Lunas</div>
+                        )}
+                        <p className='text-caption-2 text-gray_r-11'>
+                          {currencyFormat(invoice.amountTotal)}
+                        </p>
+                      </div>
+                    </div>
+                    <ChevronRightIcon className='w-5 stroke-2' />
+                  </div>
+                </Link>
+              ))}
+              {transaction.data?.invoices?.length === 0 && (
+                <div className='badge-red text-sm px-2'>Belum ada invoice</div>
+              )}
+            </div>
+          </div>
+
+          <Divider />
+
           {!auth?.feature.soApproval && (
             <div className='p-4 flex flex-col gap-y-4'>
               <DescriptionRow label='Purchase Order'>
@@ -354,8 +394,20 @@ const Transaction = ({ id }) => {
           <Divider />
 
           <div className='font-medium p-4'>Detail Produk</div>
+          {transaction?.data?.products.length > 0? (
+            <div>
+              {memoizeVariantGroupCard}
+            </div>
+          ) : (
+            <div className='badge-red text-sm px-2 ml-4'>Semua produk telah di reject</div>
+            )}
 
-          {memoizeVariantGroupCard}
+          {transaction?.data?.productsRejectLine.length > 0 && (
+            <div>
+              <div className='font-medium p-4'>Detail Produk Reject</div>
+              {memoizeVariantGroupCardReject}
+            </div>
+          )}
 
           <Divider />
 
@@ -363,37 +415,6 @@ const Transaction = ({ id }) => {
 
           <Divider />
 
-          <div className='p-4'>
-            <p className='font-medium'>Invoice</p>
-            <div className='flex flex-col gap-y-3 mt-4'>
-              {transaction.data?.invoices?.map((invoice, index) => (
-                <Link href={`/my/invoices/${invoice.id}`} key={index}>
-                  <div className='shadow rounded-md p-4 text-gray_r-12 font-normal flex justify-between'>
-                    <div>
-                      <p className='mb-2'>{invoice?.name}</p>
-                      <div className='flex items-center gap-x-1'>
-                        {invoice.amountResidual > 0 ? (
-                          <div className='badge-red'>Belum Lunas</div>
-                        ) : (
-                          <div className='badge-green'>Lunas</div>
-                        )}
-                        <p className='text-caption-2 text-gray_r-11'>
-                          {currencyFormat(invoice.amountTotal)}
-                        </p>
-                      </div>
-                    </div>
-                    <ChevronRightIcon className='w-5 stroke-2' />
-                  </div>
-                </Link>
-              ))}
-              {transaction.data?.invoices?.length === 0 && (
-                <div className='badge-red text-sm px-2'>Belum ada invoice</div>
-              )}
-            </div>
-          </div>
-
-          <Divider />
-
           <div className='p-4 pt-0'>
             {transaction.data?.status == 'draft' && auth?.feature.soApproval && (
               <div className='flex gap-x-2'>
@@ -561,51 +582,83 @@ const Transaction = ({ id }) => {
                   />
                 </div>
               </div>
-
-              <div className='text-h-sm font-semibold mt-10 mb-4'>
-                Pengiriman
-              </div>
-              <div className='grid grid-cols-3 gap-1'>
-                {transaction?.data?.pickings?.map((airway) => (
-                  <button
-                    className='shadow rounded-md p-3 text-gray_r-12 font-normal flex justify-between items-center text-left'
-                    key={airway?.id}
-                    onClick={() => setIdAWB(airway?.id)}
-                  >
-                    <div>
-                      <span className='text-sm text-gray_r-11'>
-                        No Resi : {airway?.trackingNumber || '-'}{' '}
-                      </span>
-                      <p className='mt-1 font-medium'>{airway?.name}</p>
-                    </div>
-                    <div className='flex gap-x-2'>
-                      <div className='text-sm text-gray-600 badge-green leading-[1.5] mt-1'>
-                        {airway?.delivered ? 'Pesanan Tiba' : 'Sedang Dikirim'}
-                      </div>
-                      <ChevronRightIcon className='w-5 stroke-2' />
+              <div className='flex '>
+                <div className='w-1/2'>
+                  <div className='text-h-sm font-semibold mt-10 mb-4'>
+                    Pengiriman
+                  </div>
+                    {transaction?.data?.pickings.length == 0 && (
+                      <div className='badge-red text-sm'>Belum ada pengiriman</div>
+                    )}
+                  <div className='grid grid-cols-1 gap-1 w-2/3'>
+                    {transaction?.data?.pickings?.map((airway) => (
+                      <button
+                        className='shadow rounded-md p-3 text-gray_r-12 font-normal flex justify-between items-center text-left h-20'
+                        key={airway?.id}
+                        onClick={() => setIdAWB(airway?.id)}
+                      >
+                        <div>
+                          <span className='text-sm text-gray_r-11'>
+                            No Resi : {airway?.trackingNumber || '-'}{' '}
+                          </span>
+                          <p className='mt-1 font-medium'>{airway?.name}</p>
+                        </div>
+                        <div className='flex gap-x-2'>
+                          <div className='text-sm text-gray-600 badge-green leading-[1.5] mt-1'>
+                            {airway?.delivered ? 'Pesanan Tiba' : 'Sedang Dikirim'}
+                          </div>
+                          <ChevronRightIcon className='w-5 stroke-2' />
+                        </div>
+                      </button>
+                    ))}
+                  </div>
+                </div>
+                <div className='invoice w-1/2 '>
+                  <div className='text-h-sm font-semibold mt-10 mb-4 '>Invoice</div>
+                      {transaction.data?.invoices?.length === 0 && (
+                        <div className='badge-red text-sm'>Belum ada invoice</div>
+                      )}
+                    <div className='grid grid-cols-1 gap-1 w-2/3 '>
+                      {transaction.data?.invoices?.map((invoice, index) => (
+                        <Link href={`/my/invoices/${invoice.id}`} key={index}>
+                          <div className='shadow rounded-md p-4 text-gray_r-12 font-normal flex justify-between'>
+                            <div>
+                              <p className='mb-1'>{invoice?.name}</p>
+                              <div className='flex items-center gap-x-1'>
+                                {invoice.amountResidual > 0 ? (
+                                  <div className='badge-red'>Belum Lunas</div>
+                                ) : (
+                                  <div className='badge-green'>Lunas</div>
+                                )}
+                                <p className='text-caption-2 text-gray_r-11'>
+                                  {currencyFormat(invoice.amountTotal)}
+                                </p>
+                              </div>
+                            </div>
+                            <ChevronRightIcon className='w-5 stroke-2' />
+                          </div>
+                        </Link>
+                      ))}
                     </div>
-                  </button>
-                ))}
+                </div>
               </div>
-              {transaction?.data?.pickings.length == 0 && (
-                <div className='badge-red text-sm'>Belum ada pengiriman</div>
-              )}
 
-              <div className='text-h-sm font-semibold mt-10 mb-4'>
+              <div className='text-h-sm font-semibold mt-4 mb-4'>
                 Rincian Pembelian
               </div>
-              <table className='table-data'>
-                <thead>
-                  <tr>
-                    <th>Nama Produk</th>
-                    {/* <th>Diskon</th> */}
-                    <th>Jumlah</th>
-                    <th>Harga</th>
-                    <th>Subtotal</th>
-                    <th></th>
-                  </tr>
-                </thead>
-                <tbody>
+              {transaction?.data?.products?.length > 0? (
+                <table className='table-data'>
+                  <thead>
+                    <tr>
+                      <th>Nama Produk</th>
+                      {/* <th>Diskon</th> */}
+                      <th>Jumlah</th>
+                      <th>Harga</th>
+                      <th>Subtotal</th>
+                      <th></th>
+                    </tr>
+                  </thead>
+                  <tbody>
                   {transaction?.data?.products?.map((product) => (
                     <tr key={product.id}>
                       <td className='flex'>
@@ -668,21 +721,14 @@ const Transaction = ({ id }) => {
                           </button>
                         </td>
                       )}
-                      {/* {transaction.data.isReaject && (
-                        <td>
-                          <button
-                            className="bg-gray-400 text-white py-1 px-3 rounded"
-                            onClick={() => openModal(product)}
-                            disabled
-                          >
-                            Direject
-                          </button>
-                        </td>
-                      )} */}
                     </tr>
                   ))}
                 </tbody>
               </table>
+              ) : (
+                <div className='badge-red text-sm'>Semua produk telah di reject</div>
+              )}
+              
               {isModalOpen && (
                 <div className='fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center'>
                   <div className='bg-white p-4 rounded w-96
@@ -713,6 +759,7 @@ const Transaction = ({ id }) => {
                 </div>
               )}
 
+            {transaction?.data?.products?.map((product) => (
               <div className='flex justify-end mt-4'>
                 <div className='w-1/4 grid grid-cols-2 gap-y-3 text-gray_r-12/80'>
                   <div className='text-right'>Subtotal</div>
@@ -738,33 +785,84 @@ const Transaction = ({ id }) => {
                   </div>
                 </div>
               </div>
+            ))}
 
-              <div className='text-h-sm font-semibold mt-10 mb-4'>Invoice</div>
-              <div className='grid grid-cols-3 gap-4'>
-                {transaction.data?.invoices?.map((invoice, index) => (
-                  <Link href={`/my/invoices/${invoice.id}`} key={index}>
-                    <div className='shadow rounded-md p-4 text-gray_r-12 font-normal flex justify-between'>
-                      <div>
-                        <p className='mb-2'>{invoice?.name}</p>
-                        <div className='flex items-center gap-x-1'>
-                          {invoice.amountResidual > 0 ? (
-                            <div className='badge-red'>Belum Lunas</div>
-                          ) : (
-                            <div className='badge-green'>Lunas</div>
-                          )}
-                          <p className='text-caption-2 text-gray_r-11'>
-                            {currencyFormat(invoice.amountTotal)}
-                          </p>
-                        </div>
-                      </div>
-                      <ChevronRightIcon className='w-5 stroke-2' />
-                    </div>
-                  </Link>
-                ))}
-              </div>
-              {transaction.data?.invoices?.length === 0 && (
-                <div className='badge-red text-sm'>Belum ada invoice</div>
+
+
+              {transaction?.data?.productsRejectLine.length > 0 && (
+                  <div className='text-h-sm font-semibold mt-10 mb-4'>
+                    Rincian Produk Reject
+                  </div>
+              )}
+              {transaction?.data?.productsRejectLine.length > 0 && (
+                  <table className='table-data'>
+                    <thead>
+                      <tr>
+                        <th>Nama Produk</th>
+                        {/* <th>Diskon</th> */}
+                        <th>Jumlah</th>
+                        <th>Harga</th>
+                        <th>Subtotal</th>
+                      </tr>
+                    </thead>
+                    <tbody>
+                      {transaction?.data?.productsRejectLine?.map((product) => (
+                        <tr key={product.id}>
+                          <td className='flex'>
+                            <Link
+                              href={createSlug(
+                                '/shop/product/',
+                                product?.parent.name,
+                                product?.parent.id
+                              )}
+                              className='w-[20%] flex-shrink-0'
+                            >
+                              <Image
+                                src={product?.parent?.image}
+                                alt={product?.name}
+                                className='object-contain object-center border border-gray_r-6 h-32 w-full rounded-md'
+                              />
+                            </Link>
+                            <div className='px-2 text-left'>
+                              <Link
+                                href={createSlug(
+                                  '/shop/product/',
+                                  product?.parent.name,
+                                  product?.parent.id
+                                )}
+                                className='line-clamp-2 leading-6 !text-gray_r-12 font-normal'
+                              >
+                                {product?.parent?.name}
+                              </Link>
+                              <div className='text-gray_r-11 mt-2'>
+                                {product?.code}{' '}
+                                {product?.attributes.length > 0
+                                  ? `| ${product?.attributes.join(', ')}`
+                                  : ''}
+                              </div>
+                            </div>
+                          </td>
+                          {/* <td>
+                            {product.price.discountPercentage > 0
+                              ? `${product.price.discountPercentage}%`
+                              : ''}
+                          </td> */}
+                          <td>{product.quantity}</td>
+                          <td>
+                            {/* {product.price.discountPercentage > 0 && (
+                              <div className='line-through mb-1 text-caption-1 text-gray_r-12/70'>
+                                {currencyFormat(product.price.price)}
+                              </div>
+                            )} */}
+                            <div>{currencyFormat(product.price.priceDiscount)}</div>
+                          </td>
+                          <td>{currencyFormat(product.quantity * product.price.priceDiscount)}</td>
+                        </tr>
+                      ))}
+                    </tbody>
+                  </table>
               )}
+              
             </div>
           </div>
         </DesktopView>
-- 
cgit v1.2.3


From 91fae67a9fdece78f0d0fbf4230472577b6260c6 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 11 Jul 2024 14:58:55 +0700
Subject: <iman> add key && update reject button by status quotation && add
 image reject

---
 src/lib/transaction/components/Transaction.jsx | 149 +++++++++++++------------
 1 file changed, 79 insertions(+), 70 deletions(-)

(limited to 'src/lib/transaction/components/Transaction.jsx')

diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index 8e7cede0..b099ffa7 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -1,4 +1,6 @@
 import Spinner from '@/core/components/elements/Spinner/Spinner';
+import NextImage from 'next/image';
+import rejectImage from "../../../../public/images/reject.png"
 import useTransaction from '../hooks/useTransaction';
 import TransactionStatusBadge from './TransactionStatusBadge';
 import Divider from '@/core/components/elements/Divider/Divider';
@@ -646,85 +648,85 @@ const Transaction = ({ id }) => {
               <div className='text-h-sm font-semibold mt-4 mb-4'>
                 Rincian Pembelian
               </div>
-              {transaction?.data?.products?.length > 0? (
-                <table className='table-data'>
-                  <thead>
-                    <tr>
-                      <th>Nama Produk</th>
-                      {/* <th>Diskon</th> */}
-                      <th>Jumlah</th>
-                      <th>Harga</th>
-                      <th>Subtotal</th>
-                      <th></th>
-                    </tr>
-                  </thead>
-                  <tbody>
-                  {transaction?.data?.products?.map((product) => (
-                    <tr key={product.id}>
-                      <td className='flex'>
-                        <Link
-                          href={createSlug(
-                            '/shop/product/',
-                            product?.parent.name,
-                            product?.parent.id
-                          )}
-                          className='w-[20%] flex-shrink-0'
-                        >
-                          <Image
-                            src={product?.parent?.image}
-                            alt={product?.name}
-                            className='object-contain object-center border border-gray_r-6 h-32 w-full rounded-md'
-                          />
-                        </Link>
-                        <div className='px-2 text-left'>
+                {transaction?.data?.products?.length > 0? (
+                  <table className='table-data'>
+                    <thead>
+                      <tr>
+                        <th>Nama Produk</th>
+                        {/* <th>Diskon</th> */}
+                        <th>Jumlah</th>
+                        <th>Harga</th>
+                        <th>Subtotal</th>
+                        <th></th>
+                      </tr>
+                    </thead>
+                    <tbody>
+                    {transaction?.data?.products?.map((product) => (
+                      <tr key={product.id}>
+                        <td className='flex'>
                           <Link
                             href={createSlug(
                               '/shop/product/',
                               product?.parent.name,
                               product?.parent.id
                             )}
-                            className='line-clamp-2 leading-6 !text-gray_r-12 font-normal'
+                            className='w-[20%] flex-shrink-0'
                           >
-                            {product?.parent?.name}
+                            <Image
+                              src={product?.parent?.image}
+                              alt={product?.name}
+                              className='object-contain object-center border border-gray_r-6 h-32 w-full rounded-md'
+                            />
                           </Link>
-                          <div className='text-gray_r-11 mt-2'>
-                            {product?.code}{' '}
-                            {product?.attributes.length > 0
-                              ? `| ${product?.attributes.join(', ')}`
-                              : ''}
-                          </div>
-                        </div>
-                      </td>
-                      {/* <td>
-                        {product.price.discountPercentage > 0
-                          ? `${product.price.discountPercentage}%`
-                          : ''}
-                      </td> */}
-                      <td>{product.quantity}</td>
-                      <td>
-                        {/* {product.price.discountPercentage > 0 && (
-                          <div className='line-through mb-1 text-caption-1 text-gray_r-12/70'>
-                            {currencyFormat(product.price.price)}
+                          <div className='px-2 text-left'>
+                            <Link
+                              href={createSlug(
+                                '/shop/product/',
+                                product?.parent.name,
+                                product?.parent.id
+                              )}
+                              className='line-clamp-2 leading-6 !text-gray_r-12 font-normal'
+                            >
+                              {product?.parent?.name}
+                            </Link>
+                            <div className='text-gray_r-11 mt-2'>
+                              {product?.code}{' '}
+                              {product?.attributes.length > 0
+                                ? `| ${product?.attributes.join(', ')}`
+                                : ''}
+                            </div>
                           </div>
-                        )} */}
-                        <div>{currencyFormat(product.price.priceDiscount)}</div>
-                      </td>
-                      <td>{currencyFormat(product.price.subtotal)}</td>
-                      {/* {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (transaction.data.isReaject == false) && ( */}
-                      {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (router.asPath.includes("/my/quotations/"))  && (
+                        </td>
+                        {/* <td>
+                          {product.price.discountPercentage > 0
+                            ? `${product.price.discountPercentage}%`
+                            : ''}
+                        </td> */}
+                        <td>{product.quantity}</td>
                         <td>
-                          <button
-                            className="bg-red-500 text-white py-1 px-3 rounded"
-                            onClick={() => openModal(product)}
-                          >
-                            Reject
-                          </button>
+                          {/* {product.price.discountPercentage > 0 && (
+                            <div className='line-through mb-1 text-caption-1 text-gray_r-12/70'>
+                              {currencyFormat(product.price.price)}
+                            </div>
+                          )} */}
+                          <div>{currencyFormat(product.price.priceDiscount)}</div>
                         </td>
-                      )}
-                    </tr>
-                  ))}
-                </tbody>
-              </table>
+                        <td>{currencyFormat(product.price.subtotal)}</td>
+                        {/* {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (transaction.data.isReaject == false) && ( */}
+                        {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) &&  (router.asPath.includes("/my/quotations/"))  && transaction.data?.status == 'draft' && (
+                          <td>
+                            <button
+                              className="bg-red-500 text-white py-1 px-3 rounded"
+                              onClick={() => openModal(product)}
+                            >
+                              Reject
+                            </button>
+                          </td>
+                        )}
+                      </tr>
+                    ))}
+                  </tbody>
+                </table>
               ) : (
                 <div className='badge-red text-sm'>Semua produk telah di reject</div>
               )}
@@ -856,13 +858,20 @@ const Transaction = ({ id }) => {
                             )} */}
                             <div>{currencyFormat(product.price.priceDiscount)}</div>
                           </td>
-                          <td>{currencyFormat(product.quantity * product.price.priceDiscount)}</td>
+                          <td className='flex justify-center'>
+                            <NextImage
+                              src={rejectImage}
+                              alt='Reject'
+                              width={90}
+                              height={30}
+                            /> 
+                          </td>
                         </tr>
                       ))}
                     </tbody>
                   </table>
               )}
-              
+                           
             </div>
           </div>
         </DesktopView>
-- 
cgit v1.2.3


From 1b9aeada3b663128f7c221342143cdb687b6e71f Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 11 Jul 2024 15:26:16 +0700
Subject: <iman> add key on map

---
 src/lib/transaction/components/Transaction.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/lib/transaction/components/Transaction.jsx')

diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index b099ffa7..97b8a507 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -762,7 +762,7 @@ const Transaction = ({ id }) => {
               )}
 
             {transaction?.data?.products?.map((product) => (
-              <div className='flex justify-end mt-4'>
+              <div className='flex justify-end mt-4' key={product.id}>
                 <div className='w-1/4 grid grid-cols-2 gap-y-3 text-gray_r-12/80'>
                   <div className='text-right'>Subtotal</div>
                   <div className='text-right font-medium'>
-- 
cgit v1.2.3


From 564cdef1d0d310fd85a96447151172febe337ef9 Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Wed, 7 Aug 2024 15:10:16 +0700
Subject: bugfix upload po

---
 src/lib/transaction/components/Transaction.jsx | 400 +++++++++++++------------
 1 file changed, 213 insertions(+), 187 deletions(-)

(limited to 'src/lib/transaction/components/Transaction.jsx')

diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index 9bef895a..85f6163b 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -1,6 +1,6 @@
 import Spinner from '@/core/components/elements/Spinner/Spinner';
 import NextImage from 'next/image';
-import rejectImage from "../../../../public/images/reject.png"
+import rejectImage from '../../../../public/images/reject.png';
 import useTransaction from '../hooks/useTransaction';
 import TransactionStatusBadge from './TransactionStatusBadge';
 import Divider from '@/core/components/elements/Divider/Divider';
@@ -40,7 +40,7 @@ import rejectProductApi from '../api/rejectProductApi';
 import { useRouter } from 'next/router';
 
 const Transaction = ({ id }) => {
-  const router = useRouter()
+  const router = useRouter();
   const [isModalOpen, setIsModalOpen] = useState(false);
   const [selectedProduct, setSelectedProduct] = useState(null);
   const [reason, setReason] = useState('');
@@ -152,7 +152,10 @@ const Transaction = ({ id }) => {
   const memoizeVariantGroupCardReject = useMemo(
     () => (
       <div className='p-4 pt-0 flex flex-col gap-y-3'>
-        <VariantGroupCard variants={transaction.data?.productsRejectLine} buyMore />
+        <VariantGroupCard
+          variants={transaction.data?.productsRejectLine}
+          buyMore
+        />
       </div>
     ),
     [transaction.data]
@@ -182,26 +185,25 @@ const Transaction = ({ id }) => {
   };
 
   const handleRejectProduct = async () => {
-    try{
+    try {
       if (!reason.trim()) {
         toast.error('Masukkan alasan terlebih dahulu');
         return;
-      }else{
-        let idSo = transaction?.data.id
-        let idProduct = selectedProduct?.id
-        await rejectProductApi({ idSo, idProduct, reason}); 
+      } else {
+        let idSo = transaction?.data.id;
+        let idProduct = selectedProduct?.id;
+        await rejectProductApi({ idSo, idProduct, reason });
         closeModal();
-        toast.success("Produk berhasil di reject")
+        toast.success('Produk berhasil di reject');
         setTimeout(() => {
           window.location.reload();
-        }, 1500); 
+        }, 1500);
       }
-    }catch(error){
+    } catch (error) {
       toast.error('Gagal reject produk. Silakan coba lagi.');
     }
   };
 
-
   return (
     transaction.data?.name && (
       <>
@@ -390,14 +392,20 @@ const Transaction = ({ id }) => {
                 <p className='text-gray_r-11 leading-none'>Dokumen PO</p>
                 <button
                   type='button'
-                  className='btn-light py-1.5 px-3 ml-auto'
+                  className='inline-block text-danger-500'
                   onClick={
                     transaction.data?.purchaseOrderFile
                       ? () => downloadPurchaseOrder(transaction.data)
-                      : openUploadPo
+                      : transaction?.data.invoices.length < 1
+                      ? openUploadPo
+                      : ''
                   }
                 >
-                  {transaction.data?.purchaseOrderFile ? 'Download' : 'Upload'}
+                  {transaction?.data?.purchaseOrderFile
+                    ? 'Download'
+                    : transaction?.data.invoices.length < 1
+                    ? 'Upload'
+                    : '-'}
                 </button>
               </div>
             </div>
@@ -406,13 +414,13 @@ const Transaction = ({ id }) => {
           <Divider />
 
           <div className='font-medium p-4'>Detail Produk</div>
-          {transaction?.data?.products.length > 0? (
-            <div>
-              {memoizeVariantGroupCard}
-            </div>
+          {transaction?.data?.products.length > 0 ? (
+            <div>{memoizeVariantGroupCard}</div>
           ) : (
-            <div className='badge-red text-sm px-2 ml-4'>Semua produk telah di reject</div>
-            )}
+            <div className='badge-red text-sm px-2 ml-4'>
+              Semua produk telah di reject
+            </div>
+          )}
 
           {transaction?.data?.productsRejectLine.length > 0 && (
             <div>
@@ -594,12 +602,16 @@ const Transaction = ({ id }) => {
                           onClick={
                             transaction.data?.purchaseOrderFile
                               ? () => downloadPurchaseOrder(transaction.data)
-                              : openUploadPo
+                              : transaction?.data.invoices.length < 1
+                              ? openUploadPo
+                              : ''
                           }
                         >
                           {transaction?.data?.purchaseOrderFile
                             ? 'Download'
-                            : 'Upload'}
+                            : transaction?.data.invoices.length < 1
+                            ? 'Upload'
+                            : '-'}
                         </button>
                       </div>
                     </>
@@ -628,9 +640,11 @@ const Transaction = ({ id }) => {
                   <div className='text-h-sm font-semibold mt-10 mb-4'>
                     Pengiriman
                   </div>
-                    {transaction?.data?.pickings.length == 0 && (
-                      <div className='badge-red text-sm'>Belum ada pengiriman</div>
-                    )}
+                  {transaction?.data?.pickings.length == 0 && (
+                    <div className='badge-red text-sm'>
+                      Belum ada pengiriman
+                    </div>
+                  )}
                   <div className='grid grid-cols-1 gap-1 w-2/3'>
                     {transaction?.data?.pickings?.map((airway) => (
                       <button
@@ -646,7 +660,9 @@ const Transaction = ({ id }) => {
                         </div>
                         <div className='flex gap-x-2'>
                           <div className='text-sm text-gray-600 badge-green leading-[1.5] mt-1'>
-                            {airway?.delivered ? 'Pesanan Tiba' : 'Sedang Dikirim'}
+                            {airway?.delivered
+                              ? 'Pesanan Tiba'
+                              : 'Sedang Dikirim'}
                           </div>
                           <ChevronRightIcon className='w-5 stroke-2' />
                         </div>
@@ -655,51 +671,53 @@ const Transaction = ({ id }) => {
                   </div>
                 </div>
                 <div className='invoice w-1/2 '>
-                  <div className='text-h-sm font-semibold mt-10 mb-4 '>Invoice</div>
-                      {transaction.data?.invoices?.length === 0 && (
-                        <div className='badge-red text-sm'>Belum ada invoice</div>
-                      )}
-                    <div className='grid grid-cols-1 gap-1 w-2/3 '>
-                      {transaction.data?.invoices?.map((invoice, index) => (
-                        <Link href={`/my/invoices/${invoice.id}`} key={index}>
-                          <div className='shadow rounded-md p-4 text-gray_r-12 font-normal flex justify-between'>
-                            <div>
-                              <p className='mb-1'>{invoice?.name}</p>
-                              <div className='flex items-center gap-x-1'>
-                                {invoice.amountResidual > 0 ? (
-                                  <div className='badge-red'>Belum Lunas</div>
-                                ) : (
-                                  <div className='badge-green'>Lunas</div>
-                                )}
-                                <p className='text-caption-2 text-gray_r-11'>
-                                  {currencyFormat(invoice.amountTotal)}
-                                </p>
-                              </div>
+                  <div className='text-h-sm font-semibold mt-10 mb-4 '>
+                    Invoice
+                  </div>
+                  {transaction.data?.invoices?.length === 0 && (
+                    <div className='badge-red text-sm'>Belum ada invoice</div>
+                  )}
+                  <div className='grid grid-cols-1 gap-1 w-2/3 '>
+                    {transaction.data?.invoices?.map((invoice, index) => (
+                      <Link href={`/my/invoices/${invoice.id}`} key={index}>
+                        <div className='shadow rounded-md p-4 text-gray_r-12 font-normal flex justify-between'>
+                          <div>
+                            <p className='mb-1'>{invoice?.name}</p>
+                            <div className='flex items-center gap-x-1'>
+                              {invoice.amountResidual > 0 ? (
+                                <div className='badge-red'>Belum Lunas</div>
+                              ) : (
+                                <div className='badge-green'>Lunas</div>
+                              )}
+                              <p className='text-caption-2 text-gray_r-11'>
+                                {currencyFormat(invoice.amountTotal)}
+                              </p>
                             </div>
-                            <ChevronRightIcon className='w-5 stroke-2' />
                           </div>
-                        </Link>
-                      ))}
-                    </div>
+                          <ChevronRightIcon className='w-5 stroke-2' />
+                        </div>
+                      </Link>
+                    ))}
+                  </div>
                 </div>
               </div>
 
               <div className='text-h-sm font-semibold mt-4 mb-4'>
                 Rincian Pembelian
               </div>
-                {transaction?.data?.products?.length > 0? (
-                  <table className='table-data'>
-                    <thead>
-                      <tr>
-                        <th>Nama Produk</th>
-                        {/* <th>Diskon</th> */}
-                        <th>Jumlah</th>
-                        <th>Harga</th>
-                        <th>Subtotal</th>
-                        <th></th>
-                      </tr>
-                    </thead>
-                    <tbody>
+              {transaction?.data?.products?.length > 0 ? (
+                <table className='table-data'>
+                  <thead>
+                    <tr>
+                      <th>Nama Produk</th>
+                      {/* <th>Diskon</th> */}
+                      <th>Jumlah</th>
+                      <th>Harga</th>
+                      <th>Subtotal</th>
+                      <th></th>
+                    </tr>
+                  </thead>
+                  <tbody>
                     {transaction?.data?.products?.map((product) => (
                       <tr key={product.id}>
                         <td className='flex'>
@@ -711,37 +729,37 @@ const Transaction = ({ id }) => {
                             )}
                             className='w-[20%] flex-shrink-0'
                           >
-                          <div className='relative'>
+                            <div className='relative'>
                               <Image
                                 src={product?.parent?.image}
                                 alt={product?.name}
                                 className='object-contain object-center border border-gray_r-6 h-32 w-full rounded-md'
                               />
-                            <div className='absolute top-0 right-4 flex  mt-3'>
-                              <div className='gambarB '>
-                                {product.isSni && (
-                                  <ImageNext
-                                    src='/images/sni-logo.png'
-                                    alt='SNI Logo'
-                                    className='w-2 h-4 object-contain object-top   sm:h-4'
-                                    width={50}
-                                    height={50}
-                                  />
-                                )}
-                              </div>
-                              <div className='gambarC  '>
-                                {product.isTkdn && (
-                                  <ImageNext
-                                    src='/images/TKDN.png'
-                                    alt='TKDN'
-                                    className='w-5 h-4 object-contain object-top  ml-1 sm:h-4'
-                                    width={50}
-                                    height={50}
-                                  />
-                                )}
+                              <div className='absolute top-0 right-4 flex  mt-3'>
+                                <div className='gambarB '>
+                                  {product.isSni && (
+                                    <ImageNext
+                                      src='/images/sni-logo.png'
+                                      alt='SNI Logo'
+                                      className='w-2 h-4 object-contain object-top   sm:h-4'
+                                      width={50}
+                                      height={50}
+                                    />
+                                  )}
+                                </div>
+                                <div className='gambarC  '>
+                                  {product.isTkdn && (
+                                    <ImageNext
+                                      src='/images/TKDN.png'
+                                      alt='TKDN'
+                                      className='w-5 h-4 object-contain object-top  ml-1 sm:h-4'
+                                      width={50}
+                                      height={50}
+                                    />
+                                  )}
+                                </div>
                               </div>
                             </div>
-                          </div>
                           </Link>
                           <div className='px-2 text-left'>
                             <Link
@@ -774,33 +792,42 @@ const Transaction = ({ id }) => {
                               {currencyFormat(product.price.price)}
                             </div>
                           )} */}
-                          <div>{currencyFormat(product.price.priceDiscount)}</div>
+                          <div>
+                            {currencyFormat(product.price.priceDiscount)}
+                          </div>
                         </td>
                         <td>{currencyFormat(product.price.subtotal)}</td>
                         {/* {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (transaction.data.isReaject == false) && ( */}
-                        {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) &&  (router.asPath.includes("/my/quotations/"))  && transaction.data?.status == 'draft' && (
-                          <td>
-                            <button
-                              className="bg-red-500 text-white py-1 px-3 rounded"
-                              onClick={() => openModal(product)}
-                            >
-                              Reject
-                            </button>
-                          </td>
-                        )}
+                        {auth?.feature.soApproval &&
+                          (auth.webRole == 2 || auth.webRole == 3) &&
+                          router.asPath.includes('/my/quotations/') &&
+                          transaction.data?.status == 'draft' && (
+                            <td>
+                              <button
+                                className='bg-red-500 text-white py-1 px-3 rounded'
+                                onClick={() => openModal(product)}
+                              >
+                                Reject
+                              </button>
+                            </td>
+                          )}
                       </tr>
                     ))}
                   </tbody>
                 </table>
               ) : (
-                <div className='badge-red text-sm'>Semua produk telah di reject</div>
+                <div className='badge-red text-sm'>
+                  Semua produk telah di reject
+                </div>
               )}
-              
+
               {isModalOpen && (
                 <div className='fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center'>
-                  <div className='bg-white p-4 rounded w-96
+                  <div
+                    className='bg-white p-4 rounded w-96
                      ease-in-out opacity-100
-                    transform transition-transform duration-300  scale-100'>
+                    transform transition-transform duration-300  scale-100'
+                  >
                     <h2 className='text-lg mb-2'>Berikan Alasan</h2>
                     <textarea
                       value={reason}
@@ -826,117 +853,116 @@ const Transaction = ({ id }) => {
                 </div>
               )}
 
-            {transaction?.data?.products?.map((product) => (
-              <div className='flex justify-end mt-4' key={product.id}>
-                <div className='w-1/4 grid grid-cols-2 gap-y-3 text-gray_r-12/80'>
-                  <div className='text-right'>Subtotal</div>
-                  <div className='text-right font-medium'>
-                    {currencyFormat(transaction.data?.amountUntaxed)}
-                  </div>
+              {transaction?.data?.products?.map((product) => (
+                <div className='flex justify-end mt-4' key={product.id}>
+                  <div className='w-1/4 grid grid-cols-2 gap-y-3 text-gray_r-12/80'>
+                    <div className='text-right'>Subtotal</div>
+                    <div className='text-right font-medium'>
+                      {currencyFormat(transaction.data?.amountUntaxed)}
+                    </div>
 
-                  <div className='text-right'>PPN 11%</div>
-                  <div className='text-right font-medium'>
-                    {currencyFormat(transaction.data?.amountTax)}
-                  </div>
+                    <div className='text-right'>PPN 11%</div>
+                    <div className='text-right font-medium'>
+                      {currencyFormat(transaction.data?.amountTax)}
+                    </div>
 
-                  <div className='text-right whitespace-nowrap'>
-                    Biaya Pengiriman
-                  </div>
-                  <div className='text-right font-medium'>
-                    {currencyFormat(transaction.data?.deliveryAmount)}
-                  </div>
+                    <div className='text-right whitespace-nowrap'>
+                      Biaya Pengiriman
+                    </div>
+                    <div className='text-right font-medium'>
+                      {currencyFormat(transaction.data?.deliveryAmount)}
+                    </div>
 
-                  <div className='text-right'>Grand Total</div>
-                  <div className='text-right font-medium text-gray_r-12'>
-                    {currencyFormat(transaction.data?.amountTotal)}
+                    <div className='text-right'>Grand Total</div>
+                    <div className='text-right font-medium text-gray_r-12'>
+                      {currencyFormat(transaction.data?.amountTotal)}
+                    </div>
                   </div>
                 </div>
-              </div>
-            ))}
-
-
+              ))}
 
               {transaction?.data?.productsRejectLine.length > 0 && (
-                  <div className='text-h-sm font-semibold mt-10 mb-4'>
-                    Rincian Produk Reject
-                  </div>
+                <div className='text-h-sm font-semibold mt-10 mb-4'>
+                  Rincian Produk Reject
+                </div>
               )}
               {transaction?.data?.productsRejectLine.length > 0 && (
-                  <table className='table-data'>
-                    <thead>
-                      <tr>
-                        <th>Nama Produk</th>
-                        {/* <th>Diskon</th> */}
-                        <th>Jumlah</th>
-                        <th>Harga</th>
-                        <th>Subtotal</th>
-                      </tr>
-                    </thead>
-                    <tbody>
-                      {transaction?.data?.productsRejectLine?.map((product) => (
-                        <tr key={product.id}>
-                          <td className='flex'>
+                <table className='table-data'>
+                  <thead>
+                    <tr>
+                      <th>Nama Produk</th>
+                      {/* <th>Diskon</th> */}
+                      <th>Jumlah</th>
+                      <th>Harga</th>
+                      <th>Subtotal</th>
+                    </tr>
+                  </thead>
+                  <tbody>
+                    {transaction?.data?.productsRejectLine?.map((product) => (
+                      <tr key={product.id}>
+                        <td className='flex'>
+                          <Link
+                            href={createSlug(
+                              '/shop/product/',
+                              product?.parent.name,
+                              product?.parent.id
+                            )}
+                            className='w-[20%] flex-shrink-0'
+                          >
+                            <Image
+                              src={product?.parent?.image}
+                              alt={product?.name}
+                              className='object-contain object-center border border-gray_r-6 h-32 w-full rounded-md'
+                            />
+                          </Link>
+                          <div className='px-2 text-left'>
                             <Link
                               href={createSlug(
                                 '/shop/product/',
                                 product?.parent.name,
                                 product?.parent.id
                               )}
-                              className='w-[20%] flex-shrink-0'
+                              className='line-clamp-2 leading-6 !text-gray_r-12 font-normal'
                             >
-                              <Image
-                                src={product?.parent?.image}
-                                alt={product?.name}
-                                className='object-contain object-center border border-gray_r-6 h-32 w-full rounded-md'
-                              />
+                              {product?.parent?.name}
                             </Link>
-                            <div className='px-2 text-left'>
-                              <Link
-                                href={createSlug(
-                                  '/shop/product/',
-                                  product?.parent.name,
-                                  product?.parent.id
-                                )}
-                                className='line-clamp-2 leading-6 !text-gray_r-12 font-normal'
-                              >
-                                {product?.parent?.name}
-                              </Link>
-                              <div className='text-gray_r-11 mt-2'>
-                                {product?.code}{' '}
-                                {product?.attributes.length > 0
-                                  ? `| ${product?.attributes.join(', ')}`
-                                  : ''}
-                              </div>
+                            <div className='text-gray_r-11 mt-2'>
+                              {product?.code}{' '}
+                              {product?.attributes.length > 0
+                                ? `| ${product?.attributes.join(', ')}`
+                                : ''}
                             </div>
-                          </td>
-                          {/* <td>
+                          </div>
+                        </td>
+                        {/* <td>
                             {product.price.discountPercentage > 0
                               ? `${product.price.discountPercentage}%`
                               : ''}
                           </td> */}
-                          <td>{product.quantity}</td>
-                          <td>
-                            {/* {product.price.discountPercentage > 0 && (
+                        <td>{product.quantity}</td>
+                        <td>
+                          {/* {product.price.discountPercentage > 0 && (
                               <div className='line-through mb-1 text-caption-1 text-gray_r-12/70'>
                                 {currencyFormat(product.price.price)}
                               </div>
                             )} */}
-                            <div>{currencyFormat(product.price.priceDiscount)}</div>
-                          </td>
-                          <td className='flex justify-center'>
-                            <NextImage
-                              src={rejectImage}
-                              alt='Reject'
-                              width={90}
-                              height={30}
-                            /> 
-                          </td>
-                        </tr>
-                      ))}
-                    </tbody>
-                  </table>
+                          <div>
+                            {currencyFormat(product.price.priceDiscount)}
+                          </div>
+                        </td>
+                        <td className='flex justify-center'>
+                          <NextImage
+                            src={rejectImage}
+                            alt='Reject'
+                            width={90}
+                            height={30}
+                          />
+                        </td>
+                      </tr>
+                    ))}
+                  </tbody>
+                </table>
               )}
-                           
             </div>
           </div>
         </DesktopView>
-- 
cgit v1.2.3


From 22138e7d2baecded261c38904d028962558951a4 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 13 Aug 2024 15:10:01 +0700
Subject: <iman> update bug grand total

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

(limited to 'src/lib/transaction/components/Transaction.jsx')

diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index 85f6163b..4d401037 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -853,8 +853,8 @@ const Transaction = ({ id }) => {
                 </div>
               )}
 
-              {transaction?.data?.products?.map((product) => (
-                <div className='flex justify-end mt-4' key={product.id}>
+              {transaction?.data?.products?.length > 0 && (
+                <div className='flex justify-end mt-4'>
                   <div className='w-1/4 grid grid-cols-2 gap-y-3 text-gray_r-12/80'>
                     <div className='text-right'>Subtotal</div>
                     <div className='text-right font-medium'>
@@ -879,7 +879,7 @@ const Transaction = ({ id }) => {
                     </div>
                   </div>
                 </div>
-              ))}
+              )} 
 
               {transaction?.data?.productsRejectLine.length > 0 && (
                 <div className='text-h-sm font-semibold mt-10 mb-4'>
-- 
cgit v1.2.3

