-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.jsx
More file actions
38 lines (28 loc) · 1.01 KB
/
Copy pathapp.jsx
File metadata and controls
38 lines (28 loc) · 1.01 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
const initState = {
users: [],
statuses: ['new', 'inprogress', 'testing', 'complited'],
};
export function reducer(state = initState, action) {
switch (action.type) {
case 'SET_USERS':
return { ...state, users: action.payload };
default:
return state;
}
}
import http from 'utils/http';
import { push } from 'redux-router';
import { openPopup } from 'containers/ProjectsList/state';
const setUsers = (users) => ({ type: 'SET_USERS', payload: users });
export const loadUsers = () => (dispatch) =>
http.get('/api/users')
.then(users => dispatch(setUsers(users)));
export const getStatusesOptions = (state) =>
state.app.statuses.map(str => ({ value: str, label: str }));
export const getUserOptions = (state) =>
state.app.users.map(user => ({ value: user.id, label: user.name }));
export const appStart = () => (dispatch) => dispatch(loadUsers());
export const showAddProject = () => (dispatch) => {
dispatch(push('/'));
dispatch(openPopup());
};