Skip to content

Commit

Permalink
feat(PAYMENTS-15271): show errors show field state actions
Browse files Browse the repository at this point in the history
  • Loading branch information
KonstantinKamenskiy committed Sep 9, 2023
1 parent e030f2a commit 1b31e0e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/core/actions/next-action.interface.ts
Original file line number Diff line number Diff line change
@@ -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;
13 changes: 13 additions & 0 deletions src/core/actions/show-errors.action.type.ts
Original file line number Diff line number Diff line change
@@ -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
>;
21 changes: 21 additions & 0 deletions src/core/actions/show-field-state.action.type.ts
Original file line number Diff line number Diff line change
@@ -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
>;
4 changes: 2 additions & 2 deletions src/core/actions/show-fields.action.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down

0 comments on commit 1b31e0e

Please sign in to comment.