From e1cd664c663b960c600a9e4a2f3f11fddbbb4dc8 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 5 Mar 2021 22:35:02 +0100 Subject: user pages --- .../app/views/user/containers/user.index.js | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 animism-align/frontend/app/views/user/containers/user.index.js (limited to 'animism-align/frontend/app/views/user/containers/user.index.js') diff --git a/animism-align/frontend/app/views/user/containers/user.index.js b/animism-align/frontend/app/views/user/containers/user.index.js new file mode 100644 index 0000000..8b207e0 --- /dev/null +++ b/animism-align/frontend/app/views/user/containers/user.index.js @@ -0,0 +1,79 @@ +import React, { Component } from 'react' +import { Link } from 'react-router-dom' +import { connect } from 'react-redux' + +import { Loader } from 'app/common' +import actions from 'app/actions' + +import UserMenu from '../components/user.menu' + +// const { result, collectionLookup } = this.props + +class UserIndex extends Component { + componentDidMount() { + this.fetch() + } + + fetch() { + actions.user.index() + } + + render() { + const { currentUser } = this.props + const { loading, lookup, order } = this.props.user.index + if (loading) { + return ( +
+ +
+ ) + } + if (!lookup || !order.length) { + return ( +
+
+ +
+

Users

+

+ {"No users"} +

+
+
+
+ ) + } + return ( +
+
+ +
+

Users

+ {order.map(id => { + const user = lookup[id] + return ( +
+ {(currentUser.is_admin || currentUser.id === user.id) + ? + {user.username} + + : user.username + } + {user.is_admin && " (admin)"} +
+ ) + })} +
+
+ {order.length >= 50 && } +
+ ) + } +} + +const mapStateToProps = state => ({ + user: state.user, + currentUser: state.auth.user, +}) + +export default connect(mapStateToProps)(UserIndex) -- cgit v1.2.3-70-g09d2