summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src-migrate/modules/register/components/FormBisnis.tsx12
-rw-r--r--src-migrate/modules/register/stores/useRegisterStore.ts8
-rw-r--r--src-migrate/validations/auth.ts11
3 files changed, 19 insertions, 12 deletions
diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx
index dec1bbf8..42d7aaa3 100644
--- a/src-migrate/modules/register/components/FormBisnis.tsx
+++ b/src-migrate/modules/register/components/FormBisnis.tsx
@@ -23,7 +23,7 @@ interface Industry {
category: string;
}
-interface CompanyType {
+interface company_type_id {
value: string;
label: string;
}
@@ -43,7 +43,7 @@ const FormBisnis: React.FC<FormProps> = ({ type, required, isPKP }) => {
const [selectedCompanyId, setSelectedCompanyId] = useState<string>('');
const [industries, setIndustries] = useState<Industry[]>([]);
- const [companyTypes, setCompanyTypes] = useState<CompanyType[]>([]);
+ const [companyTypes, setCompanyTypes] = useState<company_type_id[]>([]);
const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]);
const router = useRouter();
@@ -58,13 +58,13 @@ const FormBisnis: React.FC<FormProps> = ({ type, required, isPKP }) => {
}, []);
useEffect(() => {
- const selectedCompanyType = companyTypes.find(company => company.value === watch('companyType'));
+ const selectedCompanyType = companyTypes.find(company => company.value === watch('company_type_id'));
if (selectedCompanyType) {
updateFormBisnis("company_type_id", selectedCompanyType?.value);
setSelectedCompanyId(selectedCompanyType?.label)
validateFormBisnis();
}
- }, [watch('companyType'), companyTypes]);
+ }, [watch('company_type_id'), companyTypes]);
useEffect(() => {
const selectedIndustryType = industries.find(industry => industry.value === watch('industry'));
@@ -183,11 +183,11 @@ const FormBisnis: React.FC<FormProps> = ({ type, required, isPKP }) => {
<div className="flex justify-between items-start gap-2 h-12">
<div className='w-4/5 pr-1'>
<Controller
- name='companyType'
+ name='company_type_id'
control={control}
render={(props) => <HookFormSelect {...props} options={companyTypes} disabled={required} placeholder="Badan Usaha"/>}
/>
- {!required && !!errors.companyType && <span className="form-msg-danger">{errors.companyType}</span>}
+ {!required && !!errors.company_type_id && <span className="form-msg-danger">{errors.company_type_id}</span>}
</div>
<div className="w-[120%]">
<input
diff --git a/src-migrate/modules/register/stores/useRegisterStore.ts b/src-migrate/modules/register/stores/useRegisterStore.ts
index 7b414ec6..de237b0d 100644
--- a/src-migrate/modules/register/stores/useRegisterStore.ts
+++ b/src-migrate/modules/register/stores/useRegisterStore.ts
@@ -28,7 +28,7 @@ type Action = {
export const useRegisterStore = create<State & Action>((set, get) => ({
form: {
business_name: '',
- companyType: '',
+ company_type_id: 0,
name: '',
email: '',
email_partner: '',
@@ -37,7 +37,7 @@ export const useRegisterStore = create<State & Action>((set, get) => ({
sppkp_document: '',
npwp_document: '',
nameWajibPajak: '',
- industry: '',
+ industry: { value: '', label: '' },
badanUsaha: '',
jenisUsaha: '',
npwp: '',
@@ -45,7 +45,7 @@ export const useRegisterStore = create<State & Action>((set, get) => ({
is_pkp: '',
},
formBisnis: {
- companyType: '',
+ company_type_id: 0,
business_name: '',
name: '',
nama_wajib_pajak : '',
@@ -56,7 +56,7 @@ export const useRegisterStore = create<State & Action>((set, get) => ({
sppkp_document: '',
npwp_document: '',
nameWajibPajak: '',
- industry: '',
+ industry: { value: '', label: '' },
badanUsaha: '',
jenisUsaha: '',
npwp: '',
diff --git a/src-migrate/validations/auth.ts b/src-migrate/validations/auth.ts
index 9bd3af07..23b033a7 100644
--- a/src-migrate/validations/auth.ts
+++ b/src-migrate/validations/auth.ts
@@ -16,13 +16,20 @@ 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.string().min(1, { message: 'Jenis usaha harus dipiliih' }),
+ industry: z.object({
+ value: z.string().min(1, { message: 'Jenis usaha harus dipilih' }),
+ label: z.string().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' }),
- companyType: z.string().min(1, { message: 'Badan usaha wajib 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()
.min(15, { message: 'Format NPWP tidak valid, NPWP harus terdiri dari 15 digit angka.' })