From c42e3256fa8f059a937629b1e44a2dc50d736928 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Fri, 10 Jan 2025 13:33:16 +0700
Subject: <iman> update code

---
 src/lib/merchant/components/Merchant.jsx | 57 +++++++++++++++++---------------
 1 file changed, 31 insertions(+), 26 deletions(-)

(limited to 'src/lib/merchant/components/Merchant.jsx')

diff --git a/src/lib/merchant/components/Merchant.jsx b/src/lib/merchant/components/Merchant.jsx
index 30ad0130..c4661d46 100644
--- a/src/lib/merchant/components/Merchant.jsx
+++ b/src/lib/merchant/components/Merchant.jsx
@@ -4,6 +4,7 @@ import Image from '~/components/ui/image';
 import InformasiPerusahaan from './InformasiPerusahaan';
 import InformasiVendor from './InformasiVendor';
 import SyaratDagang from './SyaratDagang';
+import Dokumen from './Dokumen';
 import { getAuth } from '~/libs/auth';
 import { setAuth } from '@/core/utils/auth';
 import useAuth from '@/core/hooks/useAuth';
@@ -20,7 +21,7 @@ import PageContent from '@/lib/content/components/PageContent';
 const Merchant = () => {
   const { isDesktop, isMobile } = useDevice();
   const [currentStep, setCurrentStep] = React.useState(0);
-  const NUMBER_OF_STEPS = 6;
+  const NUMBER_OF_STEPS = 5;
   const [isLoading, setIsLoading] = useState(false);
   const [bigData, setBigData] = useState();
   const [idTempo, setIdTempo] = useState(0);
@@ -30,10 +31,19 @@ const Merchant = () => {
   const [BannerTempo, setBannerTempo] = useState();
   const [notValid, setNotValid] = useState(false);
   const [buttonSubmitClick, setButtonSubmitClick] = useState(false);
+
+  const [error, setError] = useState(false);
+
+  const handleIsError = (value) => {
+    console.log('value yang dihasilkan', value);
+    goToNextStep();
+    setError(value); // Memperbarui state berdasarkan isError
+  };
   const stepDivs = [
-    <InformasiPerusahaan />,
-    <InformasiVendor />,
+    <InformasiVendor handleIsError={handleIsError} />,
+    <InformasiPerusahaan handleIsError={handleIsError} />,
     <SyaratDagang />,
+    <Dokumen />,
   ];
 
   const stepLabels = [
@@ -45,6 +55,13 @@ const Merchant = () => {
     'Konfirmasi',
   ];
 
+  useEffect(() => {
+    window.scrollTo({
+      top: 0,
+      behavior: 'smooth',
+    });
+  }, [currentStep]);
+
   // useEffect(() => {
   //   const loadBigData = async () => {
   //     const toCamelCase = (str) =>
@@ -170,9 +187,7 @@ const Merchant = () => {
             className='w-full mt-6'
           />
         )}
-        <h1 className=' font-semibold text-center mb-6'>
-          Form Pengajuan Tempo
-        </h1>
+        <h1 className=' font-semibold text-center mb-6'>Form Merchant</h1>
         <p
           className={`text-center  ${
             isMobile ? 'w-full text-sm' : 'w-3/4 mb-4'
@@ -224,27 +239,17 @@ const Merchant = () => {
             )}
             {currentStep < 5 && (
               <>
-                <Tooltip
-                  label={clsxm({
-                    'Klik simpan data terlebih dahulu':
-                      currentStep === 3 && !hasSavedata,
-                  })}
+                <Button
+                  colorScheme='red'
+                  w={`${isMobile ? 'full' : 'fit'}`}
+                  isDisabled={currentStep === NUMBER_OF_STEPS - 1}
+                  onClick={goToNextStep}
                 >
-                  <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>
+                  <span className={`${isMobile ? 'text-xs' : ''} `}>
+                    Langkah Selanjutnya
+                  </span>
+                  {<ChevronRightIcon className='w-5' />}
+                </Button>
               </>
             )}
           </div>
-- 
cgit v1.2.3

