myProfileReducer.js 729 B

12345678910111213141516171819202122232425262728293031323334353637
  1. export const myProfileReducer = (state = {}, { type, aboutMe, newResult }) => {
  2. const types = {
  3. 'PROFILE-PAGE': () => {
  4. return {
  5. ...state,
  6. aboutMe,
  7. }
  8. },
  9. 'REMOVE-DATA': () => {
  10. return {
  11. aboutMe: {},
  12. }
  13. },
  14. 'UPDATE_FOLLOWING': () => {
  15. return {
  16. ...state,
  17. aboutMe: ({ ...state.aboutMe, following: [...newResult] })
  18. }
  19. },
  20. 'UPDATE_AVATAR': () => {
  21. return {
  22. ...state,
  23. aboutMe: ({
  24. ...state.aboutMe,
  25. avatar: { ...newResult }
  26. })
  27. }
  28. },
  29. }
  30. if (type in types) {
  31. return types[type]()
  32. }
  33. return state
  34. }