summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/auth/components/SwitchAccount.jsx37
1 files changed, 25 insertions, 12 deletions
diff --git a/src/lib/auth/components/SwitchAccount.jsx b/src/lib/auth/components/SwitchAccount.jsx
index 12d00890..9adcc726 100644
--- a/src/lib/auth/components/SwitchAccount.jsx
+++ b/src/lib/auth/components/SwitchAccount.jsx
@@ -39,8 +39,15 @@ const SwitchAccount = ({ company_type }) => {
mutationFn: (data) => registerUser(data),
});
const [notValid, setNotValid] = useState(false);
- const { form, isCheckedTNC, isValidCaptcha, errors, validate, updateForm } =
- useRegisterStore();
+ const {
+ form,
+ isCheckedTNC,
+ isValidCaptcha,
+ errors,
+ validate,
+ updateForm,
+ resetForm,
+ } = useRegisterStore();
const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]);
useEffect(() => {
const loadProfile = async () => {
@@ -79,15 +86,17 @@ const SwitchAccount = ({ company_type }) => {
if (dataProfile?.companyType === 'nonpkp') {
setSelectedValue('PKP');
}
- updateForm('email_partner', dataProfile?.email_partner);
- updateForm('business_name', dataProfile?.name);
- updateForm('industry_id', `${dataProfile?.industryId}`);
- updateForm('company_type_id', `${dataProfile?.companyTypeId}`);
- updateForm('nama_wajib_pajak', dataProfile?.taxName);
- updateForm('npwp', dataProfile?.npwp);
- updateForm('alamat_wajib_pajak', dataProfile?.alamatWajibPajak);
- updateForm('alamat_bisnis', dataProfile?.alamatBisnis);
- validate();
+ if (auth?.company) {
+ updateForm('email_partner', dataProfile?.email_partner);
+ updateForm('business_name', dataProfile?.name);
+ updateForm('industry_id', `${dataProfile?.industryId}`);
+ updateForm('company_type_id', `${dataProfile?.companyTypeId}`);
+ updateForm('nama_wajib_pajak', dataProfile?.taxName);
+ updateForm('npwp', dataProfile?.npwp);
+ updateForm('alamat_wajib_pajak', dataProfile?.alamatWajibPajak);
+ updateForm('alamat_bisnis', dataProfile?.alamatBisnis);
+ validate();
+ }
};
if (auth) loadProfile();
}, [auth, setValue]);
@@ -97,9 +106,10 @@ const SwitchAccount = ({ company_type }) => {
updateForm('password', 'example@mail.com');
updateForm('phone', '081234567890');
validate();
- }, []);
+ }, [buttonSubmitClick, changeConfirmation]);
const handleChangeBisnis = (value) => {
+ resetForm();
setSelectedValueBisnis(value);
if (value === 'true') {
validate();
@@ -121,9 +131,12 @@ const SwitchAccount = ({ company_type }) => {
}
};
const onSubmitHandler = async (values) => {
+ console.log('error', errors);
+ console.log('form', form);
setChangeConfirmation(false);
// let data = { ...form, id: `${auth.partnerId}` };
const data = form;
+ console.log('data', data);
if (!isFormValid) {
setNotValid(true);
setButtonSubmitClick(!buttonSubmitClick);