mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
Fixed Issue 1930
This commit is contained in:
parent
56fd5c7ed7
commit
86551baa94
1 changed files with 14 additions and 9 deletions
|
@ -444,18 +444,20 @@ class DemographicsStep extends React.Component {
|
||||||
handleChooseGender (name, gender) {
|
handleChooseGender (name, gender) {
|
||||||
this.setState({otherDisabled: gender !== 'other'});
|
this.setState({otherDisabled: gender !== 'other'});
|
||||||
}
|
}
|
||||||
handleValidSubmit (formData, reset, invalidate) {
|
handleValidSubmit (formData) {
|
||||||
|
return this.props.onNextStep(formData);
|
||||||
|
}
|
||||||
|
isValidBirthdate (year, month) {
|
||||||
const birthdate = new Date(
|
const birthdate = new Date(
|
||||||
formData.user.birth.year,
|
year,
|
||||||
formData.user.birth.month - 1,
|
month - 1,
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
if (((Date.now() - birthdate) / (24 * 3600 * 1000 * 365.25)) < this.props.birthOffset) {
|
return (((Date.now() - birthdate) / (24 * 3600 * 1000 * 365.25)) >= this.props.birthOffset);
|
||||||
return invalidate({
|
}
|
||||||
'user.birth.year': this.props.intl.formatMessage({id: 'teacherRegistration.validationAge'})
|
birthDateValidator (values) {
|
||||||
});
|
const isValid = this.isValidBirthdate(values['user.birth.year'], values['user.birth.month']);
|
||||||
}
|
return isValid ? true : this.props.intl.formatMessage({id: 'teacherRegistration.validationAge'});
|
||||||
return this.props.onNextStep(formData);
|
|
||||||
}
|
}
|
||||||
render () {
|
render () {
|
||||||
const countryOptions = getCountryOptions(this.props.intl, DEFAULT_COUNTRY);
|
const countryOptions = getCountryOptions(this.props.intl, DEFAULT_COUNTRY);
|
||||||
|
@ -485,6 +487,9 @@ class DemographicsStep extends React.Component {
|
||||||
}
|
}
|
||||||
name="user.birth.month"
|
name="user.birth.month"
|
||||||
options={this.getMonthOptions()}
|
options={this.getMonthOptions()}
|
||||||
|
validations={{
|
||||||
|
birthDateVal: values => this.birthDateValidator(values)
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<Select
|
<Select
|
||||||
required
|
required
|
||||||
|
|
Loading…
Reference in a new issue