summaryrefslogtreecommitdiff
path: root/src/lib/auth/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/auth/components')
-rw-r--r--src/lib/auth/components/CompanyProfile.jsx40
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>