summaryrefslogtreecommitdiff
path: root/src-migrate/modules/register/components
diff options
context:
space:
mode:
Diffstat (limited to 'src-migrate/modules/register/components')
-rw-r--r--src-migrate/modules/register/components/Form.tsx20
-rw-r--r--src-migrate/modules/register/components/FormBisnis.tsx50
-rw-r--r--src-migrate/modules/register/components/RegistrasiBisnis.tsx21
3 files changed, 45 insertions, 46 deletions
diff --git a/src-migrate/modules/register/components/Form.tsx b/src-migrate/modules/register/components/Form.tsx
index c4789e9a..5e5e0a11 100644
--- a/src-migrate/modules/register/components/Form.tsx
+++ b/src-migrate/modules/register/components/Form.tsx
@@ -37,16 +37,16 @@ const Form: React.FC<FormProps> = ({ type, required, isBisnisRegist=false }) =>
updateForm(name, value)
// if(!isBisnisRegist){
- updateForm('type_acc',`individu`)
- updateForm('is_pkp','false')
- updateForm('business_name','Iman')
- updateForm('company_type_id','0')
- updateForm('email_partner','it@fixcomart.co.id')
- updateForm('industry_id','0')
- updateForm('nama_wajib_pajak','Iman')
- updateForm('npwp','958666666688888')
- updateForm('npwp_document','adsdad.pdf')
- updateForm('sppkp_document','fdddwedw.pdf')
+ // updateForm('type_acc',`individu`)
+ // updateForm('is_pkp','false')
+ // updateForm('business_name','Iman')
+ // updateForm('company_type_id','0')
+ // updateForm('email_partner','it@fixcomart.co.id')
+ // updateForm('industry_id','0')
+ // updateForm('nama_wajib_pajak','Iman')
+ // updateForm('npwp','958666666688888')
+ // updateForm('npwp_document','adsdad.pdf')
+ // updateForm('sppkp_document','fdddwedw.pdf')
// }
validate()
}
diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx
index f969efdf..5d15ab6c 100644
--- a/src-migrate/modules/register/components/FormBisnis.tsx
+++ b/src-migrate/modules/register/components/FormBisnis.tsx
@@ -28,17 +28,15 @@ interface companyType {
label: string;
}
-const FormBisnis: React.FC<FormProps> = ({ type, required, isPKP }) => {
+const form: React.FC<FormProps> = ({ type, required, isPKP }) => {
const {
form,
- formBisnis,
isCheckedTNC,
isValidCaptcha,
errors,
- updateFormBisnis,
- validateFormBisnis,
+ updateForm,
+ validate
} = useRegisterStore()
- console.log("errors bisnis",errors)
const { control, watch, setValue } = useForm();
const [selectedCategory, setSelectedCategory] = useState<string>('');
const [selectedCompanyId, setSelectedCompanyId] = useState<string>('');
@@ -61,18 +59,18 @@ const FormBisnis: React.FC<FormProps> = ({ type, required, isPKP }) => {
useEffect(() => {
const selectedCompanyType = companyTypes.find(company => company.value === watch('companyType'));
if (selectedCompanyType) {
- updateFormBisnis("company_type_id", `${selectedCompanyType?.value}`);
+ updateForm("company_type_id", `${selectedCompanyType?.value}`);
setSelectedCompanyId(selectedCompanyType?.label)
- validateFormBisnis();
+ validate();
}
}, [watch('companyType'), companyTypes]);
useEffect(() => {
const selectedIndustryType = industries.find(industry => industry.value === watch('industry_id'));
if (selectedIndustryType) {
- updateFormBisnis("industry_id", `${selectedIndustryType?.value}`);
+ updateForm("industry_id", `${selectedIndustryType?.value}`);
setSelectedCategory(selectedIndustryType.category);
- validateFormBisnis();
+ validate();
}
}, [watch('industry_id'), industries]);
@@ -86,14 +84,14 @@ const FormBisnis: React.FC<FormProps> = ({ type, required, isPKP }) => {
const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {
const { name, value } = event.target;
- updateFormBisnis('type_acc',`business`)
- updateFormBisnis('is_pkp',`${isPKP}`)
- updateFormBisnis(name, value);
- updateFormBisnis('name',form.name);
- updateFormBisnis('email',form.email);
- updateFormBisnis('password',form.password);
- updateFormBisnis('phone',form.phone);
- validateFormBisnis();
+ updateForm('type_acc',`business`)
+ updateForm('is_pkp',`${isPKP}`)
+ updateForm(name, value);
+ updateForm('name',form.name);
+ updateForm('email',form.email);
+ updateForm('password',form.password);
+ updateForm('phone',form.phone);
+ validate();
};
const handleFileChange = async (event: ChangeEvent<HTMLInputElement>) => {
@@ -120,8 +118,8 @@ const FormBisnis: React.FC<FormProps> = ({ type, required, isPKP }) => {
}
fileBase64 = await getFileBase64(file);
}
- updateFormBisnis(name, fileBase64);
- validateFormBisnis();
+ updateForm(name, fileBase64);
+ validate();
}
};
@@ -132,12 +130,12 @@ const FormBisnis: React.FC<FormProps> = ({ type, required, isPKP }) => {
const handleSubmit = async (e: ChangeEvent<HTMLFormElement>) => {
e.preventDefault();
- const response = await mutation.mutateAsync(formBisnis);
+ const response = await mutation.mutateAsync(form);
if (response?.register === true) {
const urlParams = new URLSearchParams({
activation: 'otp',
- email: formBisnis.email,
+ email: form.email,
redirect: (router.query?.next || '/') as string
});
router.push(`${router.route}?${urlParams}`);
@@ -177,7 +175,7 @@ const FormBisnis: React.FC<FormProps> = ({ type, required, isPKP }) => {
id='email_partner'
name='email_partner'
placeholder='example@email.com'
- value={!required ? formBisnis.email_partner : ''}
+ value={!required ? form.email_partner : ''}
className={`form-input mt-3 ${required ? 'cursor-no-drop' : ''}`}
disabled={required}
contentEditable={required}
@@ -212,7 +210,7 @@ const FormBisnis: React.FC<FormProps> = ({ type, required, isPKP }) => {
className="form-input h-full "
placeholder="Nama Perusahaan"
autoCapitalize="true"
- value={formBisnis.business_name}
+ value={form.business_name}
aria-invalid={!!errors.business_name}
onChange={handleInputChange}
/>
@@ -245,7 +243,7 @@ const FormBisnis: React.FC<FormProps> = ({ type, required, isPKP }) => {
id='nama_wajib_pajak'
name='nama_wajib_pajak'
placeholder='Masukan nama lengkap anda'
- value={!required? formBisnis.nama_wajib_pajak : ''}
+ value={!required? form.nama_wajib_pajak : ''}
className={`form-input mt-3 ${required ? 'cursor-no-drop' : ''}`}
disabled={required}
contentEditable={required}
@@ -269,7 +267,7 @@ const FormBisnis: React.FC<FormProps> = ({ type, required, isPKP }) => {
contentEditable={required}
readOnly={required}
placeholder='000.000.000.0-000.000'
- value={!required ? formBisnis.npwp : ''}
+ value={!required ? form.npwp : ''}
onChange={handleInputChange}
aria-invalid={isPKP && !required && !!errors.npwp}
/>
@@ -324,4 +322,4 @@ const FormBisnis: React.FC<FormProps> = ({ type, required, isPKP }) => {
)
}
-export default FormBisnis;
+export default form;
diff --git a/src-migrate/modules/register/components/RegistrasiBisnis.tsx b/src-migrate/modules/register/components/RegistrasiBisnis.tsx
index 6ace27f9..b8ea5fff 100644
--- a/src-migrate/modules/register/components/RegistrasiBisnis.tsx
+++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx
@@ -29,13 +29,11 @@ const RegistrasiBisnis = () => {
const [selectedValueBisnis, setSelectedValueBisnis] = useState('false');
const {
form,
- formBisnis,
isCheckedTNC,
isValidCaptcha,
errors,
- updateFormBisnis,
- validateFormBisnis,
validate,
+ updateForm
} = useRegisterStore()
const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors])
const toast = useToast()
@@ -45,18 +43,18 @@ const RegistrasiBisnis = () => {
useEffect(() => {
if (selectedValue === "PKP") {
- updateFormBisnis("is_pkp", 'true');
- validateFormBisnis();
+ updateForm("is_pkp", 'true');
+ validate();
} else {
- updateFormBisnis("is_pkp", 'false');
- validateFormBisnis();
+ updateForm("is_pkp", 'false');
+ validate();
}
}, [selectedValue,]);
const handleChange = (value: string) => {
setSelectedValue(value);
if (value === "PKP") {
- validateFormBisnis();
+ validate();
setIsIndividuRequired(true);
setIsPKP(true);
} else {
@@ -68,9 +66,12 @@ const RegistrasiBisnis = () => {
const handleChangeBisnis = (value: string) => {
setSelectedValueBisnis(value);
+ console.log('value',value)
if (value === "true") {
+ updateForm('is_terdaftar','true')
setIsTerdaftar(true);
} else {
+ updateForm('is_terdaftar','false')
setIsTerdaftar(false);
}
};
@@ -85,8 +86,8 @@ const RegistrasiBisnis = () => {
const handleSubmit = async () => {
console.log("form",form)
- console.log("form Bisnis",formBisnis)
- const response = await mutation.mutateAsync(formBisnis)
+ console.log("form Bisnis",form)
+ const response = await mutation.mutateAsync(form)
console.log("response",response)