1import * as Types from '../constants/types/login' 2import * as LoginGen from '../actions/login-gen' 3import * as SignupGen from '../actions/signup-gen' 4import * as ProvisionGen from '../actions/provision-gen' 5import * as Container from '../util/container' 6 7const initialState = { 8 forgotPasswordSubmitting: false, 9 forgotPasswordSuccess: false, 10 registerUserPassLoading: false, 11} 12 13type Actions = LoginGen.Actions | SignupGen.RequestAutoInvitePayload | ProvisionGen.StartProvisionPayload 14 15const clearErrors = (draftState: Container.Draft<Types.State>) => { 16 draftState.error = undefined 17} 18 19export default Container.makeReducer<Actions, Types.State>(initialState, { 20 [LoginGen.resetStore]: () => initialState, 21 [LoginGen.loginError]: (draftState, action) => { 22 draftState.error = action.payload.error 23 }, 24 [LoginGen.loadedIsOnline]: (draftState, action) => { 25 draftState.isOnline = action.payload.isOnline 26 }, 27 [SignupGen.requestAutoInvite]: draftState => clearErrors(draftState), 28 [LoginGen.login]: draftState => clearErrors(draftState), 29 [ProvisionGen.startProvision]: draftState => clearErrors(draftState), 30}) 31