ClasesReducer.js 564 B

123456789101112131415161718192021222324
  1. import {
  2. CLASE_FETCH_SUCCESS,
  3. CLASE_FETCH_FAIL,
  4. CLASE_FETCH
  5. } from '../actions/types';
  6. const INITIAL_STATE = {
  7. curClase: { profesor: {} },
  8. loading: true,
  9. error: false
  10. };
  11. export default (state = INITIAL_STATE, action) => {
  12. switch (action.type) {
  13. case CLASE_FETCH:
  14. return { ...state, curClase: { error: false }, loading: true };
  15. case CLASE_FETCH_SUCCESS:
  16. return { ...state, loading: false, curClase: action.payload };
  17. case CLASE_FETCH_FAIL:
  18. return { ...state, loading: false, curClase: { error: true } };
  19. default:
  20. return state;
  21. }
  22. };