import React, { Component } from 'react' import { connect } from 'react-redux' import { history } from 'app/store' import actions from 'app/actions' import { Loader } from 'app/common' import UserForm from '../components/user.form' import UserMenu from '../components/user.menu' class UserEdit extends Component { componentDidMount() { console.log(this.props.match.params.id) actions.user.show(this.props.match.params.id) } handleSubmit(data) { actions.user.update(data) .then(response => { // response console.log(response) history.push('/users/') }) .catch(err => { console.log(err) if (!err.errors) { if (err.error) { alert(err.error) return } alert("There was an error saving this user.") return } const errorStr = Object.keys(err.errors) .map(key => ( err.errors[key].map(error => key + ": " + error ).join("\n") )).join("\n") alert("There was an error updating this user.\n" + errorStr) }) } render() { const { show } = this.props.user if (show.loading || !show.res) { return (