Add React Admin and modify AdminHandler

This commit is contained in:
Nathan Barber
2021-04-05 16:51:22 -04:00
parent c5bfd28005
commit 11cb9523e8
35 changed files with 18333 additions and 218 deletions

View File

@@ -0,0 +1,33 @@
import { compose, withProps } from "recompose";
import { connect } from "react-redux";
import { jhapiRequest } from "../../util/jhapiUtil";
import { Groups } from "./Groups.pre";
const withGroupsAPI = withProps((props) => ({
refreshGroupsData: () =>
jhapiRequest("/groups", "GET")
.then((data) => data.json())
.then((data) => props.dispatch({ type: "GROUPS_DATA", value: data })),
refreshUserData: () =>
jhapiRequest("/users", "GET")
.then((data) => data.json())
.then((data) => props.dispatch({ type: "USER_DATA", value: data })),
addUsersToGroup: (name, new_users) =>
jhapiRequest("/groups/" + name + "/users", "POST", {
body: { users: new_users },
json: true,
}),
removeUsersFromGroup: (name, removed_users) =>
jhapiRequest("/groups/" + name + "/users", "DELETE", {
body: { users: removed_users },
json: true,
}),
}));
export default compose(
connect((state) => ({
user_data: state.user_data,
groups_data: state.groups_data,
})),
withGroupsAPI
)(Groups);