Commit 40fb433d authored by Matthew Taylor's avatar Matthew Taylor

Make country choice a function that’s called

And also default the country in address to the country in demographics. Thanks @rschamp @carljbowman!
parent 2650e6e1
...@@ -27,17 +27,23 @@ var Tooltip = require('../../components/tooltip/tooltip.jsx'); ...@@ -27,17 +27,23 @@ var Tooltip = require('../../components/tooltip/tooltip.jsx');
require('./steps.scss'); require('./steps.scss');
var DEFAULT_COUNTRY = 'us'; var DEFAULT_COUNTRY = 'us';
var COUNTRY_OPTIONS = countryData.countryOptions.concat({ var getCountryOptions = function (defaultCountry) {
var options = countryData.countryOptions.concat({
label: <intl.FormattedMessage id="teacherRegistration.selectCountry" />, label: <intl.FormattedMessage id="teacherRegistration.selectCountry" />,
disabled: true, disabled: true,
selected: true selected: true
}).sort(function (a, b) { });
if (typeof defaultCountry !== 'undefined') {
return options.sort(function (a, b) {
if (a.disabled) return -1; if (a.disabled) return -1;
if (b.disabled) return 1; if (b.disabled) return 1;
if (a.value === DEFAULT_COUNTRY) return -1; if (a.value === defaultCountry) return -1;
if (b.value === DEFAULT_COUNTRY) return 1; if (b.value === defaultCountry) return 1;
return 0; return 0;
}.bind(this)); }.bind(this));
}
return options;
};
var NextStepButton = React.createClass({ var NextStepButton = React.createClass({
getDefaultProps: function () { getDefaultProps: function () {
...@@ -277,7 +283,7 @@ module.exports = { ...@@ -277,7 +283,7 @@ module.exports = {
'August', 'September', 'October', 'November', 'December' 'August', 'September', 'October', 'November', 'December'
].map(function (label, id) { ].map(function (label, id) {
return { return {
value: id+1, value: id + 1,
label: this.props.intl.formatMessage({id: 'general.month' + label})}; label: this.props.intl.formatMessage({id: 'general.month' + label})};
}.bind(this)); }.bind(this));
}, },
...@@ -333,7 +339,7 @@ module.exports = { ...@@ -333,7 +339,7 @@ module.exports = {
</div> </div>
<Select label={formatMessage({id: 'general.country'})} <Select label={formatMessage({id: 'general.country'})}
name="user.country" name="user.country"
options={COUNTRY_OPTIONS} options={getCountryOptions(DEFAULT_COUNTRY)}
required /> required />
<Checkbox className="demographics-checkbox-is-robot" <Checkbox className="demographics-checkbox-is-robot"
label="I'm a robot!" label="I'm a robot!"
...@@ -598,7 +604,8 @@ module.exports = { ...@@ -598,7 +604,8 @@ module.exports = {
<Form onValidSubmit={this.onValidSubmit}> <Form onValidSubmit={this.onValidSubmit}>
<Select label={formatMessage({id: 'general.country'})} <Select label={formatMessage({id: 'general.country'})}
name="address.country" name="address.country"
options={COUNTRY_OPTIONS} options={getCountryOptions()}
value={this.props.defaultCountry}
onChange={this.onChangeCountry} onChange={this.onChangeCountry}
required /> required />
<Input label={formatMessage({id: 'teacherRegistration.addressLine1'})} <Input label={formatMessage({id: 'teacherRegistration.addressLine1'})}
......
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
&.organization-step { &.organization-step {
.checkbox-group { .checkbox-group {
.validation-message { .validation-message {
transform: translate(16rem, -16rem); transform: translate(16rem, 8rem);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment