From 544f0321f069254b64ea080d11724ab3e4a92bce Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 14 Aug 2024 11:34:38 +0700
Subject: <iman> update button lanjutkan transaksi & status quotation logic
 after upload po

---
 src/lib/transaction/components/Transaction.jsx | 29 +++++++++++++++++++++-----
 1 file changed, 24 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 85f6163b..88f11fd4 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -5,6 +5,8 @@ import useTransaction from '../hooks/useTransaction';
 import TransactionStatusBadge from './TransactionStatusBadge';
 import Divider from '@/core/components/elements/Divider/Divider';
 import { useEffect, useMemo, useRef, useState } from 'react';
+import { Button, Tooltip } from '@chakra-ui/react';
+import clsxm from '~/libs/clsxm';
 import ImageNext from 'next/image';
 import {
   downloadPurchaseOrder,
@@ -107,7 +109,7 @@ const Transaction = ({ id }) => {
       toast.error('Mohon upload dokumen PO anda sebelum melanjutkan pesanan');
       return;
     }
-    await checkoutPoApi({ id });
+    await checkoutPoApi({ id, status: true });
     toast.success('Berhasil melanjutkan pesanan');
     transaction.refetch();
   };
@@ -563,10 +565,27 @@ const Transaction = ({ id }) => {
                   )}
                 {transaction.data?.status == 'draft' &&
                   !auth?.feature.soApproval && (
-                    <button className='btn-yellow' onClick={checkout}>
-                      Lanjutkan Transaksi
-                    </button>
-                  )}
+                    <div>
+                      <Tooltip
+                      label={clsxm({
+                        'Mohon upload dokumen PO anda sebelum melanjutkan pesanan': !transaction?.data?.purchaseOrderFile,
+                      })}>
+                      <Button  colorScheme='yellow'  onClick={checkout}
+                      isDisabled={
+                        // transaction.data?.status === 'draft'
+                        //   ? true
+                        //   : false ||
+                           auth?.webRole === statusApprovalWeb
+                          ? true
+                          : false || transaction?.data?.purchaseOrderFile === true ? false : true
+                      }
+                      >
+                        Lanjutkan Transaksi
+                      </Button>
+                    </Tooltip>
+
+                    </div>
+                    )}
                 {transaction.data?.status != 'draft' &&
                   !auth?.feature.soApproval && (
                     <button
-- 
cgit v1.2.3

