diff options
| -rw-r--r-- | src-migrate/modules/page-content/index.tsx | 1 | ||||
| -rw-r--r-- | src-migrate/modules/register/components/FormBisnis.tsx | 72 | ||||
| -rw-r--r-- | src/lib/auth/components/SwitchAccount.jsx | 4 |
3 files changed, 43 insertions, 34 deletions
diff --git a/src-migrate/modules/page-content/index.tsx b/src-migrate/modules/page-content/index.tsx index af597641..edecb855 100644 --- a/src-migrate/modules/page-content/index.tsx +++ b/src-migrate/modules/page-content/index.tsx @@ -20,7 +20,6 @@ const PageContent = ({ path }: Props) => { `src="${process.env.NEXT_PUBLIC_ODOO_API_HOST}/web/image` ); }, [data]); - console.log('parsedContent', parsedContent); if (isLoading) return <PageContentSkeleton />; return <div dangerouslySetInnerHTML={{ __html: parsedContent || '' }}></div>; diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index c88ec735..d4fdbbbd 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -1,4 +1,11 @@ -import { ChangeEvent, useEffect, useMemo, useRef, useState } from 'react'; +import { + ChangeEvent, + useEffect, + useMemo, + useRef, + useState, + MouseEvent, +} from 'react'; import { useMutation } from 'react-query'; import { useRegisterStore } from '../stores/useRegisterStore'; import { RegisterProps } from '~/types/auth'; @@ -62,7 +69,6 @@ const form: React.FC<FormProps> = ({ const router = useRouter(); const toast = useToast(); - const emailRef = useRef<HTMLInputElement>(null); const businessNameRef = useRef<HTMLInputElement>(null); const companyTypeRef = useRef<HTMLInputElement>(null); @@ -94,38 +100,14 @@ const form: React.FC<FormProps> = ({ useEffect(() => { if (form.company_type_id) { - console.log('form.company_type_id', form.company_type_id); - setValue('companyType', form.company_type_id); + setValue('companyType', parseInt(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]); - + }, []); useEffect(() => { - const selectedIndustryType = industries.find( - (industry) => industry.value === watch('industry_id') - ); - if (selectedIndustryType) { - updateForm('industry_id', `${selectedIndustryType?.value}`); - setSelectedCategory(selectedIndustryType.category); - validate(); + if (form.industry_id) { + setValue('industry_id', parseInt(form.industry_id)); } - }, [watch('industry_id'), industries]); + }, []); useEffect(() => { const loadIndustries = async () => { @@ -326,6 +308,32 @@ const form: React.FC<FormProps> = ({ }; loadIndustries(); }, [buttonSubmitClick, chekValid]); + + const handleCompanyTypeChange = (event: MouseEvent<HTMLDivElement>) => { + const selectedCompanyTypeValue = watch('companyType'); + const selectedCompanyType = companyTypes.find( + (company) => company.value === selectedCompanyTypeValue + ); + + if (selectedCompanyType !== undefined) { + updateForm('company_type_id', `${selectedCompanyType.value}`); + validate(); + } + }; + useEffect(() => {}, [watch('industry_id'), industries]); + + const handleIndustriIdChange = (event: MouseEvent<HTMLDivElement>) => { + const selectedIndustriIdValue = watch('industry_id'); + const selectedIndustryType = industries.find( + (industry) => industry.value === selectedIndustriIdValue + ); + if (selectedIndustryType) { + updateForm('industry_id', `${selectedIndustryType?.value}`); + setSelectedCategory(selectedIndustryType.category); + validate(); + } + }; + return ( <> <BottomPopup @@ -393,6 +401,7 @@ const form: React.FC<FormProps> = ({ <div className='w-4/5 pr-1 max-h-11 transition-all duration-500' ref={companyTypeRef} + onClick={handleCompanyTypeChange} > <Controller name='companyType' @@ -440,6 +449,7 @@ const form: React.FC<FormProps> = ({ <div className='max-h-10 transition-all duration-500' ref={industryRef} + onClick={handleIndustriIdChange} > <Controller name='industry_id' diff --git a/src/lib/auth/components/SwitchAccount.jsx b/src/lib/auth/components/SwitchAccount.jsx index ad22da0f..14ad7e8a 100644 --- a/src/lib/auth/components/SwitchAccount.jsx +++ b/src/lib/auth/components/SwitchAccount.jsx @@ -79,8 +79,8 @@ const SwitchAccount = () => { } updateForm('email_partner', dataProfile.email_partner); updateForm('business_name', dataProfile.name); - updateForm('industry_id', dataProfile.industryId); - updateForm('company_type_id', dataProfile.companyTypeId); + 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); |
