Skip to content
Snippets Groups Projects
Select Git revision
  • b80f869c8b23a243c554476d4e110455f6468b4b
  • master default protected
  • 1.3.1
  • 1.3.0
  • 1.2.0
  • 1.1.5
  • 1.1.4
  • 1.1.3
  • 1.1.2
  • 1.1.1
  • 1.1.0
  • 1.0.19
  • 1.0.18
  • 1.0.17
  • 1.0.16
  • 1.0.15
  • 1.0.14
  • 1.0.13
  • 1.0.12
  • 1.0.10
  • 1.0.9
  • 1.0.8
22 results

NewsReducer.js

Blame
  • Forked from KSZK / DevTeam / kszkepzes / old / kszkepzes-frontend
    Source project has a limited visibility.
    To find the state of this project's repository at the time of any of these versions, check out the tags.
    NewsReducer.js 618 B
    import { GET_NEWS, ADD_NEWS, DELETE_NEWS, EDIT_NEWS } from '../actions/types';
    
    const INITIAL_STATE = [];
    
    export default (state = INITIAL_STATE, action) => {
      switch (action.type) {
        case GET_NEWS:
          return action.payload;
        case ADD_NEWS:
          return [action.payload, ...state];
        case EDIT_NEWS:
          const array = state.filter(item => item.id === action.payload.id);
          state.splice(state.indexOf(array.pop()), 1, action.payload);
          return [...state];
        case DELETE_NEWS:
          state.splice(state.indexOf(action.payload), 1);
          return [...state];
        default:
          return state;
      }
    };