Skip to content

Instantly share code, notes, and snippets.

@Porter97
Created March 30, 2020 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Porter97/79d1b3dd46a571f38c47f5f1afaa0ac5 to your computer and use it in GitHub Desktop.
Save Porter97/79d1b3dd46a571f38c47f5f1afaa0ac5 to your computer and use it in GitHub Desktop.
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 'REGISTER':
return {
...state,
redirectTo: action.error ? null : '/',
currentUser: action.error ? null : action.payload.user,
};
default:
return state;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment