add error-message when repeated data is sended in topic-edit-modal component
This commit is contained in:
parent
fbfbcef21a
commit
dd9e269fa5
|
@ -11,6 +11,7 @@ import SubmitButton from 'core-components/submit-button';
|
||||||
import IconSelector from 'core-components/icon-selector';
|
import IconSelector from 'core-components/icon-selector';
|
||||||
import ColorSelector from 'core-components/color-selector';
|
import ColorSelector from 'core-components/color-selector';
|
||||||
import InfoTooltip from 'core-components/info-tooltip';
|
import InfoTooltip from 'core-components/info-tooltip';
|
||||||
|
import Message from 'core-components/message';
|
||||||
|
|
||||||
class TopicEditModal extends React.Component {
|
class TopicEditModal extends React.Component {
|
||||||
|
|
||||||
|
@ -26,7 +27,8 @@ class TopicEditModal extends React.Component {
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
values: this.props.defaultValues || {title: '', icon: 'address-card', color: '#ff6900', private: false},
|
values: this.props.defaultValues || {title: '', icon: 'address-card', color: '#ff6900', private: false},
|
||||||
loading: false
|
loading: false,
|
||||||
|
errorMessage: false
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -34,6 +36,7 @@ class TopicEditModal extends React.Component {
|
||||||
<div className="topic-edit-modal">
|
<div className="topic-edit-modal">
|
||||||
<Header title={i18n((this.props.addForm) ? 'ADD_TOPIC' : 'EDIT_TOPIC')} description={i18n((this.props.addForm) ? 'ADD_TOPIC_DESCRIPTION' : 'EDIT_TOPIC_DESCRIPTION')} />
|
<Header title={i18n((this.props.addForm) ? 'ADD_TOPIC' : 'EDIT_TOPIC')} description={i18n((this.props.addForm) ? 'ADD_TOPIC_DESCRIPTION' : 'EDIT_TOPIC_DESCRIPTION')} />
|
||||||
<Form values={this.state.values} onChange={this.onFormChange.bind(this)} onSubmit={this.onSubmit.bind(this)} loading={this.state.loading}>
|
<Form values={this.state.values} onChange={this.onFormChange.bind(this)} onSubmit={this.onSubmit.bind(this)} loading={this.state.loading}>
|
||||||
|
{this.state.errorMessage ? <Message type="error">{i18n(this.state.errorMessage)}</Message> : null}
|
||||||
<FormField name="title" label={i18n('TITLE')} fieldProps={{size: 'large'}} validation="TITLE" required />
|
<FormField name="title" label={i18n('TITLE')} fieldProps={{size: 'large'}} validation="TITLE" required />
|
||||||
<FormField name="icon" className="topic-edit-modal__icon" label={i18n('ICON')} decorator={IconSelector} />
|
<FormField name="icon" className="topic-edit-modal__icon" label={i18n('ICON')} decorator={IconSelector} />
|
||||||
<FormField name="color" className="topic-edit-modal__color" label={i18n('COLOR')} decorator={ColorSelector} />
|
<FormField name="color" className="topic-edit-modal__color" label={i18n('COLOR')} decorator={ColorSelector} />
|
||||||
|
@ -68,13 +71,16 @@ class TopicEditModal extends React.Component {
|
||||||
}
|
}
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.context.closeModal();
|
this.context.closeModal();
|
||||||
|
this.setState({
|
||||||
|
errorMessage: false
|
||||||
|
});
|
||||||
if(this.props.onChange) {
|
if(this.props.onChange) {
|
||||||
this.props.onChange();
|
this.props.onChange();
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
}).catch((e) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: false
|
loading: false,
|
||||||
|
errorMessage: e.message
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue