Skip to content
Snippets Groups Projects
Select Git revision
  • 79fc439508f2b98373702a21ea34fb4ac9e7f098
  • 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

TraineeReducer.js

Blame
  • Forked from KSZK / DevTeam / kszkepzes / old / kszkepzes-frontend
    Source project has a limited visibility.
    TraineeReducer.js 909 B
    import { GET_TRAINEES, GET_PROFILES, GET_SELECTED_PROFILE, SET_STATUS } from '../actions/types';
    
    const INITIAL_STATE = { profiles: [], selectedProfile: {} };
    
    export default (state = INITIAL_STATE, action) => {
      switch (action.type) {
        case GET_TRAINEES:
          return { ...state, trainees: [...action.payload] };
        case GET_PROFILES:
          return { ...state, profiles: [...action.payload] };
        case GET_SELECTED_PROFILE:
          return { ...state, selectedProfile: action.payload };
        case SET_STATUS:
          const index = state.profiles.findIndex(item => item.id === action.payload.id);
          state.profiles.splice(index, 1, action.payload);
          if (action.payload.id === state.selectedProfile.id) {
            return { ...state, profiles: [...state.profiles], selectedProfile: action.payload };
          }
          return { ...state, profiles: [...state.profiles] }
        default:
          return state;
      }
    };