messageActions.js
1.19 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
/**
* # guideActions.js
*
* App user guide
*
*/
'use strict';
import {Actions} from 'react-native-router-flux';
import MessageService from '../../services/MessageService';
const {
MESSAGE_DETAIL,
REQUEST_MSG_LIST,
REQUEST_MSG_LIST_SUCCESS,
REQUEST_MSG_LIST_FAILURE,
} = require('../../constants/actionTypes').default;
export function checkMessageDetail(item) {
Actions.MessageDetail();
return {
type: MESSAGE_DETAIL,
payload: item,
};
}
export function requestMsgList(shopsId) {
return {
type: REQUEST_MSG_LIST,
payload: shopsId,
}
}
export function requestMsgListSuccess(json) {
return {
type: REQUEST_MSG_LIST_SUCCESS,
payload: json,
}
}
export function requestMsgListFailure(error) {
return {
type: REQUEST_MSG_LIST_FAILURE,
payload: error,
}
}
export function getMsgList(shopsId) {
return dispatch => {
dispatch(requestMsgList(shopsId));
return new MessageService().getMsgList(shopsId)
.then(json => {
dispatch(requestMsgListSuccess(json));
})
.catch(error => {
dispatch(requestMsgListFailure(error));
});
};
}