From fad165af76bb008076e96199f173fbe27b7835a8 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 18 Sep 2024 17:18:47 +0700
Subject: <iman> update alamat yang sama

---
 src/lib/auth/components/CompanyProfile.jsx | 40 ++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

(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 d4cf8657..ee9c1f58 100644
--- a/src/lib/auth/components/CompanyProfile.jsx
+++ b/src/lib/auth/components/CompanyProfile.jsx
@@ -24,6 +24,45 @@ const CompanyProfile = () => {
       alamat_bisnis: '',
     },
   });
+
+  const formatNpwp = (value) => {
+    try {
+      const cleaned = ('' + value).replace(/\D/g, '');
+      let match;
+      if (cleaned.length <= 15) {
+        match = cleaned.match(
+          /(\d{0,2})?(\d{0,3})?(\d{0,3})?(\d{0,1})?(\d{0,3})?(\d{0,3})$/
+        );
+      } else {
+        match = cleaned.match(
+          /(\d{0,3})?(\d{0,3})?(\d{0,3})?(\d{0,1})?(\d{0,3})?(\d{0,3})$/
+        );
+      }
+
+      if (match) {
+        return [
+          match[1],
+          match[2] ? '.' : '',
+          match[2],
+          match[3] ? '.' : '',
+          match[3],
+          match[4] ? '.' : '',
+          match[4],
+          match[5] ? '-' : '',
+          match[5],
+          match[6] ? '.' : '',
+          match[6],
+        ].join('');
+      }
+
+      // If match is null, return the original cleaned string or handle as needed
+      return cleaned;
+    } catch (error) {
+      // Handle error or return a default value
+      console.error('Error formatting NPWP:', error);
+      return value;
+    }
+  };
   const [industries, setIndustries] = useState([]);
   useEffect(() => {
     const loadIndustries = async () => {
@@ -206,6 +245,7 @@ const CompanyProfile = () => {
                 {...register('npwp')}
                 type='text'
                 className='form-input mt-3'
+                maxLength={16}
               />
             </div>
           </div>
-- 
cgit v1.2.3

