function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import messages from './messages'; // $FlowFixMe LabelPill is in typescript

import LabelPill from '../../../../components/label-pill';
import { ReadableTime } from '../../../../components/time';
import { TASK_NEW_NOT_STARTED } from '../../../../constants';

var TaskDueDate = function TaskDueDate(_ref) {
  var dueDate = _ref.dueDate,
      status = _ref.status;
  var isOverdue = dueDate ? status === TASK_NEW_NOT_STARTED && new Date(dueDate) < Date.now() : false;
  var fullDueDate = new Date(dueDate);
  var pillProps = isOverdue ? {
    'data-testid': 'task-overdue-date',
    type: 'error'
  } : {
    type: 'default'
  };
  return /*#__PURE__*/React.createElement("div", {
    "data-testid": "task-due-date"
  }, /*#__PURE__*/React.createElement(LabelPill.Pill, pillProps, /*#__PURE__*/React.createElement(LabelPill.Text, null, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.taskFeedStatusDue, {
    values: {
      dateTime: /*#__PURE__*/React.createElement(ReadableTime, {
        alwaysShowTime: true,
        uppercase: true,
        timestamp: fullDueDate.getTime()
      })
    }
  })))));
};

export default TaskDueDate;
//# sourceMappingURL=TaskDueDate.js.map