diff --git a/app/soapbox/components/birth_date_input.js b/app/soapbox/components/birth_date_input.js index 3147c317e..b07c54515 100644 --- a/app/soapbox/components/birth_date_input.js +++ b/app/soapbox/components/birth_date_input.js @@ -34,18 +34,14 @@ class EditProfile extends ImmutablePureComponent { value: PropTypes.instanceOf(Date), }; - isDateValid = date => { - const { minAge } = this.props; - const allowedDate = new Date(); - allowedDate.setDate(allowedDate.getDate() - minAge); - return date && allowedDate.setHours(0, 0, 0, 0) >= new Date(date).setHours(0, 0, 0, 0); - } - render() { - const { intl, value, onChange, supportsBirthDates, hint, required } = this.props; + const { intl, value, onChange, supportsBirthDates, hint, required, minAge } = this.props; if (!supportsBirthDates) return null; + const maxDate = new Date(); + maxDate.setDate(maxDate.getDate() - minAge); + return (
{hint && ( @@ -60,7 +56,7 @@ class EditProfile extends ImmutablePureComponent { wrapperClassName='react-datepicker-wrapper' onChange={onChange} placeholderText={intl.formatMessage(messages.birthDatePlaceholder)} - filterDate={this.isDateValid} + maxDate={maxDate} required={required} />
diff --git a/app/soapbox/features/auth_login/components/registration_form.js b/app/soapbox/features/auth_login/components/registration_form.js index 0bc68be30..52272f1f9 100644 --- a/app/soapbox/features/auth_login/components/registration_form.js +++ b/app/soapbox/features/auth_login/components/registration_form.js @@ -325,7 +325,7 @@ class RegistrationForm extends ImmutablePureComponent { error={passwordMismatch === true} required /> - {!birthDateRequired && + {birthDateRequired &&