2017-09-27 02:33:08 +08:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2018-10-07 14:27:27 +08:00
|
|
|
import { localized, 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 SendLaterOptions = {
|
2018-10-07 14:27:27 +08:00
|
|
|
[localized('In 1 hour')]: DateUtils.in1Hour,
|
|
|
|
[localized('In 2 hours')]: DateUtils.in2Hours,
|
|
|
|
[localized('Later Today')]: DateUtils.laterToday,
|
|
|
|
[localized('Tomorrow Morning')]: DateUtils.tomorrow,
|
|
|
|
[localized('Tomorrow Evening')]: DateUtils.tomorrowEvening,
|
|
|
|
[localized('This Weekend')]: DateUtils.thisWeekend,
|
|
|
|
[localized('Next Week')]: DateUtils.nextWeek,
|
2017-09-27 02:33:08 +08:00
|
|
|
};
|
2017-09-07 07:19:48 +08:00
|
|
|
|
|
|
|
function SendLaterPopover(props) {
|
|
|
|
let footer;
|
2017-09-27 02:33:08 +08:00
|
|
|
const { onAssignSendLaterDate, onCancelSendLater, sendLaterDate } = props;
|
2018-10-07 14:27:27 +08:00
|
|
|
const header = <span key="send-later-header">{localized('Send Later')}:</span>;
|
2017-09-07 07:19:48 +08:00
|
|
|
if (sendLaterDate) {
|
|
|
|
footer = [
|
|
|
|
<div key="divider-unschedule" className="divider" />,
|
|
|
|
<div className="section" key="cancel-section">
|
|
|
|
<button className="btn btn-cancel" onClick={onCancelSendLater}>
|
2018-10-07 14:27:27 +08:00
|
|
|
{localized('Unschedule Send')}
|
2017-09-07 07:19:48 +08:00
|
|
|
</button>
|
|
|
|
</div>,
|
2017-09-27 02:33:08 +08:00
|
|
|
];
|
2017-09-07 07:19:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<DatePickerPopover
|
|
|
|
className="send-later-popover"
|
|
|
|
header={header}
|
|
|
|
footer={footer}
|
|
|
|
dateOptions={SendLaterOptions}
|
|
|
|
onSelectDate={onAssignSendLaterDate}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
SendLaterPopover.displayName = 'SendLaterPopover';
|
|
|
|
SendLaterPopover.propTypes = {
|
2017-09-26 14:50:34 +08:00
|
|
|
sendLaterDate: PropTypes.instanceOf(Date),
|
2017-09-07 07:19:48 +08:00
|
|
|
onAssignSendLaterDate: PropTypes.func.isRequired,
|
|
|
|
onCancelSendLater: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
2017-09-27 02:33:08 +08:00
|
|
|
export default SendLaterPopover;
|