From ea5c6ef19717dc0eb6e1879cb48704064a263596 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Sat, 11 Jan 2025 10:01:34 +0700
Subject: <iman> update merchant

---
 src/lib/merchant/components/Dokumen.jsx | 64 ++++++++++++++++++---------------
 1 file changed, 35 insertions(+), 29 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 d9b53e82..a701a36d 100644
--- a/src/lib/merchant/components/Dokumen.jsx
+++ b/src/lib/merchant/components/Dokumen.jsx
@@ -24,7 +24,13 @@ import MobileView from '@/core/components/views/MobileView';
 import DesktopView from '@/core/components/views/DesktopView';
 import getFileBase64 from '@/core/utils/getFileBase64';
 import odooApi from '~/libs/odooApi';
-const Dokumen = () => {
+const Dokumen = ({ handleIsError }) => {
+  const isError = (value) => {
+    // Logika menentukan error
+    const result = value ? true : false;
+    handleIsError(result); // Panggil handleIsError dari Merchant
+    return result;
+  };
   const {
     register,
     handleSubmit,
@@ -76,6 +82,14 @@ const Dokumen = () => {
   const [isPkp, setIsPkp] = useState(false);
 
   const recaptchaRef = useRef(null);
+  const npwpRef = useRef(null);
+  const sppkpRef = 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();
@@ -245,7 +259,12 @@ const Dokumen = () => {
       loadZip();
     }
   }, [watchsubDistrict, subDistricts]);
+
   const onSubmitHandler = async (values) => {
+    const options = {
+      behavior: 'smooth',
+      block: 'center',
+    };
     const npwp = DeatailFile.npwp;
     const sppkp = DeatailFile.sppkp;
     const dokumenKtpDirut = DeatailFile.dokumenKtpDirut;
@@ -263,6 +282,10 @@ const Dokumen = () => {
       return;
     }
     if (!dokumenKtpDirut && !isPkp) {
+      if (ktpDirutRef.current) {
+        ktpDirutRef.current.scrollIntoView(options);
+        console.log('MASUK SINI BANG');
+      }
       toast.error('KTP Dirut/Direktur wajib di tambahkan');
       return;
     }
@@ -286,6 +309,9 @@ const Dokumen = () => {
       file_dataProduk: dataProduk ? dataProduk : '',
       file_pricelist: pricelist ? pricelist : '',
     };
+    isError(true);
+    toast.dismiss(toastId);
+    toast.success('Berhasil menambahkan data');
     // const formData = new FormData();
     // formData.append('npwp', values.npwp[0]);
     // const create_leads = await createMerchantApi({ data });
@@ -383,7 +409,10 @@ const Dokumen = () => {
                     Pastikan dokumen yang anda upload sudah benar
                   </span>
                 </div>
-                <div className='w-3/5 flex flex-col justify-start items-start'>
+                <div
+                  className='w-3/5 flex flex-col justify-start items-start'
+                  ref={npwpRef}
+                >
                   <div className='flex flex-row items-start justify-start gap-2'>
                     <label
                       htmlFor='npwp'
@@ -478,7 +507,10 @@ const Dokumen = () => {
                     Pastikan dokumen yang anda upload sudah benar
                   </span>
                 </div>
-                <div className='w-3/5 flex flex-col justify-start items-start'>
+                <div
+                  className='w-3/5 flex flex-col justify-start items-start'
+                  ref={ktpDirutRef}
+                >
                   <div className='flex flex-row items-start justify-start gap-2'>
                     <label
                       htmlFor='dokumenKtpDirut'
@@ -1392,32 +1424,6 @@ const Dokumen = () => {
   );
 };
 const validationSchema = Yup.object().shape({
-  company: Yup.string().required('Harus di-isi'),
-  pejabatName: Yup.string().required('Harus di-isi'),
-  PICName: Yup.string().required('Harus di-isi'),
-  PICPosition: Yup.string().required('Harus di-isi'),
-  email: Yup.string()
-    .email('Format harus seperti contoh@email.com')
-    .required('Harus di-isi'),
-  emailSales: Yup.string()
-    .email('Format harus seperti contoh@email.com')
-    .required('Harus di-isi'),
-  emailFinance: Yup.string()
-    .email('Format harus seperti contoh@email.com')
-    .required('Harus di-isi'),
-  phone: Yup.string().required('Harus di-isi'),
-  state: Yup.string().required('Harus dipilih'),
-  bisnisType: Yup.string().required('Harus dipilih'),
-  categoryPerusahaan: Yup.string().required('Harus dipilih'),
-  city: Yup.string().required('Harus dipilih'),
-  district: Yup.string().required('Harus dipilih'),
-  subDistrict: Yup.string().required('Harus dipilih'),
-  zip: Yup.string().required('Harus di-isi'),
-  bank: Yup.string().required('Harus di-isi'),
-  rekening: Yup.string().required('Harus di-isi'),
-  accountNumber: Yup.string().required('Harus di-isi'),
-  address: Yup.string().required('Harus di-isi'),
-  mobile: Yup.string().required('Harus di-isi'),
   npwp: Yup.mixed().required('File is required'),
   pricelist: Yup.mixed().required('File is required'),
 });
-- 
cgit v1.2.3

