diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-09-23 09:22:29 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-09-23 09:22:29 +0700 |
| commit | c13bb5c6f78032695b24cf8a6c23942eb465c6d5 (patch) | |
| tree | e48c1ab39a61fd5702f578fbfdb7a7375cc1ce43 /src/lib/auth/components/CompanyProfile.jsx | |
| parent | 870bede9df9920b23f2e5cb771ff5ae6448e3ac7 (diff) | |
| parent | 4bd29979c34c1ec3b31dd384829b008eb726769c (diff) | |
Merge branch 'Feature/new-register' into Feature/switch-account
Diffstat (limited to 'src/lib/auth/components/CompanyProfile.jsx')
| -rw-r--r-- | src/lib/auth/components/CompanyProfile.jsx | 64 |
1 files changed, 54 insertions, 10 deletions
diff --git a/src/lib/auth/components/CompanyProfile.jsx b/src/lib/auth/components/CompanyProfile.jsx index cebb15b0..6100e626 100644 --- a/src/lib/auth/components/CompanyProfile.jsx +++ b/src/lib/auth/components/CompanyProfile.jsx @@ -7,23 +7,25 @@ import { useEffect, useState } from 'react'; import { Controller, useForm } from 'react-hook-form'; import { toast } from 'react-hot-toast'; import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; +import { yupResolver } from '@hookform/resolvers/yup'; +import * as Yup from 'yup'; const CompanyProfile = () => { const [changeConfirmation, setChangeConfirmation] = useState(false); const auth = useAuth(); const [isOpen, setIsOpen] = useState(false); const toggle = () => setIsOpen(!isOpen); - const { register, setValue, control, handleSubmit } = useForm({ - defaultValues: { - industry: '', - companyType: '', - name: '', - taxName: '', - npwp: '', - alamat_wajib_pajak: '', - alamat_bisnis: '', - }, + const { + register, + formState: { errors }, + setValue, + control, + handleSubmit, + } = useForm({ + resolver: yupResolver(validationSchema), + defaultValues, }); + const [industries, setIndustries] = useState([]); useEffect(() => { const loadIndustries = async () => { @@ -156,6 +158,9 @@ const CompanyProfile = () => { <HookFormSelect {...props} options={industries} /> )} /> + <div className='text-caption-2 text-danger-500 mt-1'> + {errors.industry?.message} + </div> </div> <div className='flex flex-wrap'> <div className='w-full mb-3'>Badan Usaha</div> @@ -167,6 +172,9 @@ const CompanyProfile = () => { <HookFormSelect {...props} options={companyTypes} /> )} /> + <div className='text-caption-2 text-danger-500 mt-1'> + {errors.companyType?.message} + </div> </div> <div className='w-9/12 pl-1'> <input @@ -175,6 +183,9 @@ const CompanyProfile = () => { className='form-input' placeholder='Cth: Indoteknik Dotcom Gemilang' /> + <div className='text-caption-2 text-danger-500 mt-1'> + {errors.name?.message} + </div> </div> </div> <div> @@ -184,6 +195,9 @@ const CompanyProfile = () => { type='text' className='form-input mt-3' /> + <div className='text-caption-2 text-danger-500 mt-1'> + {errors.taxName?.message} + </div> </div> <div> <label>Alamat Wajib Pajak</label> @@ -192,6 +206,9 @@ const CompanyProfile = () => { type='text' className='form-input mt-3' /> + <div className='text-caption-2 text-danger-500 mt-1'> + {errors.alamat_wajib_pajak?.message} + </div> </div> <div> <label>Alamat Bisnis</label> @@ -200,6 +217,9 @@ const CompanyProfile = () => { type='text' className='form-input mt-3' /> + <div className='text-caption-2 text-danger-500 mt-1'> + {errors.alamat_bisnis?.message} + </div> </div> <div> <label>Nomor NPWP</label> @@ -207,7 +227,11 @@ const CompanyProfile = () => { {...register('npwp')} type='text' className='form-input mt-3' + maxLength={16} /> + <div className='text-caption-2 text-danger-500 mt-1'> + {errors.npwp?.message} + </div> </div> </div> <button type='submit' className='btn-yellow w-full mt-6'> @@ -220,3 +244,23 @@ const CompanyProfile = () => { }; export default CompanyProfile; + +const validationSchema = Yup.object().shape({ + alamat_bisnis: Yup.string().required('Harus di-isi'), + alamat_wajib_pajak: Yup.string().required('Harus di-isi'), + taxName: Yup.string().required('Harus di-isi'), + npwp: Yup.string().required('Harus di-isi'), + name: Yup.string().required('Harus di-isi'), + industry: Yup.string().required('Harus di-pilih'), + companyType: Yup.string().required('Harus di-pilih'), +}); + +const defaultValues = { + industry: '', + companyType: '', + name: '', + taxName: '', + npwp: '', + alamat_wajib_pajak: '', + alamat_bisnis: '', +}; |
