From 0178a1f88d7d34824562e1413be073c0795a47cf Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 16 Dec 2024 17:42:31 +0700
Subject: <iman> update code

---
 .../pengajuan-tempo/component/PengajuanTempo.jsx   | 95 +++++++++++++++++-----
 1 file changed, 73 insertions(+), 22 deletions(-)

(limited to 'src/lib/pengajuan-tempo/component/PengajuanTempo.jsx')

diff --git a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
index b4f4ac9b..f5cad812 100644
--- a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
+++ b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
@@ -253,6 +253,29 @@ const PengajuanTempo = () => {
     setCurrentStep((prev) => (prev === NUMBER_OF_STEPS - 1 ? prev : prev + 1));
   };
 
+  const goPrevStep = () => {
+    // if (!isFormValid) {
+    //   setNotValid(true);
+    //   setButtonSubmitClick(!buttonSubmitClick);
+    //   return;
+    // } else {
+    //   // saveToLocalStorage(stepLabels[currentStep], stepDivsForm[currentStep]);
+    //   if (currentStep == 3) {
+    //     handleDaftarTempoSupplier();
+    //   } else if (currentStep == 4) {
+    //     handleDaftarTempoDokumen();
+    //   } else {
+    //     handleDaftarTempoPerPage(
+    //       stepLabels[currentStep],
+    //       stepDivsForm[currentStep]
+    //     );
+    //   }
+    //   setButtonSubmitClick(!buttonSubmitClick);
+    //   setNotValid(false);
+    // }
+    setCurrentStep((prev) => (prev === NUMBER_OF_STEPS - 1 ? prev : prev - 1));
+  };
+
   const handleDaftarTempoPerPage = async (
     label,
     formData,
@@ -558,30 +581,57 @@ const PengajuanTempo = () => {
           <span className='text-xs opacity-60'>
             *Pastikan data yang anda masukan sudah benar dan sesuai
           </span>
-          {currentStep < 5 && (
-            <>
-              <Tooltip
-                label={clsxm({
-                  'Klik simpan data terlebih dahulu':
-                    currentStep === 3 && !hasSavedata,
-                })}
+          <div
+            className={` flex flex-row ${
+              currentStep > 0 && currentStep < 5
+                ? 'justify-between'
+                : 'justify-end'
+            } items-center w-full ${isMobile ? 'gap-x-4 ' : ''}`}
+          >
+            {currentStep < 5 && currentStep > 0 && (
+              <Button
+                colorScheme='yellow'
+                w={`${isMobile ? 'full' : 'fit'}`}
+                onClick={goPrevStep}
               >
-                <Button
-                  colorScheme='red'
-                  w={`${isMobile ? 'full' : 'fit'}`}
-                  isDisabled={
-                    (currentStep === 3 && !hasSavedata) ||
-                    currentStep === NUMBER_OF_STEPS - 1
-                  }
-                  onClick={goToNextStep}
+                {<ChevronLeftIcon className='w-5' />}
+                <span className={`${isMobile ? 'text-xs' : ''} `}>
+                  Langkah Sebelumnya
+                </span>
+              </Button>
+            )}
+            {currentStep < 5 && (
+              <>
+                <Tooltip
+                  label={clsxm({
+                    'Klik simpan data terlebih dahulu':
+                      currentStep === 3 && !hasSavedata,
+                  })}
                 >
-                  Langkah Selanjutnya {<ChevronRightIcon className='w-5' />}
-                </Button>
-              </Tooltip>
-            </>
-          )}
+                  <Button
+                    colorScheme='red'
+                    w={`${isMobile ? 'full' : 'fit'}`}
+                    isDisabled={
+                      (currentStep === 3 && !hasSavedata) ||
+                      currentStep === NUMBER_OF_STEPS - 1
+                    }
+                    onClick={goToNextStep}
+                  >
+                    <span className={`${isMobile ? 'text-xs' : ''} `}>
+                      Langkah Selanjutnya
+                    </span>
+                    {<ChevronRightIcon className='w-5' />}
+                  </Button>
+                </Tooltip>
+              </>
+            )}
+          </div>
           {currentStep == 5 && (
-            <div className='flex flex-col items-end justify-start gap-4'>
+            <div
+              className={`flex flex-col ${
+                isMobile ? 'items-start' : 'items-end'
+              } w-full justify-start gap-4`}
+            >
               <TempoTermCondition onCheckChange={handleCheckChange} />
               <Button
                 colorScheme='red'
@@ -601,6 +651,7 @@ const PengajuanTempo = () => {
 const TempoTermCondition = ({ onCheckChange }) => {
   const [isCheckedTNC, SetIsCheckedTNC] = useState(false);
   const [openTNC, SetOpenTNC] = useState(false);
+  const { isDesktop, isMobile } = useDevice();
 
   const openTNCHandle = () => {
     SetOpenTNC(!openTNC);
@@ -623,7 +674,7 @@ const TempoTermCondition = ({ onCheckChange }) => {
           isChecked={isCheckedTNC}
           onChange={toggleCheckTNC}
         />
-        <div>
+        <div className={`text-center ${isMobile ? 'text-sm' : ''}`}>
           <label htmlFor='tnc' className='cursor-pointer'>
             Dengan ini saya menyetujui
           </label>{' '}
-- 
cgit v1.2.3

