index.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import * as types from "../../../constants";
  2. import initialState from './../../initialState';
  3. export default function signIn(state = initialState.signIn, {type, payload: user, error}) {
  4. switch (type) {
  5. case types.SIGN_IN_REQUEST: {
  6. return {
  7. ...state,
  8. isFetching: true
  9. }
  10. }
  11. case types.SIGN_IN_REQUEST_SUCCESS: {
  12. return {
  13. ...state,
  14. user,
  15. isFetching: false
  16. }
  17. }
  18. case types.SIGN_IN_REQUEST_FAILURE: {
  19. return {
  20. ...state,
  21. error,
  22. isFetching: false
  23. }
  24. }
  25. case types.USER_IS_SIGNED_IN: {
  26. return {
  27. ...state,
  28. user
  29. }
  30. }
  31. case types.USER_IS_NOT_SIGNED_IN: {
  32. return {
  33. ...state,
  34. user: null
  35. }
  36. }
  37. default: {
  38. return state
  39. }
  40. }
  41. }