summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-09-18 17:18:47 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-09-18 17:18:47 +0700
commitfad165af76bb008076e96199f173fbe27b7835a8 (patch)
tree95931d7046f6f621e274fef2e3eba32cfb516127
parentbaa9b1e32c0afabf074f6c181274312d757a7099 (diff)
<iman> update alamat yang sama
-rw-r--r--src-migrate/modules/register/components/FormBisnis.tsx18
-rw-r--r--src/lib/auth/components/CompanyProfile.jsx40
2 files changed, 57 insertions, 1 deletions
diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx
index 70ed6bee..bf00c28e 100644
--- a/src-migrate/modules/register/components/FormBisnis.tsx
+++ b/src-migrate/modules/register/components/FormBisnis.tsx
@@ -48,6 +48,7 @@ const form: React.FC<FormProps> = ({
buttonSubmitClick,
}) => {
const { form, errors, updateForm, validate } = useRegisterStore();
+ console.log('form', form);
const { control, watch, setValue } = useForm();
const [selectedCategory, setSelectedCategory] = useState<string>('');
const [isChekBox, setIsChekBox] = useState<boolean>(false);
@@ -128,9 +129,23 @@ const form: React.FC<FormProps> = ({
const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {
const { name, value } = event.target;
- updateForm('type_acc', `business`);
+
+ updateForm('type_acc', 'business');
updateForm('is_pkp', `${isPKP}`);
+
+ // Update form dengan nilai terbaru dari input yang berubah
updateForm(name, value);
+
+ // Jika checkbox aktif, sinkronisasi alamat_wajib_pajak dengan alamat_bisnis
+ if (isChekBox) {
+ if (name === 'alamat_wajib_pajak') {
+ updateForm('alamat_bisnis', value);
+ } else if (name === 'alamat_bisnis') {
+ updateForm('alamat_wajib_pajak', value);
+ }
+ }
+
+ // Validasi setelah perubahan dilakukan
validate();
};
@@ -188,6 +203,7 @@ const form: React.FC<FormProps> = ({
useEffect(() => {
if (isChekBox) {
updateForm('isChekBox', 'true');
+ updateForm('alamat_wajib_pajak', `${form.alamat_bisnis}`);
validate();
} else {
updateForm('isChekBox', 'false');
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>