mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-02-17 00:21:20 -05:00
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:
parent
12e87df7c3
commit
2c472b607a
2 changed files with 17 additions and 3 deletions
|
@ -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()}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue