mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 11:47:56 +01:00
Add users management to site settings (#126)
This commit is contained in:
committed by
GitHub
parent
bc15140512
commit
37fb99a868
58
app/javascript/reducers/SiteSettings/usersReducer.ts
Normal file
58
app/javascript/reducers/SiteSettings/usersReducer.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import {
|
||||
UsersRequestActionTypes,
|
||||
USERS_REQUEST_START,
|
||||
USERS_REQUEST_SUCCESS,
|
||||
USERS_REQUEST_FAILURE,
|
||||
} from '../../actions/User/requestUsers';
|
||||
|
||||
import {
|
||||
UserUpdateActionTypes,
|
||||
USER_UPDATE_START,
|
||||
USER_UPDATE_SUCCESS,
|
||||
USER_UPDATE_FAILURE,
|
||||
} from '../../actions/User/updateUser';
|
||||
|
||||
export interface SiteSettingsUsersState {
|
||||
areUpdating: boolean;
|
||||
error: string;
|
||||
}
|
||||
|
||||
const initialState: SiteSettingsUsersState = {
|
||||
areUpdating: false,
|
||||
error: '',
|
||||
};
|
||||
|
||||
const siteSettingsUsersReducer = (
|
||||
state = initialState,
|
||||
action: UsersRequestActionTypes | UserUpdateActionTypes,
|
||||
) => {
|
||||
switch (action.type) {
|
||||
case USERS_REQUEST_START:
|
||||
case USER_UPDATE_START:
|
||||
return {
|
||||
...state,
|
||||
areUpdating: true,
|
||||
};
|
||||
|
||||
case USERS_REQUEST_SUCCESS:
|
||||
case USER_UPDATE_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
areUpdating: false,
|
||||
error: '',
|
||||
};
|
||||
|
||||
case USERS_REQUEST_FAILURE:
|
||||
case USER_UPDATE_FAILURE:
|
||||
return {
|
||||
...state,
|
||||
areUpdating: false,
|
||||
error: action.error,
|
||||
};
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
export default siteSettingsUsersReducer;
|
||||
Reference in New Issue
Block a user