diff options
Diffstat (limited to 'src/store/form')
| -rw-r--r-- | src/store/form/actions.ts | 14 | ||||
| -rw-r--r-- | src/store/form/reducers.ts | 7 | ||||
| -rw-r--r-- | src/store/form/types.ts | 3 |
3 files changed, 20 insertions, 4 deletions
diff --git a/src/store/form/actions.ts b/src/store/form/actions.ts index 8b48a37..dc43729 100644 --- a/src/store/form/actions.ts +++ b/src/store/form/actions.ts @@ -5,7 +5,8 @@ export enum FormAction { SET_VALUE = "SET_VALUE", SET_ERROR = "SET_ERROR", SET_VALID = "SET_VALID", - CLEAN = "CLEAN" + CLEAN = "CLEAN", + SET_CAPTCHA_TOKEN = "SET_CAPTCHA_TOKEN" } // This is base for all actions @@ -42,7 +43,12 @@ export interface CleanAction extends DefaultFormAction { type: FormAction.CLEAN } -export type Action = SetValueAction | SetErrorAction | SetValidAction | CleanAction; +export interface SetCaptchaTokenAction extends DefaultFormAction { + type: FormAction.SET_CAPTCHA_TOKEN, + payload: string | null +} + +export type Action = SetValueAction | SetErrorAction | SetValidAction | CleanAction | SetCaptchaTokenAction; export function setValue(question: Question, value: string | Map<string, boolean> | null): SetValueAction { return { @@ -77,3 +83,7 @@ export function setValid(question: Question, valid: boolean): SetValidAction { export function clean(): CleanAction { return { type: FormAction.CLEAN }; } + +export function setCaptchaToken(token: string | null): SetCaptchaTokenAction { + return { type: FormAction.SET_CAPTCHA_TOKEN, payload: token }; +} diff --git a/src/store/form/reducers.ts b/src/store/form/reducers.ts index fcbb33a..21bd047 100644 --- a/src/store/form/reducers.ts +++ b/src/store/form/reducers.ts @@ -4,7 +4,8 @@ import {FormState} from "./types"; export const initialState: FormState = { values: new Map(), errors: new Map(), - valid: new Map() + valid: new Map(), + captchaToken: null }; export function formReducer(state = initialState, action: Action): FormState { @@ -24,6 +25,10 @@ export function formReducer(state = initialState, action: Action): FormState { case FormAction.CLEAN: return initialState; + + case FormAction.SET_CAPTCHA_TOKEN: + new_state.captchaToken = action.payload; + break; } return new_state; } diff --git a/src/store/form/types.ts b/src/store/form/types.ts index 1d3e594..3f8557e 100644 --- a/src/store/form/types.ts +++ b/src/store/form/types.ts @@ -1,5 +1,6 @@ export interface FormState { values: Map<string, string | Map<string, boolean> | null>, errors: Map<string, string>, - valid: Map<string, boolean> + valid: Map<string, boolean>, + captchaToken: string | null } |