diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-10-21 16:16:34 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-10-21 16:16:34 +0700 |
| commit | 3a0f3c6ed7ef886d3205d51937b1ecbb035b1a87 (patch) | |
| tree | ded50fbc40919b389088e1e983637b85fa1eb04e /src-migrate/modules | |
| parent | c61477111b95d83a9b862f242923b911364f3612 (diff) | |
<iman> update and fix section dokumen
Diffstat (limited to 'src-migrate/modules')
| -rw-r--r-- | src-migrate/modules/register/stores/usePengajuanTempoStore.ts | 41 |
1 files changed, 41 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 }); + // } + // } + }, +})); |
