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/') }) } }} /> ), ]))