result.js
1.05 KB
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
45
46
// action
const GET_RESULT = 'GET_RESULT';
const GET_RESULT_SUCCESS = 'GET_RESULT_SUCCESS';
const GET_RESULT_ERROR = 'GET_RESULT_ERROR';
// action creators
export const getResult = () => ({type:GET_RESULT});
export const getResultSuccess = (data) => ({type: GET_RESULT_SUCCESS,payload: data});
export const getResultError = (e) => ({type: GET_RESULT_ERROR, payload: e});
const initialState = {
loading: true,
data: null,
error: null
}
function result(
state = initialState,
action
){
switch(action.type){
case GET_RESULT: {
return{
loading: true,
data: null,
error: null
}
}
case GET_RESULT_SUCCESS:{
return{
loading: false,
data: action.payload,
error: null
}
}
case GET_RESULT_ERROR:{
return{
loading: false,
data: null,
error: action.payload
}
}
}
}
export default result;