From bf33cdda7fb249cdd2473e0d1039704fd2171589 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 23 Aug 2024 13:42:20 +0700 Subject: update new register --- src-migrate/modules/register/components/FormBisnis.tsx | 12 ++++++------ src-migrate/modules/register/stores/useRegisterStore.ts | 4 ++-- src-migrate/validations/auth.ts | 9 +-------- 3 files changed, 9 insertions(+), 16 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index 42d7aaa3..b58f2fec 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -17,7 +17,7 @@ interface FormProps { isPKP: boolean; } -interface Industry { +interface industry_id { label: string; value: string; category: string; @@ -42,7 +42,7 @@ const FormBisnis: React.FC = ({ type, required, isPKP }) => { const [selectedCategory, setSelectedCategory] = useState(''); const [selectedCompanyId, setSelectedCompanyId] = useState(''); - const [industries, setIndustries] = useState([]); + const [industries, setIndustries] = useState([]); const [companyTypes, setCompanyTypes] = useState([]); const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]); @@ -67,13 +67,13 @@ const FormBisnis: React.FC = ({ type, required, isPKP }) => { }, [watch('company_type_id'), companyTypes]); useEffect(() => { - const selectedIndustryType = industries.find(industry => industry.value === watch('industry')); + const selectedIndustryType = industries.find(industry => industry.value === watch('industry_id')); if (selectedIndustryType) { updateFormBisnis("industry_id", selectedIndustryType?.value); setSelectedCategory(selectedIndustryType.label); validateFormBisnis(); } - }, [watch('industry'), industries]); + }, [watch('industry_id'), industries]); useEffect(() => { const loadIndustries = async () => { @@ -212,14 +212,14 @@ const FormBisnis: React.FC = ({ type, required, isPKP }) => { Klasifikasi Jenis Usaha } /> {selectedCategory && Kategori : {selectedCategory} } - {!required && !!errors.industry && {errors.industry}} + {!required && !!errors.industry_id && {errors.industry_id}}
diff --git a/src-migrate/modules/register/stores/useRegisterStore.ts b/src-migrate/modules/register/stores/useRegisterStore.ts index de237b0d..2db0b602 100644 --- a/src-migrate/modules/register/stores/useRegisterStore.ts +++ b/src-migrate/modules/register/stores/useRegisterStore.ts @@ -37,7 +37,7 @@ export const useRegisterStore = create((set, get) => ({ sppkp_document: '', npwp_document: '', nameWajibPajak: '', - industry: { value: '', label: '' }, + industry_id: 0, badanUsaha: '', jenisUsaha: '', npwp: '', @@ -56,7 +56,7 @@ export const useRegisterStore = create((set, get) => ({ sppkp_document: '', npwp_document: '', nameWajibPajak: '', - industry: { value: '', label: '' }, + industry_id: 0, badanUsaha: '', jenisUsaha: '', npwp: '', diff --git a/src-migrate/validations/auth.ts b/src-migrate/validations/auth.ts index 23b033a7..fd645ef3 100644 --- a/src-migrate/validations/auth.ts +++ b/src-migrate/validations/auth.ts @@ -16,19 +16,12 @@ export const registerSchema = z.object({ nama_wajib_pajak: z.string().min(1, { message: 'Nama wajib pajak harus diisi' }), sppkp_document: z.string().min(1, { message: 'document harus diisi' }), npwp_document: z.string().min(1, { message: 'document harus diisi' }), - industry: z.object({ - value: z.string().min(1, { message: 'Jenis usaha harus dipilih' }), - label: z.string().min(1, { message: 'Jenis usaha harus dipilih' }), - }), + industry_id: z.number().min(1, { message: 'Jenis usaha harus dipilih' }), email_partner: z .string() .min(1, { message: 'Email harus diisi' }) .email({ message: 'Email harus menggunakan format example@mail.com' }), business_name: z.string().min(1, { message: 'Nama perusahaan harus diisi' }), - // company_type_id: z.object({ - // value: z.string().min(1, { message: 'Badan usaha wajib dipilih' }), - // label: z.string().min(1, { message: 'Badan usaha wajib dipilih' }), - // }), company_type_id: z.number().min(1, { message: 'Badan usaha wajib dipilih' }), npwp: z .string() -- cgit v1.2.3