summaryrefslogtreecommitdiff
path: root/src-migrate
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-10-18 10:39:40 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-10-18 10:39:40 +0700
commit661d742193b62aeb3d2a2350433bdd3714667625 (patch)
treeb76533a91025136daf8efdd64bd1a4aacb4c71b5 /src-migrate
parentead46a6d760850530946926b390a8954ca64e1c2 (diff)
<iman> add kontak perusahaan
Diffstat (limited to 'src-migrate')
-rw-r--r--src-migrate/modules/register/stores/usePengajuanTempoStore.ts89
-rw-r--r--src-migrate/types/tempo.ts16
-rw-r--r--src-migrate/validations/tempo.ts29
3 files changed, 54 insertions, 80 deletions
diff --git a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts
index 8891e6ea..247f62dd 100644
--- a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts
+++ b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts
@@ -93,83 +93,64 @@ export const usePengajuanTempoStore = create<State & Action>((set, get) => ({
}));
type StateKontakPerson = {
- form: TempoPropsKontakPerson;
- errors: {
+ formKontakPerson: TempoPropsKontakPerson;
+ errorsKontakPerson: {
[key in keyof TempoPropsKontakPerson]?: string;
};
- isCheckedTNC: boolean;
- isOpenTNC: boolean;
- isValidCaptcha: boolean;
+};
+type ActionKontakPerson = {
+ updateFormKontakPerson: (name: string, value: string) => void;
+
+ validateKontakPerson: () => void;
+ resetFormKontakPerson: () => void;
};
export const usePengajuanTempoStoreKontakPerson = create<
- StateKontakPerson & Action
+ StateKontakPerson & ActionKontakPerson
>((set, get) => ({
- form: {
+ formKontakPerson: {
direkturName: '',
direkturMobile: '',
direkturEmail: '',
- industry_id: '',
- street: '',
- state: '',
- city: '',
- zip: '',
- bankName: '',
- accountName: '',
- accountNumber: '',
- estimasi: '',
- tempoDuration: '',
- bersedia: '',
- categoryProduk: '',
- tempoLimit: '',
+ purchasingName: '',
+ purchasingEmail: '',
+ financeMobile: '',
+ financeName: '',
+ financeEmail: '',
},
- updateForm: (name, value) =>
- set((state) => ({ form: { ...state.form, [name]: value } })),
+ updateFormKontakPerson: (name, value) =>
+ set((state) => ({
+ formKontakPerson: { ...state.formKontakPerson, [name]: value },
+ })),
- errors: {},
- validate: () => {
+ errorsKontakPerson: {},
+ validateKontakPerson: () => {
try {
- TempoSchemaKontakPerson.parse(get().form);
- set({ errors: {} });
+ TempoSchemaKontakPerson.parse(get().formKontakPerson);
+ set({ errorsKontakPerson: {} });
} catch (error) {
if (error instanceof ZodError) {
- const errors: StateKontakPerson['errors'] = {};
+ const errorsKontakPerson: StateKontakPerson['errorsKontakPerson'] = {};
error.errors.forEach(
- (e) => (errors[e.path[0] as keyof TempoPropsKontakPerson] = e.message)
+ (e) =>
+ (errorsKontakPerson[e.path[0] as keyof TempoPropsKontakPerson] =
+ e.message)
);
- set({ errors });
+ set({ errorsKontakPerson });
}
}
},
- isCheckedTNC: false,
- toggleCheckTNC: () => set((state) => ({ isCheckedTNC: !state.isCheckedTNC })),
-
- isOpenTNC: false,
- openTNC: () => set(() => ({ isOpenTNC: true })),
- closeTNC: () => set(() => ({ isOpenTNC: false })),
-
- isValidCaptcha: false,
- updateValidCaptcha: (value) => set(() => ({ isValidCaptcha: value })),
-
- resetForm: () =>
+ resetFormKontakPerson: () =>
set({
- form: {
+ formKontakPerson: {
direkturName: '',
direkturMobile: '',
direkturEmail: '',
- industry_id: '',
- street: '',
- state: '',
- city: '',
- zip: '',
- bankName: '',
- accountName: '',
- accountNumber: '',
- estimasi: '',
- tempoDuration: '',
- bersedia: '',
- categoryProduk: '',
- tempoLimit: '',
+ purchasingName: '',
+ purchasingEmail: '',
+ financeName: '',
+ financeMobile: '',
+ financeEmail: '',
},
}),
}));
diff --git a/src-migrate/types/tempo.ts b/src-migrate/types/tempo.ts
index a4bd3d0a..fc920c05 100644
--- a/src-migrate/types/tempo.ts
+++ b/src-migrate/types/tempo.ts
@@ -22,17 +22,11 @@ export type tempoPropsKontakPerson = {
direkturName: string;
direkturMobile: string;
direkturEmail: string;
- industry_id: string;
- street: string;
- state: string;
- city: string;
- zip: string;
- bankName: string;
- accountName: string;
- accountNumber: string;
- estimasi: string;
- tempoDuration: string;
- bersedia: string;
+ purchasingName: string;
+ purchasingEmail: string;
+ financeMobile: string;
+ financeEmail: string;
+ financeName: string;
};
export type TempoApiProps = OdooApiRes<TempoProps>;
diff --git a/src-migrate/validations/tempo.ts b/src-migrate/validations/tempo.ts
index dca60869..45cc8cd2 100644
--- a/src-migrate/validations/tempo.ts
+++ b/src-migrate/validations/tempo.ts
@@ -28,31 +28,30 @@ export const TempoSchema = z.object({
});
export const TempoSchemaKontakPerson = z.object({
direkturName: z.string().min(1, { message: 'Nama harus diisi' }),
+ financeName: z.string().min(1, { message: 'Nama harus diisi' }),
direkturMobile: z
.string()
.min(1, { message: 'Nomor telepon harus diisi' })
.refine((val) => /^\d{10,12}$/.test(val), {
message: 'Format nomor telepon tidak valid, contoh: 081234567890',
}),
+ financeMobile: z
+ .string()
+ .min(1, { message: 'Nomor telepon harus diisi' })
+ .refine((val) => /^\d{10,12}$/.test(val), {
+ message: 'Format nomor telepon tidak valid, contoh: 081234567890',
+ }),
direkturEmail: z
.string()
.min(1, { message: 'Email harus diisi' })
.email({ message: 'Email harus menggunakan format example@mail.com' }),
- street: z.string().min(1, { message: 'Alamat harus diisi' }),
- industry_id: z.string().min(1, { message: 'Jenis usaha harus dipilih' }),
- zip: z.string().min(1, { message: 'Kode pos harus diisi' }),
- state: z.string().min(1, { message: 'Provinsi harus dipilih' }),
- city: z.string().min(1, { message: 'Kota harus dipilih' }),
- bankName: z.string().min(1, { message: 'Nama bank harus diisi' }),
- accountName: z.string().min(1, { message: 'Nama rekening harus diisi' }),
- accountNumber: z.string().min(1, { message: 'Nomor rekening harus diisi' }),
- estimasi: z
+ purchasingEmail: z
.string()
- .min(1, { message: 'Estimasi pemmbelian pertahun harus diisi' }),
- tempoDuration: z.string().min(1, { message: 'Durasi tempo harus dipilih' }),
- tempoLimit: z.string().min(1, { message: 'Limit tempo harus dipilih' }),
- bersedia: z.string().min(1, { message: 'Harus dipilih' }),
- categoryProduk: z
+ .min(1, { message: 'Email harus diisi' })
+ .email({ message: 'Email harus menggunakan format example@mail.com' }),
+ financeEmail: z
.string()
- .min(1, { message: 'Category produk harus dipilih' }),
+ .min(1, { message: 'Email harus diisi' })
+ .email({ message: 'Email harus menggunakan format example@mail.com' }),
+ purchasingName: z.string().min(1, { message: 'Nama harus diisi' }),
});