From fb04f8d327aafa2eb5440ade12919e1f07c2c1c1 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Fri, 10 Jan 2025 16:34:43 +0700
Subject: <iman> update merchant

---
 src/lib/merchant/components/InformasiVendor.jsx | 95 +++++--------------------
 1 file changed, 19 insertions(+), 76 deletions(-)

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

diff --git a/src/lib/merchant/components/InformasiVendor.jsx b/src/lib/merchant/components/InformasiVendor.jsx
index 9aea7811..6e57eade 100644
--- a/src/lib/merchant/components/InformasiVendor.jsx
+++ b/src/lib/merchant/components/InformasiVendor.jsx
@@ -149,6 +149,7 @@ const InformasiVendor = ({ handleIsError }) => {
     });
 
     setKreditLimitFormat(formattedValue1);
+    setValue('kreditLimit', formattedValue1);
   };
 
   const [selectedIds, setSelectedIds] = useState(
@@ -326,6 +327,7 @@ const InformasiVendor = ({ handleIsError }) => {
       loadZip();
     }
   }, [watchsubDistrict, subDistricts]);
+  console.log('errors', errors);
   const onSubmitHandler = async (values) => {
     const toastId = toast.loading('Mengirimkan formulir merchant...');
     const data = {
@@ -336,35 +338,12 @@ const InformasiVendor = ({ handleIsError }) => {
       is_pengajuan_tempo: values.isPengajuanTempo,
       tempo_duration: values.tempoDuration,
       kredit_limit: values.kreditLimit,
-      name_merchant: 'Form Merchant - ' + values.company,
-      partner_id: auth.partnerId,
-      state: values.state,
-      city: values.city,
-      district: values.district,
-      subDistrict: values.subDistrict,
-      zip: values.zip,
-      bank_name: values.bank,
-      rekening_name: values.rekening,
-      account_number: values.accountNumber,
-      email_company: values.email,
-      email_sales: values.emailSales,
-      email_finance: values.emailFinance,
-      phone: values.phone,
-      mobile: values.mobile,
-      description:
-        'Nama Perusahaan : ' +
-        values.company +
-        ' \r\n  Alamat  : ' +
-        values.address +
-        ' \r\n  Kota  : ' +
-        values.city +
-        ' \r\n  Telepon: ' +
-        values.phone +
-        ' \r\n  Email  : ' +
-        values.email +
-        ' \r\n No Hp : ' +
-        values.mobile,
+      waktu_pengiriman: values.waktuPengiriman,
+      terhitung_sejak: values.terhitungSejak,
     };
+    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 });
@@ -422,6 +401,7 @@ const InformasiVendor = ({ handleIsError }) => {
       [fieldName]: file ? file.name : '', // Tambahkan atau perbarui file di state
     }));
   };
+  console.log("watch('isPengajuanTempo')", watch('kreditLimit'));
 
   return (
     <>
@@ -1336,59 +1316,22 @@ const InformasiVendor = ({ handleIsError }) => {
   );
 };
 const validationSchema = Yup.object().shape({
-  categoryProduk: Yup.string().required('Harus di-isi'),
+  categoryProduk: Yup.string().required('Harus di-pilih'),
   merkDagang: Yup.string().required('Harus di-isi'),
-  tempoDuration: Yup.string().required('Harus di-isi'),
+  isPengajuanTempo: Yup.string().required('Harus di-pilih'),
+  tempoDuration: Yup.string().required('Harus di-pilih'),
   kreditLimit: Yup.string().required('Harus di-isi'),
   waktuPengiriman: Yup.string().required('Harus di-isi'),
-  terhitungSejak: 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'),
+  terhitungSejak: Yup.string().required('Harus di-pilih'),
 });
 const defaultValues = {
-  company: '',
-  pejabatName: '',
-  PICName: '',
-  PICPosition: '',
-  email: '',
-  emailSales: '',
-  emailFinance: '',
-  phone: '',
-  state: '',
-  city: '',
-  district: '',
-  subDistrict: '',
-  zip: '',
-  bank: '',
-  rekening: '',
-  accountNumber: '',
-  address: '',
-  mobile: '',
+  categoryProduk: '',
+  merkDagang: '',
+  isPengajuanTempo: '',
+  tempoDuration: '',
+  kreditLimit: '',
+  waktuPengiriman: '',
+  terhitungSejak: '',
 };
 
 export default InformasiVendor;
-- 
cgit v1.2.3

