import { injectIntl, defineMessages } from 'react-intl'; import DatePicker from 'react-datepicker'; import IconButton from '../../../components/icon_button'; import { isMobile } from '../../../utils/is_mobile'; import "react-datepicker/dist/react-datepicker.css"; const messages = defineMessages({ schedule_status: { id: 'schedule_status.title', defaultMessage: 'Schedule Status' }, }); class DatePickerWrapper extends React.PureComponent { static propTypes = { value: PropTypes.string, onClick: PropTypes.func, }; render() { const { value, onClick } = this.props; return ( ) } } export default @injectIntl class SchedulePostDropdown extends React.PureComponent { static propTypes = { date: PropTypes.instanceOf(Date), setScheduledAt: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, isPro: PropTypes.bool, onOpenProUpgradeModal: PropTypes.func.isRequired, position: PropTypes.string, }; handleToggle = () => { if (!this.props.isPro) { return this.props.onOpenProUpgradeModal(); } const { date } = this.props; const value = date ? null : new Date(); this.handleSetDate(value); } handleSetDate = (date) => { this.props.setScheduledAt(date); } render () { const { intl, date, isPro, position } = this.props; const open = !!date; const datePickerDisabled = !isPro; const withPortal = isMobile(window.innerWidth); const popperPlacement = position || undefined; return (