Only allows birthdays > 13 yrs old for teacher reg

Helps fix https://github.com/LLK/scratchr2/issues/4470 from the UX side of things
This commit is contained in:
Matthew Taylor 2017-04-12 17:41:43 -04:00
parent 12e87df7c3
commit 2c472b607a
2 changed files with 17 additions and 3 deletions

View file

@ -324,13 +324,26 @@ module.exports = {
},
getYearOptions: function () {
return Array.apply(null, Array(100)).map(function (v, id) {
var year = new Date().getFullYear() - id;
var year = new Date().getFullYear() - (id + 13);
return {value: year, label: year};
});
},
onChooseGender: function (name, gender) {
this.setState({otherDisabled: gender !== 'other'});
},
onValidSubmit: function (formData, reset, invalidate) {
var birthdate = new Date(
formData.user.birth.year,
formData.user.birth.month - 1,
1
);
if (((Date.now() - birthdate) / (24*3600*1000*365.25)) < 13) {
return invalidate({
'user.birth.month': this.props.intl.formatMessage({id: 'teacherRegistration.validationAge'})
});
}
return this.props.onNextStep(formData);
},
render: function () {
var formatMessage = this.props.intl.formatMessage;
return (
@ -348,7 +361,7 @@ module.exports = {
tipContent={formatMessage({id: 'registration.nameStepTooltip'})} />
</p>
<Card>
<Form onValidSubmit={this.props.onNextStep}>
<Form onValidSubmit={this.onValidSubmit}>
<Select label={formatMessage({id: 'general.birthMonth'})}
name="user.birth.month"
options={this.getMonthOptions()}

View file

@ -36,5 +36,6 @@
"teacherRegistration.howUseScratch": "How do you plan to use Scratch at your organization?",
"teacherRegistration.emailStepTitle": "Email Address",
"teacherRegistration.emailStepDescription": "We will send you a confirmation email that will allow you to access your Scratch Teacher Account.",
"teacherRegistration.validationEmailMatch": "The emails do not match"
"teacherRegistration.validationEmailMatch": "The emails do not match",
"teacherRegistration.validationAge": "Sorry, teachers must be over 13 years old"
}