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/components/user.menu.js | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 animism-align/frontend/app/views/user/components/user.menu.js (limited to 'animism-align/frontend/app/views/user/components/user.menu.js') diff --git a/animism-align/frontend/app/views/user/components/user.menu.js b/animism-align/frontend/app/views/user/components/user.menu.js new file mode 100644 index 0000000..cf77970 --- /dev/null +++ b/animism-align/frontend/app/views/user/components/user.menu.js @@ -0,0 +1,64 @@ +import React, { Component } from 'react' +import { Route } from 'react-router-dom' +import { connect } from 'react-redux' + +import { history } from 'app/store' +import actions from 'app/actions' +import { MenuButton } from 'app/common' + +const mapStateToProps = state => ({ + user: state.user, + currentUser: state.auth.user, +}) + +export default class UserMenu extends Component { + render() { + return ( +
+ + + + +
+ ) + } +} + +const UserIndexMenu = connect(mapStateToProps)((props) => ([ + props.currentUser.is_admin && , +])) + +const UserShowMenu = connect(mapStateToProps)((props) => ([ + , + (props.currentUser.is_admin || parseInt(props.match.params.id) === props.currentUser.id) && ( + + ), + (parseInt(props.match.params.id) !== props.currentUser.id) && ( + { + const { res: user } = props.user.show + if (confirm("Really delete this user?")) { + actions.user.destroy(user).then(() => { + history.push('/users/') + }) + } + }} /> + ), +])) + +const UserNewMenu = (props) => ([ + , +]) + +const UserEditMenu = connect(mapStateToProps)((props) => ([ + , + (parseInt(props.match.params.id) !== props.currentUser.id) && ( + { + const { res: user } = props.user.show + if (confirm("Really delete this user?")) { + actions.user.destroy(user).then(() => { + history.push('/users/') + }) + } + }} /> + ), +])) -- cgit v1.2.3-70-g09d2