diff --git a/src/routes/app/routes/organization/components/organization.js b/src/routes/app/routes/organization/components/organization.js index f13b045..7fcc14c 100644 --- a/src/routes/app/routes/organization/components/organization.js +++ b/src/routes/app/routes/organization/components/organization.js @@ -11,6 +11,8 @@ import { import moment from 'moment'; import Delete from 'material-ui/svg-icons/action/delete'; import IconButton from 'material-ui/IconButton'; +import FlatButton from 'material-ui/FlatButton'; +import Dialog from 'material-ui/Dialog'; import GoogleAddressComponent from './GoogleAddressComponent'; import ContactComponent from './ContactComponent'; @@ -463,7 +465,9 @@ class Organization extends React.Component { "useruuid": "", "name": "", } - } + }, + showErrorMessage : false, + errorMessage : '' } componentDidMount() { @@ -597,11 +601,20 @@ class Organization extends React.Component { self.setState(Object.assign(self.state, { organization: res.data })); }) .catch(err => { - if (err.response.status === 422) { - location.href = '/#/app/table/organizations'; - } else { - console.error(err); + let errorMessage = ''; + switch(err.response.status){ + case 403: + errorMessage = 'Not authorized to add child organization'; + break; + case 422: + location.href = '/#/app/table/organizations'; + break; + default: + errorMessage = 'Error adding child organization'; + console.error(err); } + this.setState(Object.assign(this.state, { showErrorMessage:true, errorMessage:errorMessage })); + }); } @@ -613,10 +626,32 @@ class Organization extends React.Component { this.getOrganization(organization.id); } + handleDialogDismiss(){ + this.setState(Object.assign(this.state, { showErrorMessage:false })); + } + render() { + + const actions = [ + , + ]; + return (
+ + {this.state.message} +