Skip to content

Instantly share code, notes, and snippets.

@charisschomba
Created February 20, 2019 09:22
Show Gist options
  • Save charisschomba/c2feb2f6e04b90b3d6052778021aa84b to your computer and use it in GitHub Desktop.
Save charisschomba/c2feb2f6e04b90b3d6052778021aa84b to your computer and use it in GitHub Desktop.
import {
REGISTER_USER,
REGISTER_ERROR,
REGISTER_SUCCESS,
} from '../../../constants/users';
const initialState = {
status: false,
success: false,
isRegistering: false,
};
const reducer = (state = initialState, action) => {
switch (action.type) {
case REGISTER_USER: {
return { ...state, isRegistering: true, status: false };
}
case REGISTER_SUCCESS: {
return {
...state,
user: action.payload,
status: false,
success: true,
isRegistering: false,
};
}
case REGISTER_ERROR: {
return {
...state,
errors: action.payload,
isRegistering: false,
status: true,
};
}
default:
return state;
}
};
export default reducer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment