import { AnyAction } from "redux" ; import { SET_LOGIN_STATE , RESET_LOGIN_STATE } from "./type" ; import { AuthState } from "./state" ; const initialState = { server : "" , client : "" , isLoggedIn : false , displayName : "" , username : "" , token : "" , } ; export default function reducer ( state = initialState , action ) { switch ( action . type ) { case SET_LOGIN_STATE : return { ... state , isLoggedIn : true , displayName : action . payload . displayName , username : action . payload . username , token : action . payload . token , } ; case RESET_LOGIN_STATE : return { ... state , isLoggedIn : false , displayName : "" , username : "" , token : "" , } ; default : return state ; } }