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) {
label: <intl.FormattedMessage id="teacherRegistration.selectCountry" />, var options = countryData.countryOptions.concat({
disabled: true, label: <intl.FormattedMessage id="teacherRegistration.selectCountry" />,
selected: true disabled: true,
}).sort(function (a, b) { selected: true
if (a.disabled) return -1; });
if (b.disabled) return 1; if (typeof defaultCountry !== 'undefined') {
if (a.value === DEFAULT_COUNTRY) return -1; return options.sort(function (a, b) {
if (b.value === DEFAULT_COUNTRY) return 1; if (a.disabled) return -1;
return 0; if (b.disabled) return 1;
}.bind(this)); if (a.value === defaultCountry) return -1;
if (b.value === defaultCountry) return 1;
return 0;
}.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