Last active
February 26, 2019 14:12
-
-
Save mohamedhamdy2017/5693254ca4306e0e7f02772d97f7f230 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { IS_FETCHING, FETCHING_SUCCESS, FETCHING_FAILED } from '../actions/actionTypes' | |
const INIT_STATE = { | |
loading: false, lat: '', lon: '', name: '', rate: '', cat: '' | |
} | |
export default (state= INIT_STATE, action) => { | |
switch(action.type){ | |
case IS_FETCHING: | |
return { ...state, loading: true} | |
case FETCHING_SUCCESS: | |
return { | |
...state, | |
lat: parseFloat(action.payload), | |
lon: parseFloat(action.payload), | |
name: action.payload, | |
rate: action.payload, | |
cat: action.payload, | |
loading: false | |
} | |
case FETCHING_FAILED: | |
return INIT_STATE | |
default: | |
return state | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment