Make dates in newsletter listings and help consistent

[MAILPOET-3441]
This commit is contained in:
Pavel Dohnal
2021-03-08 14:34:40 +01:00
committed by Veljko V
parent aff4c9d5b7
commit 91b468fabf
2 changed files with 41 additions and 34 deletions

View File

@@ -1,17 +1,23 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React from 'react'; import React from 'react';
import MailPoet from 'mailpoet'; import MailPoet from 'mailpoet';
import parseDate from 'date-fns/parse';
const TasksListDataRow = (props) => ( const TasksListDataRow = (props) => {
let scheduled = props.task.scheduled_at;
if (scheduled) {
scheduled = parseDate(scheduled, 'yyyy-MM-dd HH:mm:ss', new Date());
}
return (
<tr> <tr>
<td className="column column-primary"> <td className="column column-primary">
{ props.task.id } {props.task.id}
</td> </td>
<td className="column"> <td className="column">
{ props.task.type } {props.task.type}
</td> </td>
<td className="column"> <td className="column">
{ props.task.newsletter ? ( {props.task.newsletter ? (
<a <a
href={props.task.newsletter.preview_url} href={props.task.newsletter.preview_url}
data-newsletter-id={props.task.newsletter.newsletter_id} data-newsletter-id={props.task.newsletter.newsletter_id}
@@ -24,18 +30,19 @@ const TasksListDataRow = (props) => (
) : MailPoet.I18n.t('none')} ) : MailPoet.I18n.t('none')}
</td> </td>
<td className="column"> <td className="column">
{ props.task.priority } {props.task.priority}
</td> </td>
{ props.show_scheduled_at ? ( {props.show_scheduled_at ? (
<td className="column-date"> <td className="column-date">
<abbr>{ MailPoet.Date.format(props.task.scheduled_at * 1000) }</abbr> <abbr>{`${MailPoet.Date.short(scheduled)} ${MailPoet.Date.time(scheduled)}`}</abbr>
</td> </td>
) : null } ) : null}
<td className="column-date"> <td className="column-date">
<abbr>{ MailPoet.Date.format(props.task.updated_at * 1000) }</abbr> <abbr>{MailPoet.Date.format(props.task.updated_at * 1000)}</abbr>
</td> </td>
</tr> </tr>
); );
};
TasksListDataRow.propTypes = { TasksListDataRow.propTypes = {
show_scheduled_at: PropTypes.bool, show_scheduled_at: PropTypes.bool,

View File

@@ -83,7 +83,7 @@ class State {
'type' => $task->type, 'type' => $task->type,
'priority' => (int)$task->priority, 'priority' => (int)$task->priority,
'updated_at' => Carbon::createFromTimeString((string)$task->updatedAt)->timestamp, 'updated_at' => Carbon::createFromTimeString((string)$task->updatedAt)->timestamp,
'scheduled_at' => $task->scheduledAt ? Carbon::createFromTimeString($task->scheduledAt)->timestamp : null, 'scheduled_at' => $task->scheduledAt ? $task->scheduledAt : null,
'status' => $task->status, 'status' => $task->status,
'newsletter' => (($queue instanceof SendingQueue) && ($newsletter instanceof Newsletter)) ? [ 'newsletter' => (($queue instanceof SendingQueue) && ($newsletter instanceof Newsletter)) ? [
'newsletter_id' => (int)$queue->newsletterId, 'newsletter_id' => (int)$queue->newsletterId,