accountSettlementActions.js
1.43 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
63
64
65
66
'use strict';
import Request from '../../services/Request';
import HomeService from '../../services/HomeService';
const {
ACCOUNT_LIST_REQUEST,
ACCOUNT_LIST_SUCCESS,
ACCOUNT_LIST_FAILURE,
ACCOUNT_LIST_CLEAN,
} = require('../../constants/actionTypes').default;
export function requestNextPage() {
return {
type: ACCOUNT_LIST_REQUEST,
}
}
/**
* Success to fetch data..
* @method nextPageOfDataSuccess
* @param {Maybe array} json remote data
* @return {[type]} [description]
*/
export function nextPageOfDataSuccess(json) {
return {
type: ACCOUNT_LIST_SUCCESS,
payload: json,
}
}
export function nextPageOfDataFailure(error) {
return {
type: ACCOUNT_LIST_FAILURE,
payload: error,
}
}
/**
* Request next page of account settlement data list...
* @method nextPageOfDataRequest
* @return {JS Objecrt}
*/
export function nextPageOfDataRequest() {
return (dispatch,getState) => {
const {home, actStmt} = getState();
dispatch(requestNextPage());
return new HomeService().accountSettlementData(home.shopId)
.then(json => {
dispatch(nextPageOfDataSuccess(json));
})
.catch(error => {
dispatch(nextPageOfDataFailure(error));
})
};
}
export function accountSettlementClean() {
return {
type: ACCOUNT_LIST_CLEAN,
}
}