Created
March 30, 2020 19:11
-
-
Save Porter97/e513d56d2231cfd825db69cc4d3bc878 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const defaultState = { | |
appName: 'Offbrand' | |
}; | |
export default (state = defaultState, action) => { | |
switch(action.type) { | |
case 'APP_LOAD': | |
return { | |
...state, | |
appLoaded: true, | |
currentUser: action.payload ? action.payload.user : null | |
}; | |
case 'REDIRECT': | |
return {...state, redirectTo: null}; | |
case 'LOGOUT': | |
return { ...state, redirectTo: '/', currentUser: null}; | |
case 'SETTINGS_SAVED': | |
return { | |
...state, | |
redirectTo: action.error ? null : '/', | |
currentUser: action.error ? null : action.payload.user | |
}; | |
case 'LOGIN': | |
case 'REGISTER': | |
return { | |
...state, | |
redirectTo: action.error ? null : '/', | |
currentUser: action.error ? null : action.payload.user, | |
}; | |
case 'LOGIN_PAGE_UNLOADED': | |
return { ...state }; | |
default: | |
return state; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment