mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
add restentpoint for login/logout, restructuring of modules and components, add flow usage
This commit is contained in:
58
scm-ui/src/users/modules/users.js
Normal file
58
scm-ui/src/users/modules/users.js
Normal file
@@ -0,0 +1,58 @@
|
||||
const FETCH_USERS = 'scm/users/FETCH';
|
||||
const FETCH_USERS_SUCCESS= 'scm/users/FETCH_SUCCESS';
|
||||
const FETCH_USERS_FAILURE = 'scm/users/FETCH_FAILURE';
|
||||
|
||||
function requestUsers() {
|
||||
return {
|
||||
type: FETCH_USERS
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function fetchUsers() {
|
||||
return function(dispatch) {
|
||||
dispatch(requestUsers());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function shouldFetchUsers(state: any): boolean {
|
||||
const users = state.users;
|
||||
return null;
|
||||
}
|
||||
|
||||
export function fetchUsersIfNeeded() {
|
||||
return (dispatch, getState) => {
|
||||
if (shouldFetchUsers(getState())) {
|
||||
dispatch(fetchUsers());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default function reducer(state = {}, action = {}) {
|
||||
switch (action.type) {
|
||||
case FETCH_USERS:
|
||||
return {
|
||||
...state,
|
||||
login: true,
|
||||
error: null
|
||||
};
|
||||
case FETCH_USERS_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
login: false,
|
||||
timestamp: action.timestamp,
|
||||
error: null,
|
||||
users: action.payload
|
||||
};
|
||||
case FETCH_USERS_FAILURE:
|
||||
return {
|
||||
...state,
|
||||
login: false,
|
||||
error: action.payload
|
||||
};
|
||||
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user