diff --git a/src/core/actions/next-action.interface.ts b/src/core/actions/next-action.interface.ts index e5f29b9..e0c982f 100644 --- a/src/core/actions/next-action.interface.ts +++ b/src/core/actions/next-action.interface.ts @@ -1,8 +1,12 @@ import { CheckStatusAction } from './check-status.action.type'; +import { ShowErrorsAction } from './show-errors.action.type'; +import { ShowFieldStateAction } from './show-field-state.action.type'; import { ShowFieldsAction } from './show-fields.action.type'; import { StatusUpdatedAction } from './status-updated.action.type'; export type NextAction = | CheckStatusAction | ShowFieldsAction - | StatusUpdatedAction; + | StatusUpdatedAction + | ShowErrorsAction + | ShowFieldStateAction; diff --git a/src/core/actions/show-errors.action.type.ts b/src/core/actions/show-errors.action.type.ts new file mode 100644 index 0000000..26632cb --- /dev/null +++ b/src/core/actions/show-errors.action.type.ts @@ -0,0 +1,13 @@ +import { FormError } from '../form/form-error.interface'; +import { Action } from './action.interface'; + +export type ShowErrorsActionType = 'show_errors'; + +export interface ShowErrorsActionData { + errors: FormError[] | null; +} + +export type ShowErrorsAction = Action< + ShowErrorsActionType, + ShowErrorsActionData +>; diff --git a/src/core/actions/show-field-state.action.type.ts b/src/core/actions/show-field-state.action.type.ts new file mode 100644 index 0000000..d23cca3 --- /dev/null +++ b/src/core/actions/show-field-state.action.type.ts @@ -0,0 +1,21 @@ +import { Action } from './action.interface'; + +enum FieldStatus { + valid = 'VALID', + invalid = 'INVALID', + pending = 'PENDING', + disabled = 'DISABLED', +} + +export type ShowFieldStateActionType = 'show_field_state'; + +export interface ShowFieldStateActionData { + fieldName: string; + fieldState: FieldStatus; + error: { code: string; message: string } | null; +} + +export type ShowFieldStateAction = Action< + ShowFieldStateActionType, + ShowFieldStateActionData +>; diff --git a/src/core/actions/show-fields.action.type.ts b/src/core/actions/show-fields.action.type.ts index f8eaa7a..7d91190 100644 --- a/src/core/actions/show-fields.action.type.ts +++ b/src/core/actions/show-fields.action.type.ts @@ -6,8 +6,8 @@ import { FormError } from '../form/form-error.interface'; export type ShowFieldsActionType = 'show_fields'; export interface ShowFieldsActionData { fields: Field[]; - errors: FormMessage[] | null; - messages: FormError[] | undefined; + errors: FormError[] | undefined; + messages: FormMessage[] | null; order?: object; } export type ShowFieldsAction = Action<