{"ast":null,"code":"import { DELETE_POST, GET_POSTS, UPDATE_POST } from \"../actions/post.actions\";\nconst initialState = {};\nexport default function postReducer() {\n  let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;\n  let action = arguments.length > 1 ? arguments[1] : undefined;\n  switch (action.type) {\n    case GET_POSTS:\n      return action.payload;\n    case UPDATE_POST:\n      return state.map(post => {\n        if (postReducer._id === action.payload.postId) {\n          return {\n            ...post,\n            message: action.payload.message\n          };\n        } else return post;\n      });\n    case DELETE_POST:\n      return;\n    default:\n      return state.filter(post => post._id !== action);\n  }\n}","map":{"version":3,"names":["DELETE_POST","GET_POSTS","UPDATE_POST","initialState","postReducer","state","action","type","payload","map","post","_id","postId","message","filter"],"sources":["C:/Users/user/Desktop/05mediaSocial/client/src/reducers/post.reducer.js"],"sourcesContent":["import { DELETE_POST, GET_POSTS, UPDATE_POST } from \"../actions/post.actions\";\r\n\r\nconst initialState = {};\r\n\r\nexport default function postReducer(state = initialState, action) {\r\n  switch (action.type) {\r\n    case GET_POSTS:\r\n      return action.payload;\r\n    \r\n\r\n      case UPDATE_POST:\r\n        return state.map((post)=>{\r\n          if(postReducer._id===action.payload.postId){\r\n            return{\r\n              ...post,\r\n              message:action.payload.message\r\n            }\r\n          }else return post\r\n        } )\r\n\r\n      case DELETE_POST:\r\n        return\r\n      default:\r\n        return state.filter((post)=>post._id !== action)\r\n    }\r\n\r\n} "],"mappings":"AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,WAAW,QAAQ,yBAAyB;AAE7E,MAAMC,YAAY,GAAG,CAAC,CAAC;AAEvB,eAAe,SAASC,WAAW,GAA+B;EAAA,IAA9BC,KAAK,uEAAGF,YAAY;EAAA,IAAEG,MAAM;EAC9D,QAAQA,MAAM,CAACC,IAAI;IACjB,KAAKN,SAAS;MACZ,OAAOK,MAAM,CAACE,OAAO;IAGrB,KAAKN,WAAW;MACd,OAAOG,KAAK,CAACI,GAAG,CAAEC,IAAI,IAAG;QACvB,IAAGN,WAAW,CAACO,GAAG,KAAGL,MAAM,CAACE,OAAO,CAACI,MAAM,EAAC;UACzC,OAAM;YACJ,GAAGF,IAAI;YACPG,OAAO,EAACP,MAAM,CAACE,OAAO,CAACK;UACzB,CAAC;QACH,CAAC,MAAK,OAAOH,IAAI;MACnB,CAAC,CAAE;IAEL,KAAKV,WAAW;MACd;IACF;MACE,OAAOK,KAAK,CAACS,MAAM,CAAEJ,IAAI,IAAGA,IAAI,CAACC,GAAG,KAAKL,MAAM,CAAC;EAAA;AAGxD"},"metadata":{},"sourceType":"module","externalDependencies":[]}