From 3692f937130e18cf396f5871d8a15bdd258bdd2b Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 13 Jan 2025 16:37:28 +0700
Subject: <iman> update merchant

---
 src/lib/merchant/components/Dokumen.jsx | 44 ++++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 11 deletions(-)

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

diff --git a/src/lib/merchant/components/Dokumen.jsx b/src/lib/merchant/components/Dokumen.jsx
index a701a36d..fb4d1914 100644
--- a/src/lib/merchant/components/Dokumen.jsx
+++ b/src/lib/merchant/components/Dokumen.jsx
@@ -84,12 +84,12 @@ const Dokumen = ({ handleIsError }) => {
   const recaptchaRef = useRef(null);
   const npwpRef = useRef(null);
   const sppkpRef = useRef(null);
+  const ktpDirutRef = useRef(null);
   const kartuNamaRef = useRef(null);
   const suratPernyataanRef = useRef(null);
   const fotoKantorRef = useRef(null);
   const dataProdukRef = useRef(null);
   const pricelistRef = useRef(null);
-  const ktpDirutRef = useRef(null);
   const router = useRouter();
 
   const auth = useAuth();
@@ -274,27 +274,38 @@ const Dokumen = ({ handleIsError }) => {
     const dataProduk = DeatailFile.dataProduk;
     const pricelist = DeatailFile.pricelist;
     if (!npwp && isPkp) {
+      if (npwpRef?.current) {
+        npwpRef.current.scrollIntoView(options);
+      }
       toast.error('NPWP wajib di tambahkan');
       return;
     }
     if (!sppkp && isPkp) {
       toast.error('SPPKP wajib di tambahkan');
+      if (sppkpRef?.current) {
+        sppkpRef.current.scrollIntoView(options);
+      }
       return;
     }
     if (!dokumenKtpDirut && !isPkp) {
-      if (ktpDirutRef.current) {
+      toast.error('KTP Dirut/Direktur wajib di tambahkan');
+      if (ktpDirutRef?.current) {
         ktpDirutRef.current.scrollIntoView(options);
-        console.log('MASUK SINI BANG');
       }
-      toast.error('KTP Dirut/Direktur wajib di tambahkan');
       return;
     }
     if (!fotoKantor) {
       toast.error('Foto Gudang / Kantor Bagian Depan wajib di tambahkan');
+      if (fotoKantorRef?.current) {
+        fotoKantorRef.current.scrollIntoView(options);
+      }
       return;
     }
     if (!pricelist) {
       toast.error('Pricelist wajib di tambahkan');
+      if (pricelistRef?.current) {
+        pricelistRef.current.scrollIntoView(options);
+      }
       return;
     }
     const toastId = toast.loading('Mengirimkan formulir merchant...');
@@ -447,7 +458,7 @@ const Dokumen = ({ handleIsError }) => {
               <div className='w-full flex flex-row items-start'>
                 <div className='w-2/5 flex flex-row justify-between items-center'>
                   <div>
-                    <label className='form-label  text-nowrap'>
+                    <label className='form-label  text-nowrap' ref={sppkpRef}>
                       SPPKP{' '}
                       {!isPkp && (
                         <span className=' opacity-60'>(Opsional)</span>
@@ -545,7 +556,7 @@ const Dokumen = ({ handleIsError }) => {
 
               <div className='w-full flex flex-row'>
                 <div className='w-2/5'>
-                  <label className='form-label  text-nowrap'>
+                  <label className='form-label  text-nowrap' ref={kartuNamaRef}>
                     Kartu Nama <span className=' opacity-60'>(Opsional)</span>{' '}
                   </label>
                   <span className='opacity-65 text-xs'>
@@ -586,7 +597,10 @@ const Dokumen = ({ handleIsError }) => {
               <div className='w-full flex flex-row items-start '>
                 <div className='w-2/5 flex flex-row justify-between items-center '>
                   <div>
-                    <label className='form-label  text-nowrap'>
+                    <label
+                      className='form-label  text-nowrap'
+                      ref={suratPernyataanRef}
+                    >
                       Surat Pernyataan Nomor Rekening{' '}
                       <span className=' opacity-60'>(Opsional)</span>
                     </label>
@@ -637,7 +651,10 @@ const Dokumen = ({ handleIsError }) => {
               </div>
               <div className='w-full flex flex-row items-start '>
                 <div className='w-2/5 flex flex-col justify-start items-start '>
-                  <label className='form-label  text-nowrap'>
+                  <label
+                    className='form-label  text-nowrap'
+                    ref={fotoKantorRef}
+                  >
                     Foto Gudang / Kantor Bagian Depan
                   </label>
                   <span className='opacity-65 text-xs'>
@@ -676,7 +693,10 @@ const Dokumen = ({ handleIsError }) => {
               </div>
               <div className='w-full flex flex-row items-start '>
                 <div className='w-2/5 flex flex-col justify-start items-start '>
-                  <label className='form-label  text-nowrap'>
+                  <label
+                    className='form-label  text-nowrap'
+                    ref={dataProdukRef}
+                  >
                     Data Produk (Item Name, Gambar, Deskripsi){' '}
                     <span className=' opacity-60'>(Opsional)</span>{' '}
                   </label>
@@ -710,13 +730,15 @@ const Dokumen = ({ handleIsError }) => {
                   </span>
 
                   <div className='text-caption-2 text-danger-500 mt-1'>
-                    {errors.fotoKantor?.message}
+                    {errors.dataProduk?.message}
                   </div>
                 </div>
               </div>
               <div className='w-full flex flex-row items-start '>
                 <div className='w-2/5 flex flex-col justify-start items-start '>
-                  <label className='form-label  text-nowrap'>Pricelist</label>
+                  <label className='form-label  text-nowrap' ref={pricelistRef}>
+                    Pricelist
+                  </label>
                   <span className='opacity-65 text-xs'>
                     Pastikan dokumen yang anda upload sudah benar
                   </span>
-- 
cgit v1.2.3

