saleStatisticsActions.js
1.29 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* # guideActions.js
*
* App user guide
*
*/
'use strict';
import {Actions} from 'react-native-router-flux';
import CONFIG from '../../constants/config';
import HomeService from '../../services/HomeService';
const {
SALE_STATS_REQUEST,
SALE_STATS_SUCCESS,
SALE_STATS_FAILURE,
} = require('../../constants/actionTypes').default;
export function saleStatsRequest(shopId) {
return {
type: SALE_STATS_REQUEST,
payload: shopId
};
}
export function saleStatsSuccess(json) {
return {
type: SALE_STATS_SUCCESS,
payload: json
};
}
export function saleStatsFailure(error) {
return {
type: SALE_STATS_FAILURE,
payload: error
};
}
export function saleStats(shopId) {
return dispatch => {
dispatch(saleStatsRequest(shopId));
return new HomeService().saleStats(shopId)
.then(json => {
dispatch(saleStatsSuccess({
goodsCount: 7600,
amountRise: true,
amountRisePercent: '20%',
goodsAmount: 19800.00,
countRise: false,
countRisePercent: '10%'
}));
})
.catch(error => {
dispatch(saleStatsFailure(error));
});
};
}