diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-09-18 17:18:47 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-09-18 17:18:47 +0700 |
| commit | fad165af76bb008076e96199f173fbe27b7835a8 (patch) | |
| tree | 95931d7046f6f621e274fef2e3eba32cfb516127 /src/lib | |
| parent | baa9b1e32c0afabf074f6c181274312d757a7099 (diff) | |
<iman> update alamat yang sama
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/auth/components/CompanyProfile.jsx | 40 |
1 files changed, 40 insertions, 0 deletions
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> |
