From 272bed12b28763b6f51b97012a4533ab17a561ae Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Wed, 6 Mar 2024 10:11:18 +0700
Subject: validation step approval

---
 src/lib/transaction/components/Transaction.jsx | 32 +++++++++++++++-----------
 1 file changed, 19 insertions(+), 13 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 d4b0f92c..ab76c671 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -33,7 +33,8 @@ import useAuth from '@/core/hooks/useAuth';
 import StepApproval from './stepper';
 
 const Transaction = ({ id }) => {
-  const auth = { ...useAuth(), isApprovalState: true };
+  const auth = { ...useAuth(), web_role: 2, feature: { so_approval: true } };
+  const statusApprovalWeb = 1
   const { transaction } = useTransaction({ id });
   const { queryAirwayBill } = useAirwayBill({ orderId: id });
 
@@ -245,7 +246,7 @@ const Transaction = ({ id }) => {
 
           <Divider />
 
-          {!auth.isApprovalState && (
+          {!auth.feature.so_approval && (
             <div className='p-4 flex flex-col gap-y-4'>
               <DescriptionRow label='Purchase Order'>
                 {transaction.data?.purchaseOrderName || '-'}
@@ -311,13 +312,13 @@ const Transaction = ({ id }) => {
           <Divider />
 
           <div className='p-4 pt-0'>
-            {transaction.data?.status == 'draft' && auth.isApprovalState && (
+            {transaction.data?.status == 'draft' && auth.feature.so_approval && (
               <div className='flex gap-x-2'>
                 <button
                   className='btn-yellow w-full'
                   onClick={checkout}
                   disabled={
-                    transaction.data?.status === 'cancel' ? true : false
+                    transaction.data?.status === 'cancel' ? true : false  || auth.web_role === statusApprovalWeb ? true : false
                   }
                 >
                   Approve
@@ -326,14 +327,14 @@ const Transaction = ({ id }) => {
                   className='btn-solid-red px-7 w-full'
                   onClick={checkout}
                   disabled={
-                    transaction.data?.status === 'cancel' ? true : false
+                    transaction.data?.status === 'cancel' ? true : false  || auth.web_role === statusApprovalWeb ? true : false
                   }
                 >
                   Reject
                 </button>
               </div>
             )}
-            {transaction.data?.status == 'draft' && !auth.isApprovalState && (
+            {transaction.data?.status == 'draft' && !auth.feature.so_approval && (
               <button className='btn-yellow w-full mt-4' onClick={checkout}>
                 Lanjutkan Transaksi
               </button>
@@ -367,7 +368,13 @@ const Transaction = ({ id }) => {
                 <h1 className='text-title-sm font-semibold mb-6'>
                   Detail Transaksi
                 </h1>
-                <StepApproval layer={2} status={'cancel'} className='ml-auto' />
+                {auth.feature.so_approval && (
+                  <StepApproval
+                    layer={statusApprovalWeb}
+                    status={'cancel'}
+                    className='ml-auto'
+                  />
+                )}
               </div>
 
               <div className='flex items-center gap-x-2 mb-3'>
@@ -385,13 +392,13 @@ const Transaction = ({ id }) => {
                   Download
                 </button>
                 {transaction.data?.status == 'draft' &&
-                  auth.isApprovalState && (
+                  auth.feature.so_approval && auth.web_role && (
                     <div className='flex gap-x-2'>
                       <button
                         className='btn-yellow'
                         onClick={checkout}
                         disabled={
-                          transaction.data?.status === 'cancel' ? true : false
+                          transaction.data?.status === 'cancel' ? true : false || auth.web_role === statusApprovalWeb ? true : false
                         }
                       >
                         Approve
@@ -400,7 +407,7 @@ const Transaction = ({ id }) => {
                         className='btn-solid-red px-7'
                         onClick={checkout}
                         disabled={
-                          transaction.data?.status === 'cancel' ? true : false
+                          transaction.data?.status === 'cancel' ? true : false || auth.web_role === statusApprovalWeb ? true : false
                         }
                       >
                         Reject
@@ -408,7 +415,7 @@ const Transaction = ({ id }) => {
                     </div>
                   )}
                 {transaction.data?.status == 'draft' &&
-                  !auth.isApprovalState && (
+                  !auth.feature.so_approval && (
                     <button className='btn-yellow' onClick={checkout}>
                       Lanjutkan Transaksi
                     </button>
@@ -436,7 +443,7 @@ const Transaction = ({ id }) => {
                   <div>Ketentuan Pembayaran</div>
                   <div>: {transaction?.data?.paymentTerm}</div>
 
-                  {!auth.isApprovalState && (
+                  {!auth.feature.so_approval && (
                     <>
                       <div>Purchase Order</div>
                       <div>
@@ -455,7 +462,6 @@ const Transaction = ({ id }) => {
                             : 'Upload'}
                         </button>
                       </div>
-                      )
                     </>
                   )}
                 </div>
-- 
cgit v1.2.3

