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
49
app/javascript/containers/UsersSiteSettings.tsx
Normal file
49
app/javascript/containers/UsersSiteSettings.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
import { connect } from "react-redux";
|
||||
|
||||
import UsersSiteSettingsP from "../components/SiteSettings/Users/UsersSiteSettingsP";
|
||||
|
||||
import { requestUsers } from "../actions/User/requestUsers";
|
||||
import { updateUser } from "../actions/User/updateUser";
|
||||
import { UserRoles, USER_STATUS_ACTIVE, USER_STATUS_BLOCKED } from "../interfaces/IUser";
|
||||
import { State } from "../reducers/rootReducer";
|
||||
|
||||
const mapStateToProps = (state: State) => ({
|
||||
users: state.users,
|
||||
settingsAreUpdating: state.siteSettings.users.areUpdating,
|
||||
settingsError: state.siteSettings.users.error,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => ({
|
||||
requestUsers() {
|
||||
dispatch(requestUsers());
|
||||
},
|
||||
|
||||
updateUserRole(
|
||||
id: number,
|
||||
role: UserRoles,
|
||||
authenticityToken: string,
|
||||
): Promise<any> {
|
||||
return dispatch(updateUser({
|
||||
id,
|
||||
role,
|
||||
authenticityToken,
|
||||
}));
|
||||
},
|
||||
|
||||
updateUserStatus(
|
||||
id: number,
|
||||
status: typeof USER_STATUS_ACTIVE | typeof USER_STATUS_BLOCKED,
|
||||
authenticityToken: string,
|
||||
) {
|
||||
dispatch(updateUser({
|
||||
id,
|
||||
status,
|
||||
authenticityToken,
|
||||
}));
|
||||
},
|
||||
});
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(UsersSiteSettingsP);
|
||||
Reference in New Issue
Block a user