From 88026798dbc0869bd00f0ad923b24c80fbc2e4a2 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 27 Dec 2024 10:29:19 +0100 Subject: [PATCH] Type validation actions --- .../src/components/grid/stores/validation.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/frontend-core/src/components/grid/stores/validation.ts b/packages/frontend-core/src/components/grid/stores/validation.ts index f118020b16..9db432d1a5 100644 --- a/packages/frontend-core/src/components/grid/stores/validation.ts +++ b/packages/frontend-core/src/components/grid/stores/validation.ts @@ -10,7 +10,17 @@ interface DerivedValidationStore { validationRowLookupMap: Readable> } -export type Store = ValidationStore & DerivedValidationStore +interface ValidationActions { + validation: ValidationStore["validation"] & { + actions: { + setError: (cellId: string | undefined, error: string) => void + rowHasErrors: (rowId: string) => boolean + focusFirstRowError: (rowId: string) => void + } + } +} + +export type Store = ValidationStore & DerivedValidationStore & ValidationActions // Normally we would break out actions into the explicit "createActions" // function, but for validation all these actions are pure so can go into @@ -49,7 +59,7 @@ export const deriveStores = (context: StoreContext): DerivedValidationStore => { } } -export const createActions = (context: StoreContext) => { +export const createActions = (context: StoreContext): ValidationActions => { const { validation, focusedCellId, validationRowLookupMap } = context const setError = (cellId: string | undefined, error: string) => {