From 062e2caf344fedf504ad601a88aaab7a3764ec21 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 26 Sep 2024 13:35:53 +0700
Subject: <iman> update informasi bisnis logic save field inputan

---
 src/lib/auth/components/CompanyProfile.jsx | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

(limited to 'src/lib/auth/components/CompanyProfile.jsx')

diff --git a/src/lib/auth/components/CompanyProfile.jsx b/src/lib/auth/components/CompanyProfile.jsx
index 7bebb02f..d066cef7 100644
--- a/src/lib/auth/components/CompanyProfile.jsx
+++ b/src/lib/auth/components/CompanyProfile.jsx
@@ -63,6 +63,7 @@ const CompanyProfile = () => {
       setValue('npwp', dataProfile.npwp);
       setValue('alamat_wajib_pajak', dataProfile.alamatWajibPajak);
       setValue('alamat_bisnis', dataProfile.alamatBisnis);
+      setValue('company_type', dataProfile.company_type);
     };
     if (auth) loadProfile();
   }, [auth, setValue]);
@@ -248,12 +249,28 @@ export default CompanyProfile;
 
 const validationSchema = Yup.object().shape({
   alamat_bisnis: Yup.string().required('Harus di-isi'),
-  alamat_wajib_pajak: Yup.string().required('Harus di-isi'),
-  taxName: Yup.string().required('Harus di-isi'),
-  npwp: Yup.string().required('Harus di-isi'),
   name: Yup.string().required('Harus di-isi'),
   industry: Yup.string().required('Harus di-pilih'),
   companyType: Yup.string().required('Harus di-pilih'),
+  taxName: Yup.string(),
+  npwp: Yup.string(),
+  alamat_wajib_pajak: Yup.string(),
+  company_type: Yup.string(),
+  taxName: Yup.string().when('company_type', {
+    is: (company_type) => company_type !== 'PKP',
+    then: Yup.string().required('Harus di-isi'),
+    otherwise: Yup.string().notRequired(),
+  }),
+  npwp: Yup.string().when('company_type', {
+    is: (company_type) => company_type !== 'PKP',
+    then: Yup.string().required('Harus di-isi'),
+    otherwise: Yup.string().notRequired(),
+  }),
+  alamat_wajib_pajak: Yup.string().when('company_type', {
+    is: (company_type) => company_type !== 'PKP',
+    then: Yup.string().required('Harus di-isi'),
+    otherwise: Yup.string().notRequired(),
+  }),
 });
 
 const defaultValues = {
-- 
cgit v1.2.3

