summaryrefslogtreecommitdiff
path: root/src-migrate
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-10-21 16:16:34 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-10-21 16:16:34 +0700
commit3a0f3c6ed7ef886d3205d51937b1ecbb035b1a87 (patch)
treeded50fbc40919b389088e1e983637b85fa1eb04e /src-migrate
parentc61477111b95d83a9b862f242923b911364f3612 (diff)
<iman> update and fix section dokumen
Diffstat (limited to 'src-migrate')
-rw-r--r--src-migrate/modules/register/stores/usePengajuanTempoStore.ts41
-rw-r--r--src-migrate/types/tempo.ts9
-rw-r--r--src-migrate/validations/tempo.ts12
3 files changed, 62 insertions, 0 deletions
diff --git a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts
index e531c3d0..08053e42 100644
--- a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts
+++ b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts
@@ -3,11 +3,13 @@ import {
TempoProps,
TempoPropsKontakPerson,
TempoPropsPengiriman,
+ TempoPropsSupplier,
} from '~/types/tempo';
import {
TempoSchema,
TempoSchemaKontakPerson,
TempoSchemaPengiriman,
+ TempoSchemaSupplier,
} from '~/validations/tempo';
import { boolean, ZodError } from 'zod';
@@ -260,3 +262,42 @@ export const usePengajuanTempoStorePengiriman = create<
},
}),
}));
+
+type StateSupplier = {
+ formSupplier: TempoPropsSupplier[];
+ errorsSupplier: {
+ [key in keyof TempoPropsSupplier]?: string;
+ };
+};
+type ActionSupplier = {
+ updateFormSupplier: (data: TempoPropsSupplier[]) => void;
+
+ validateSupplier: () => void;
+};
+export const usePengajuanTempoStoreSupplier = create<
+ StateSupplier & ActionSupplier
+>((set, get) => ({
+ formSupplier: [],
+ updateFormSupplier: (data) => {
+ set(() => ({
+ formSupplier: data, // Menyimpan data baru ke dalam formSupplier
+ }));
+ },
+
+ errorsSupplier: {},
+ validateSupplier: () => {
+ // try {
+ // TempoSchemaSupplier.parse(get().formSupplier);
+ // set({ errorsSupplier: {} });
+ // } catch (error) {
+ // if (error instanceof ZodError) {
+ // const errorsSupplier: StateSupplier['errorsSupplier'] = {};
+ // error.errors.forEach(
+ // (e) =>
+ // (errorsSupplier[e.path[0] as keyof TempoPropsSupplier] = e.message)
+ // );
+ // set({ errorsSupplier });
+ // }
+ // }
+ },
+}));
diff --git a/src-migrate/types/tempo.ts b/src-migrate/types/tempo.ts
index b40ef8d7..17c4c906 100644
--- a/src-migrate/types/tempo.ts
+++ b/src-migrate/types/tempo.ts
@@ -2,6 +2,7 @@ import {
TempoSchema,
TempoSchemaKontakPerson,
TempoSchemaPengiriman,
+ TempoSchemaSupplier,
} from '~/validations/tempo';
import { OdooApiRes } from './odoo';
import { z } from 'zod';
@@ -60,12 +61,20 @@ export type tempoPropsPengiriman = {
dokumenPengirimanInvoice: string;
dokumenPengirimanInvoiceInput: string;
};
+export type tempoPropsSupplier = {
+ supplier: string;
+ pic: string;
+ telepon: string;
+ durasiTempo: string;
+ creditLimit: string;
+};
export type TempoApiProps = OdooApiRes<TempoProps>;
export type TempoProps = z.infer<typeof TempoSchema>;
export type TempoPropsKontakPerson = z.infer<typeof TempoSchemaKontakPerson>;
export type TempoPropsPengiriman = z.infer<typeof TempoSchemaPengiriman>;
+export type TempoPropsSupplier = z.infer<typeof TempoSchemaSupplier>;
export type TempoResApiProps = {
Tempo: boolean;
diff --git a/src-migrate/validations/tempo.ts b/src-migrate/validations/tempo.ts
index 9a0df8bb..86bcf6d1 100644
--- a/src-migrate/validations/tempo.ts
+++ b/src-migrate/validations/tempo.ts
@@ -95,3 +95,15 @@ export const TempoSchemaPengiriman = z.object({
}),
dokumenPengirimanInvoiceInput: z.string().optional(),
});
+export const TempoSchemaSupplier = z.object({
+ supplier: z.string().min(1, { message: 'Nama supplier harus diisi' }),
+ pic: z.string().min(1, { message: 'Nama PIC harus diisi' }),
+ telepon: z
+ .string()
+ .min(1, { message: 'Nomor telepon harus diisi' })
+ .refine((val) => /^\d{10,12}$/.test(val), {
+ message: 'Format nomor telepon tidak valid, contoh: 081234567890',
+ }),
+ durasiTempo: z.string().min(1, { message: 'Durasi tempo harus diisi' }),
+ creditLimit: z.string().min(1, { message: 'Limit Kredit harus diisi' }),
+});