You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

userDetailsReducer.js 959B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import createReducer from "../../utils/createReducer";
  2. import {
  3. USER_DETAILS_ERR,
  4. USER_DETAILS_SUCCESS,
  5. USER_DETAILS_TOGGLE,
  6. } from "../../actions/users/usersActionConstants";
  7. // import { setUsersError } from "../../actions/users/usersActions";
  8. const initialState = {
  9. user: {},
  10. errorMessage: "",
  11. };
  12. export default createReducer(
  13. {
  14. [USER_DETAILS_SUCCESS]: setStateUserDetails,
  15. [USER_DETAILS_ERR]: setUserDetailsErrorMessage,
  16. [USER_DETAILS_TOGGLE]: toggleUserDetails,
  17. },
  18. initialState
  19. );
  20. function setStateUserDetails(state, action) {
  21. return {
  22. ...state,
  23. user: action.payload,
  24. };
  25. }
  26. function setUserDetailsErrorMessage(state, action) {
  27. return {
  28. ...state,
  29. errorMessage: action.payload,
  30. };
  31. }
  32. function toggleUserDetails(state) {
  33. console.log('ovde')
  34. return state.user
  35. ? {
  36. ...state,
  37. user: { ...state.user, isEnabled: !state.user.isEnabled },
  38. }
  39. : {
  40. ...state,
  41. };
  42. }