-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactions.js
61 lines (54 loc) · 1.09 KB
/
actions.js
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
import { FETCHING_MEMBER, FETCHING_MEMBER_SUCCESS, FETCHING_MEMBER_FAILURE, ADD_MEMBER, EDIT_MEMBER, DELETE_MEMBER } from './constants'
import getMembers from './api'
export function fetchData() {
return (dispatch) => {
dispatch(getMember())
getMembers()
.then((data) => {
dispatch(getMemberSuccess(data))
})
.catch((err) => console.log('err:', err))
}
}
export function getMember() {
return {
type: FETCHING_MEMBER
}
}
export function getMemberSuccess(data) {
return {
type: FETCHING_MEMBER_SUCCESS,
data
}
}
export function getMemberFailure() {
return {
type: FETCHING_MEMBER_FAILURE
}
}
export function addMember(first_name, last_name, email, mobile_no, role) {
return {
type: ADD_MEMBER,
first_name,
last_name,
email,
mobile_no,
role
}
}
export function editMember(first_name, last_name, email, mobile_no, role) {
return {
type: EDIT_MEMBER,
first_name,
last_name,
email,
mobile_no,
role
}
}
export function deleteMember(email) {
return {
type: DELETE_MEMBER,
email
}
}