From 935066853ab4847fbff605eed21f98ddbb445864 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 26 Sep 2024 17:02:45 +0700 Subject: update form bisnis --- .../modules/register/components/FormBisnis.tsx | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src-migrate/modules') diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index 6185179f..c88ec735 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -87,16 +87,31 @@ const form: React.FC = ({ label: o.name, })) ); + // setValue('companyType', form.company_type_id); }; loadCompanyTypes(); }, []); + useEffect(() => { + if (form.company_type_id) { + console.log('form.company_type_id', form.company_type_id); + setValue('companyType', form.company_type_id); + } + }, [form.company_type_id]); + useEffect(() => { const selectedCompanyType = companyTypes.find( (company) => company.value === watch('companyType') ); if (selectedCompanyType) { + console.log('selectedCompanyType', selectedCompanyType); updateForm('company_type_id', `${selectedCompanyType?.value}`); + // setCompanyTypes([ + // { + // value: '2', + // label: 'Distributor', + // }, + // ]); validate(); } }, [watch('companyType'), companyTypes]); @@ -122,6 +137,7 @@ const form: React.FC = ({ category: o.category, })) ); + // setValue('industry_id', form.industry_id); }; loadIndustries(); }, []); @@ -582,7 +598,13 @@ const form: React.FC = ({ readOnly={required} ref={npwpRef} placeholder='000.000.000.0-000.000' - value={!required ? formattedNpwp : ''} + value={ + !required + ? formattedNpwp === '' + ? form.npwp + : formattedNpwp + : '' + } maxLength={21} // Set maximum length to 16 characters onChange={(e) => { if (!required) { -- cgit v1.2.3