purchaseCodeActions.js
2.5 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
'use strict';
import ReactNative from 'react-native';
import PurchaseCodeService from '../../services/PurchaseCodeService';
const {
GET_MINE_LIMIT_PURCHASE_LIST_REQUEST,
GET_MINE_LIMIT_PURCHASE_LIST_SUCCESS,
GET_MINE_LIMIT_PURCHASE_LIST_FAILURE,
DELETE_MINE_LIMIT_PURCHASE_REQUEST,
DELETE_MINE_LIMIT_PURCHASE_SUCCESS,
DELETE_MINE_LIMIT_PURCHASE_FAILURE,
} = require('../../constants/actionTypes').default;
export function MineLimitPurchaseListRequest() {
return {
type: GET_MINE_LIMIT_PURCHASE_LIST_REQUEST,
};
}
export function MineLimitPurchaseListSuccess(json) {
return {
type: GET_MINE_LIMIT_PURCHASE_LIST_SUCCESS,
payload: json
}
}
export function MineLimitPurchaseListFailure(error) {
return {
type: GET_MINE_LIMIT_PURCHASE_LIST_FAILURE,
payload: error
}
}
export function getMineLimitPurchaseList() {
return (dispatch, getState) => {
let {app, purchaseCode} = getState();
let fetchMineLimitPurchaseList = (uid) => {
dispatch(MineLimitPurchaseListRequest());
return new PurchaseCodeService(app.host).getMineLimitPurchaseList(uid)
.then(json => {
dispatch(MineLimitPurchaseListSuccess(json));
})
.catch(error => {
dispatch(MineLimitPurchaseListFailure(error));
});
}
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
fetchMineLimitPurchaseList(uid);
})
.catch(error => {
});
};
}
export function fetchDeleteMinePurchaseCodeLimitCode() {
return {
type: DELETE_MINE_LIMIT_PURCHASE_REQUEST,
};
}
export function DeleteMinePurchaseCodeLimitCodeSuccess(json) {
return {
type: DELETE_MINE_LIMIT_PURCHASE_SUCCESS,
payload: json
}
}
export function DeleteMinePurchaseCodeLimitCodeFailure(error) {
return {
type: DELETE_MINE_LIMIT_PURCHASE_FAILURE,
payload: error
}
}
export function deleteMinePurchaseCodeLimitCode(data) {
return (dispatch, getState) => {
let {app, purchaseCode} = getState();
let limitCode = data.limitCode;
let fetchDeleteMinePurchaseCodeLimitCode = (uid) => {
dispatch(MineLimitPurchaseListRequest());
return new PurchaseCodeService(app.host).DeleteMinePurchaseCodeLimitCode(uid,limitCode)
.then(json => {
dispatch(DeleteMinePurchaseCodeLimitCodeSuccess(json));
})
.catch(error => {
dispatch(DeleteMinePurchaseCodeLimitCodeFailure(error));
});
}
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
fetchDeleteMinePurchaseCodeLimitCode(uid);
})
.catch(error => {
});
};
}