Split admin panel in components
This commit is contained in:
parent
a336c3a4dc
commit
667768fa10
22
src/public/js/components/admins/panel.js
Normal file
22
src/public/js/components/admins/panel.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import React from "react"
|
||||||
|
import { connect } from "react-redux"
|
||||||
|
import { bindActionCreators } from "redux"
|
||||||
|
import { getUsers } from "../../actions/admins"
|
||||||
|
|
||||||
|
import UserList from "./users"
|
||||||
|
|
||||||
|
function mapStateToProps(state) {
|
||||||
|
return {
|
||||||
|
users : state.adminStore.get("users"),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const mapDispatchToProps = (dipatch) =>
|
||||||
|
bindActionCreators({ getUsers }, dipatch)
|
||||||
|
|
||||||
|
function AdminPanel(props) {
|
||||||
|
return (
|
||||||
|
<UserList users={props.users} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(AdminPanel);
|
@ -1,23 +1,6 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import { connect } from "react-redux"
|
|
||||||
import { bindActionCreators } from "redux"
|
|
||||||
import { getUsers } from "../../actions/admins"
|
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
export default function UserList(props) {
|
||||||
return {
|
|
||||||
users : state.adminStore.get("users"),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
const mapDispatchToProps = (dipatch) =>
|
|
||||||
bindActionCreators({ getUsers }, dipatch)
|
|
||||||
|
|
||||||
function AdminView(props) {
|
|
||||||
return (
|
|
||||||
<UserList users={props.users} />
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function UserList(props) {
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h2 className="hidden-xs">Users</h2>
|
<h2 className="hidden-xs">Users</h2>
|
||||||
@ -60,5 +43,3 @@ function User(props) {
|
|||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(AdminView);
|
|
||||||
|
@ -6,7 +6,7 @@ import UserEdit from "./components/users/edit"
|
|||||||
import UserActivation from "./components/users/activation"
|
import UserActivation from "./components/users/activation"
|
||||||
import UserSignUp from "./components/users/signup"
|
import UserSignUp from "./components/users/signup"
|
||||||
import TorrentList from "./components/torrents/list"
|
import TorrentList from "./components/torrents/list"
|
||||||
import AdminView from "./components/admins/users"
|
import AdminPanel from "./components/admins/panel"
|
||||||
|
|
||||||
import { fetchTorrents } from "./actions/torrents"
|
import { fetchTorrents } from "./actions/torrents"
|
||||||
import { userLogout, getUserInfos } from "./actions/users"
|
import { userLogout, getUserInfos } from "./actions/users"
|
||||||
@ -250,7 +250,7 @@ export default function getRoutes(App) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/admin",
|
path: "/admin",
|
||||||
component: AdminView,
|
component: AdminPanel,
|
||||||
onEnter: function(nextState, replace, next) {
|
onEnter: function(nextState, replace, next) {
|
||||||
adminCheck(nextState, replace, next, function() {
|
adminCheck(nextState, replace, next, function() {
|
||||||
store.dispatch(getUsers());
|
store.dispatch(getUsers());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user