Commit 9bd08267 authored by mgabdev's avatar mgabdev

Updated schedule post dropdown

parent 09a87788
...@@ -11,11 +11,22 @@ const messages = defineMessages({ ...@@ -11,11 +11,22 @@ const messages = defineMessages({
schedule_status: { id: 'schedule_status.title', defaultMessage: 'Schedule Status' }, schedule_status: { id: 'schedule_status.title', defaultMessage: 'Schedule Status' },
}); });
const DatePickerWrapper = ({ value, onClick }) => ( class DatePickerWrapper extends React.PureComponent {
<button className="schedule-post-dropdown-wrapper" onClick={onClick}> static propTypes = {
{value} value: PropTypes.string,
</button> onClick: PropTypes.func,
); };
render() {
const { value, onClick } = this.props;
return (
<button className="schedule-post-dropdown-wrapper" onClick={onClick}>
{value}
</button>
)
}
}
export default @injectIntl export default @injectIntl
class SchedulePostDropdown extends React.PureComponent { class SchedulePostDropdown extends React.PureComponent {
...@@ -28,23 +39,14 @@ class SchedulePostDropdown extends React.PureComponent { ...@@ -28,23 +39,14 @@ class SchedulePostDropdown extends React.PureComponent {
onOpenProUpgradeModal: PropTypes.func.isRequired, onOpenProUpgradeModal: PropTypes.func.isRequired,
}; };
state = {
open: false,
};
handleToggle = () => { handleToggle = () => {
if (!this.props.isPro) { if (!this.props.isPro) {
return this.props.onOpenProUpgradeModal(); return this.props.onOpenProUpgradeModal();
} }
const newOpen = !this.state.open; const { date } = this.props;
const newDate = newOpen ? new Date() : null; const value = date ? null : new Date();
this.handleSetDate(value);
this.handleSetDate(newDate);
this.setState({
open: newOpen
});
} }
handleSetDate = (date) => { handleSetDate = (date) => {
...@@ -53,7 +55,8 @@ class SchedulePostDropdown extends React.PureComponent { ...@@ -53,7 +55,8 @@ class SchedulePostDropdown extends React.PureComponent {
render () { render () {
const { intl, date, isPro } = this.props; const { intl, date, isPro } = this.props;
const { open } = this.state;
const open = !!date;
const datePickerDisabled = !isPro; const datePickerDisabled = !isPro;
const withPortal = isMobile(window.innerWidth); const withPortal = isMobile(window.innerWidth);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment