-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocationReducer.ts
44 lines (40 loc) · 917 Bytes
/
locationReducer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import {
GET_LOCATION_REQUEST,
GET_LOCATION_SUCCESS,
GET_LOCATION_FAILURE,
} from '../actions/actionTypes';
export interface LocationState {
loading: boolean;
data: any;
error: string | null;
}
const initialState: LocationState = {
loading: false,
data: null,
error: null,
};
const locationReducer = (state = initialState, action: any) => {
switch (action.type) {
case GET_LOCATION_REQUEST:
return {
...state,
loading: true,
error: null,
};
case GET_LOCATION_SUCCESS:
return {
...state,
loading: false,
data: action.payload,
};
case GET_LOCATION_FAILURE:
return {
...state,
loading: false,
error: action.payload,
};
default:
return state;
}
};
export default locationReducer;