import { AuthState } from '../types' ; import { FIREBASE_GOOGLE_LOGIN_POPUP , GET_LOGIN_REDIRECT_RESULT , TRIGGER_LOGIN_WITH_REDIRECT , } from './types' ; export default { [ FIREBASE_GOOGLE_LOGIN_POPUP . PENDING ] : ( state ) => { state . loading = true ; } , [ FIREBASE_GOOGLE_LOGIN_POPUP . REJECTED ] : ( state , { payload } ) => { state . error = payload ; state . loading = false ; } , [ FIREBASE_GOOGLE_LOGIN_POPUP . COMPLETED ] : ( state , { payload } ) => { state . user = payload . user ; state . loading = false ; } , [ TRIGGER_LOGIN_WITH_REDIRECT . PENDING ] : ( state ) => { window . sessionStorage . setItem ( 'redirect_started' , `google_${ new Date ( ) . toISOString ( ) }` ) ; state . loading = true ; } , [ GET_LOGIN_REDIRECT_RESULT . REJECTED ] : ( state , { payload } ) => { window . sessionStorage . removeItem ( 'redirect_started' ) ; state . error = payload ; state . loading = false ; } , [ GET_LOGIN_REDIRECT_RESULT . COMPLETED ] : ( state , { payload } ) => { state . user = payload . user ; state . loading = false ; } , } ;