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 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

