From 0bca1bfb2bc7e52a31dde39602dd599d7c640e73 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Sat, 24 Aug 2024 08:46:44 +0700 Subject: update new register --- .../modules/register/components/FormBisnis.tsx | 39 +++++++++++++++------- 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'src-migrate/modules/register/components/FormBisnis.tsx') diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index b58f2fec..f969efdf 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -23,13 +23,14 @@ interface industry_id { category: string; } -interface company_type_id { +interface companyType { value: string; label: string; } const FormBisnis: React.FC = ({ type, required, isPKP }) => { const { + form, formBisnis, isCheckedTNC, isValidCaptcha, @@ -43,7 +44,7 @@ const FormBisnis: React.FC = ({ type, required, isPKP }) => { const [selectedCompanyId, setSelectedCompanyId] = useState(''); const [industries, setIndustries] = useState([]); - const [companyTypes, setCompanyTypes] = useState([]); + const [companyTypes, setCompanyTypes] = useState([]); const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]); const router = useRouter(); @@ -58,19 +59,19 @@ const FormBisnis: React.FC = ({ type, required, isPKP }) => { }, []); useEffect(() => { - const selectedCompanyType = companyTypes.find(company => company.value === watch('company_type_id')); + const selectedCompanyType = companyTypes.find(company => company.value === watch('companyType')); if (selectedCompanyType) { - updateFormBisnis("company_type_id", selectedCompanyType?.value); + updateFormBisnis("company_type_id", `${selectedCompanyType?.value}`); setSelectedCompanyId(selectedCompanyType?.label) validateFormBisnis(); } - }, [watch('company_type_id'), companyTypes]); + }, [watch('companyType'), companyTypes]); useEffect(() => { const selectedIndustryType = industries.find(industry => industry.value === watch('industry_id')); if (selectedIndustryType) { - updateFormBisnis("industry_id", selectedIndustryType?.value); - setSelectedCategory(selectedIndustryType.label); + updateFormBisnis("industry_id", `${selectedIndustryType?.value}`); + setSelectedCategory(selectedIndustryType.category); validateFormBisnis(); } }, [watch('industry_id'), industries]); @@ -85,15 +86,29 @@ const FormBisnis: React.FC = ({ type, required, isPKP }) => { const handleInputChange = (event: ChangeEvent) => { const { name, value } = event.target; + updateFormBisnis('type_acc',`business`) + updateFormBisnis('is_pkp',`${isPKP}`) updateFormBisnis(name, value); - updateFormBisnis('name','iman'); - updateFormBisnis('email','it@fixcomart.co.id'); - updateFormBisnis('password','Fixcomart378'); - updateFormBisnis('phone','082339129611'); + updateFormBisnis('name',form.name); + updateFormBisnis('email',form.email); + updateFormBisnis('password',form.password); + updateFormBisnis('phone',form.phone); validateFormBisnis(); }; const handleFileChange = async (event: ChangeEvent) => { + // const file = poFile.current.files[0]; + // const name = poNumber.current.value; + // if (typeof file === 'undefined' || !name) { + // toast.error('Nomor dan Dokumen PO harus diisi'); + // return; + // } + // if (file.size > 5000000) { + // toast.error('Maksimal ukuran file adalah 5MB'); + // return; + // } + // const data = { name, file: await getFileBase64(file) }; + let fileBase64 = ''; const { name} = event.target; const file = event.target.files?.[0]; @@ -183,7 +198,7 @@ const FormBisnis: React.FC = ({ type, required, isPKP }) => {
} /> -- cgit v1.2.3