Use new Datepicker on AgeVerification step
This commit is contained in:
parent
165a4cc469
commit
5900068144
|
@ -1,13 +1,17 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
|
interface ISelect extends React.SelectHTMLAttributes<HTMLSelectElement> {
|
||||||
|
children: Iterable<React.ReactNode>,
|
||||||
|
}
|
||||||
|
|
||||||
/** Multiple-select dropdown. */
|
/** Multiple-select dropdown. */
|
||||||
const Select = React.forwardRef<HTMLSelectElement>((props, ref) => {
|
const Select = React.forwardRef<HTMLSelectElement, ISelect>((props, ref) => {
|
||||||
const { children, ...filteredProps } = props;
|
const { children, ...filteredProps } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<select
|
<select
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className='pl-3 pr-10 py-2 text-base border-gray-300 dark:border-slate-700 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 dark:bg-slate-800 sm:text-sm rounded-md'
|
className='w-full pl-3 pr-10 py-2 text-base border-gray-300 dark:border-slate-700 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 dark:bg-slate-800 dark:text-white sm:text-sm rounded-md disabled:opacity-50'
|
||||||
{...filteredProps}
|
{...filteredProps}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import DatePicker from 'react-datepicker';
|
|
||||||
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
|
|
||||||
import snackbar from 'soapbox/actions/snackbar';
|
import snackbar from 'soapbox/actions/snackbar';
|
||||||
import { verifyAge } from 'soapbox/actions/verification';
|
import { verifyAge } from 'soapbox/actions/verification';
|
||||||
import { Button, Form, FormGroup, Text } from 'soapbox/components/ui';
|
import { Button, Datepicker, Form, Text } from 'soapbox/components/ui';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
fail: {
|
fail: {
|
||||||
|
@ -23,13 +22,6 @@ function meetsAgeMinimum(birthday, ageMinimum) {
|
||||||
return new Date(year + ageMinimum, month, day) <= new Date();
|
return new Date(year + ageMinimum, month, day) <= new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMaximumDate(ageMinimum) {
|
|
||||||
const date = new Date();
|
|
||||||
date.setUTCFullYear(date.getUTCFullYear() - ageMinimum);
|
|
||||||
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
const AgeVerification = () => {
|
const AgeVerification = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
@ -67,21 +59,9 @@ const AgeVerification = () => {
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='sm:pt-10 sm:w-2/3 md:w-1/2 mx-auto'>
|
<div className='sm:pt-10 sm:w-2/3 mx-auto'>
|
||||||
<Form onSubmit={handleSubmit}>
|
<Form onSubmit={handleSubmit}>
|
||||||
<FormGroup labelText='Birth Date'>
|
<Datepicker onChange={onChange} />
|
||||||
<DatePicker
|
|
||||||
selected={date}
|
|
||||||
dateFormat='MMMM d, yyyy'
|
|
||||||
onChange={onChange}
|
|
||||||
showMonthDropdown
|
|
||||||
showYearDropdown
|
|
||||||
maxDate={getMaximumDate(ageMinimum)}
|
|
||||||
className='block w-full sm:text-sm border-gray-300 rounded-md focus:ring-indigo-500 focus:border-indigo-500'
|
|
||||||
dropdownMode='select'
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</FormGroup>
|
|
||||||
|
|
||||||
<Text theme='muted' size='sm'>
|
<Text theme='muted' size='sm'>
|
||||||
{siteTitle} requires users to be at least {ageMinimum} years old to
|
{siteTitle} requires users to be at least {ageMinimum} years old to
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
select {
|
select {
|
||||||
@apply pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md;
|
@apply pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md;
|
||||||
|
|
||||||
|
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-error::before,
|
.form-error::before,
|
||||||
|
|
Loading…
Reference in New Issue