myProfileReducer.js 858 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. }
  21. if (type in types) {
  22. return types[type]()
  23. }
  24. return state
  25. }
  26. //type
  27. export const actionProfilePageDataType = (aboutMe) => ({
  28. type: 'PROFILE-PAGE',
  29. aboutMe,
  30. })
  31. export const actionRemoveDataAboutMe = () =>
  32. ({ type: 'REMOVE-DATA' })
  33. export const actionChangeFollowingType = (newResult) => ({
  34. type:"UPDATE_FOLLOWING", newResult
  35. })