123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- import {
- GET_DOCTORS_REQUEST,
- GET_DOCTORS_REQUEST_SUCCESS,
- GET_DOCTORS_REQUEST_FAIL,
- GET_SERVICES_REQUEST,
- GET_SERVICES_REQUEST_SUCCESS,
- GET_SERVICES_REQUEST_FAIL,
- POST_DOCTORS_REQUEST,
- POST_DOCTORS_REQUEST_SUCCESS,
- POST_DOCTORS_REQUEST_FAIL
- } from './actions'
- const defaultState = {
- doctors:[ ],
- services:{
- service1:{id:1},
- service2:{id:2},
- service3:{id:3},
- service4:{id:4},
- service5:{id:5},
- service6:{id:6},
- service7:{id:7},
- service8:{id:8},
- service9:{id:9},
- },
- isFetching:false,
- error: null,
- };
- // -----------------------------------------------------------------------------------------------------------------
- export const appReducer = (state = defaultState,action) => {
- switch (action.type) {
- // -----------------------------------------------------------------------------------------------------------------
- case GET_DOCTORS_REQUEST : {
- return {
- ...state,
- isFetching: true
- };
- }
- case GET_DOCTORS_REQUEST_SUCCESS : {
- return {
- ...state,
- doctors:action.payload,
- isFetching: false
- }
- }
- case GET_DOCTORS_REQUEST_FAIL : {
- return {
- ...state,
- error:action.payload,
- isFetching: false
- }
- }
- // -----------------------------------------------------------------------------------------------------------------
- case GET_SERVICES_REQUEST : {
- return {
- ...state,
- isFetching: true
- };
- }
- case GET_SERVICES_REQUEST_SUCCESS : {
- return {
- ...state,
- services:action.payload,
- isFetching: false
- }
- }
- case GET_SERVICES_REQUEST_FAIL : {
- return {
- ...state,
- error:action.payload,
- isFetching: false
- }
- }
- // -----------------------------------------------------------------------------------------------------------------
- case POST_DOCTORS_REQUEST : {
- return {
- ...state,
- isFetching: true
- };
- }
- case POST_DOCTORS_REQUEST_SUCCESS : {
- return {
- ...state,
- isFetching: false
- }
- }
- case POST_DOCTORS_REQUEST_FAIL : {
- return {
- ...state,
- error: action.payload,
- isFetching: false
- }
- }
- // _______________________________________________________________________________
- default:
- return state
- }
- };
|