Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
Make country a required field
Browse files Browse the repository at this point in the history
  • Loading branch information
osahyoun committed Nov 13, 2018
1 parent 563f224 commit e55c9d6
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion app/javascript/email_pension/EmailRepresentativeView.js
Expand Up @@ -6,6 +6,7 @@ import Button from '../components/Button/Button';
import FormGroup from '../components/Form/FormGroup';
import EmailEditor from '../components/EmailEditor/EmailEditor';
import SelectTarget from './SelectTarget';
import SelectCountry from '../components/SelectCountry/SelectCountry';
import { FormattedMessage, injectIntl } from 'react-intl';
import './EmailPensionView.scss';

Expand Down Expand Up @@ -33,6 +34,7 @@ class EmailRepresentativeView extends Component {
name: '',
email: '',
subject: '',
country: '',
target_name: '',
target_email: '',
...props,
Expand All @@ -42,7 +44,7 @@ class EmailRepresentativeView extends Component {
validateForm() {
const errors = {};

const fields = ['subject', 'name', 'email', 'targets'];
const fields = ['country', 'subject', 'name', 'email', 'targets'];

fields.forEach(field => {
if (isEmpty(this.state[field])) {
Expand Down Expand Up @@ -99,6 +101,7 @@ class EmailRepresentativeView extends Component {

const payload = {
body: this.state.body,
country: this.state.country,
subject: this.state.subject,
from_name: this.state.name,
from_email: this.state.email,
Expand Down Expand Up @@ -137,6 +140,23 @@ class EmailRepresentativeView extends Component {
onSubmit={e => e.preventDefault()}
className="action-form form--big"
>
<FormGroup>
<SelectCountry
value={this.state.country}
name="country"
label={
<FormattedMessage
id="email_tool.form.select_country"
defaultMessage="Select country (default)"
/>
}
className="form-control"
errorMessage={this.state.errors.country}
onChange={value => {
this.handleChange({ country: value });
}}
/>
</FormGroup>
<SelectTarget
handler={this.handleTargetSelection.bind(this)}
endpoint={this.props.targetEndpoint}
Expand Down

0 comments on commit e55c9d6

Please sign in to comment.