Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. export const authStore = {
  2. auth: {
  3. isLogged: false,
  4. user: {}
  5. }
  6. };
  7.  
  8. export const LOGIN = "LOGIN";
  9. export const LOGOUT = "LOGOUT";
  10.  
  11. const authReducer = (state = authStore, action) => {
  12. switch (action.type) {
  13. case LOGIN:
  14. return {
  15. auth: {
  16. ...state.auth,
  17. isLogged: true,
  18. user: action.payload
  19. }
  20. };
  21. case LOGOUT:
  22. return {
  23. auth: {
  24. ...state.auth,
  25. isLogged: false,
  26. user: {}
  27. }
  28. };
  29. default:
  30. return state;
  31. }
  32. };
  33.  
  34. export const LogInUser = user => {
  35. return {
  36. type: LOGIN,
  37. payload: user
  38. };
  39. };
  40.  
  41. export const LogOutUser = () => {
  42. return {
  43. type: LOGOUT
  44. };
  45. };
  46.  
  47. export default authReducer;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement