2017-09-27 02:33:08 +08:00
|
|
|
import React from 'react';
|
|
|
|
import moment from 'moment';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-09-27 02:42:18 +08:00
|
|
|
import { DateUtils } from 'mailspring-exports';
|
2017-09-27 02:46:00 +08:00
|
|
|
import { DatePickerPopover } from 'mailspring-component-kit';
|
2017-09-07 07:19:48 +08:00
|
|
|
|
|
|
|
const SendRemindersOptions = {
|
|
|
|
'In 1 hour': DateUtils.in1Hour,
|
|
|
|
'In 2 hours': DateUtils.in2Hours,
|
|
|
|
'In 4 hours': () => DateUtils.minutesFromNow(240),
|
|
|
|
'Tomorrow morning': DateUtils.tomorrow,
|
|
|
|
'Tomorrow evening': DateUtils.tomorrowEvening,
|
|
|
|
'In 2 days': () => DateUtils.hoursFromNow(48),
|
|
|
|
'In 4 days': () => DateUtils.hoursFromNow(96),
|
|
|
|
'In 1 week': () => DateUtils.weeksFromNow(1),
|
|
|
|
'In 2 weeks': () => DateUtils.weeksFromNow(2),
|
|
|
|
'In 1 month': () => DateUtils.monthsFromNow(1),
|
2017-09-27 02:33:08 +08:00
|
|
|
};
|
2017-09-07 07:19:48 +08:00
|
|
|
|
|
|
|
function SendRemindersPopover(props) {
|
2017-09-27 02:33:08 +08:00
|
|
|
const { reminderDate, onRemind, onCancelReminder } = props;
|
|
|
|
const header = <span key="reminders-header">Remind me if no one replies:</span>;
|
2017-09-26 06:44:20 +08:00
|
|
|
const footer = [];
|
|
|
|
|
|
|
|
if (reminderDate) {
|
2017-09-27 02:33:08 +08:00
|
|
|
footer.push(<div key="reminders-divider" className="divider" />);
|
2017-09-26 06:44:20 +08:00
|
|
|
footer.push(
|
2017-09-27 02:33:08 +08:00
|
|
|
<div key="send-reminders-footer" className="section send-reminders-footer">
|
2017-09-07 07:19:48 +08:00
|
|
|
<div className="reminders-label">
|
|
|
|
<span>
|
|
|
|
This thread will come back to the top of your inbox if nobody replies by:
|
|
|
|
<span className="reminder-date">
|
2017-09-26 06:44:20 +08:00
|
|
|
{` ${moment(reminderDate).format(DateUtils.DATE_FORMAT_LONG_NO_YEAR)}`}
|
2017-09-07 07:19:48 +08:00
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<button className="btn btn-cancel" onClick={onCancelReminder}>
|
|
|
|
Clear reminder
|
|
|
|
</button>
|
2017-09-26 06:44:20 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2017-09-07 07:19:48 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<DatePickerPopover
|
|
|
|
className="send-reminders-popover"
|
|
|
|
header={header}
|
|
|
|
footer={footer}
|
|
|
|
onSelectDate={onRemind}
|
|
|
|
dateOptions={SendRemindersOptions}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
SendRemindersPopover.displayName = 'SendRemindersPopover';
|
|
|
|
|
|
|
|
SendRemindersPopover.propTypes = {
|
2017-09-26 06:44:20 +08:00
|
|
|
reminderDate: PropTypes.instanceOf(Date),
|
2017-09-07 07:19:48 +08:00
|
|
|
onRemind: PropTypes.func,
|
|
|
|
onCancelReminder: PropTypes.func,
|
|
|
|
};
|
|
|
|
|
2017-09-27 02:33:08 +08:00
|
|
|
export default SendRemindersPopover;
|