import PropTypes from 'prop-types'; import React from 'react'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { defineMessages, injectIntl } from 'react-intl'; import { connect } from 'react-redux'; import IconButton from 'soapbox/components/icon_button'; import BundleContainer from 'soapbox/features/ui/containers/bundle_container'; import { DatePicker } from 'soapbox/features/ui/util/async-components'; import { getFeatures } from 'soapbox/utils/features'; const messages = defineMessages({ birthdayPlaceholder: { id: 'edit_profile.fields.birthday_placeholder', defaultMessage: 'Your birthday' }, previousMonth: { id: 'datepicker.previous_month', defaultMessage: 'Previous month' }, nextMonth: { id: 'datepicker.next_month', defaultMessage: 'Next month' }, previousYear: { id: 'datepicker.previous_year', defaultMessage: 'Previous year' }, nextYear: { id: 'datepicker.next_year', defaultMessage: 'Next year' }, }); const mapStateToProps = state => { const features = getFeatures(state.get('instance')); return { supportsBirthdays: features.birthdays, minAge: state.getIn(['instance', 'pleroma', 'metadata', 'birthday_min_age']), }; }; export default @connect(mapStateToProps) @injectIntl class BirthdayInput extends ImmutablePureComponent { static propTypes = { hint: PropTypes.node, required: PropTypes.bool, supportsBirthdays: PropTypes.bool, minAge: PropTypes.number, onChange: PropTypes.func.isRequired, value: PropTypes.instanceOf(Date), }; renderHeader = ({ decreaseMonth, increaseMonth, prevMonthButtonDisabled, nextMonthButtonDisabled, decreaseYear, increaseYear, prevYearButtonDisabled, nextYearButtonDisabled, date, }) => { const { intl } = this.props; return (