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,41 +1,48 @@
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) => {
<tr> let scheduled = props.task.scheduled_at;
<td className="column column-primary"> if (scheduled) {
{ props.task.id } scheduled = parseDate(scheduled, 'yyyy-MM-dd HH:mm:ss', new Date());
</td> }
<td className="column"> return (
{ props.task.type } <tr>
</td> <td className="column column-primary">
<td className="column"> {props.task.id}
{ props.task.newsletter ? (
<a
href={props.task.newsletter.preview_url}
data-newsletter-id={props.task.newsletter.newsletter_id}
data-queue-id={props.task.newsletter.queue_id}
target="_blank"
rel="noopener noreferrer"
>
{props.task.newsletter.subject || MailPoet.I18n.t('preview')}
</a>
) : MailPoet.I18n.t('none')}
</td>
<td className="column">
{ props.task.priority }
</td>
{ props.show_scheduled_at ? (
<td className="column-date">
<abbr>{ MailPoet.Date.format(props.task.scheduled_at * 1000) }</abbr>
</td> </td>
) : null } <td className="column">
<td className="column-date"> {props.task.type}
<abbr>{ MailPoet.Date.format(props.task.updated_at * 1000) }</abbr> </td>
</td> <td className="column">
</tr> {props.task.newsletter ? (
); <a
href={props.task.newsletter.preview_url}
data-newsletter-id={props.task.newsletter.newsletter_id}
data-queue-id={props.task.newsletter.queue_id}
target="_blank"
rel="noopener noreferrer"
>
{props.task.newsletter.subject || MailPoet.I18n.t('preview')}
</a>
) : MailPoet.I18n.t('none')}
</td>
<td className="column">
{props.task.priority}
</td>
{props.show_scheduled_at ? (
<td className="column-date">
<abbr>{`${MailPoet.Date.short(scheduled)} ${MailPoet.Date.time(scheduled)}`}</abbr>
</td>
) : null}
<td className="column-date">
<abbr>{MailPoet.Date.format(props.task.updated_at * 1000)}</abbr>
</td>
</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,