import { MailPoet } from 'mailpoet';
import { CancelTaskButton, RescheduleTaskButton } from './tasks-list-actions';
export type Props = {
type: string;
task: {
id: number;
type: string;
priority: number;
updatedAt: string;
scheduledAt?: string;
cancelledAt?: string;
status?: string;
newsletter: {
newsletterId?: number;
queueId?: number;
previewUrl?: string;
subject?: string;
};
subscriberEmail?: string;
};
};
function TasksListDataRow({ type, task }: Props): JSX.Element {
const showScheduledAt = type === 'scheduled';
const showCancelledAt = type === 'cancelled';
const canCancelTask = type === 'scheduled' || type === 'running';
const canRescheduleTask = type === 'cancelled';
return (
{task.id} |
{task.newsletter ? (
{task.newsletter.subject || MailPoet.I18n.t('preview')}
) : (
MailPoet.I18n.t('none')
)}
|
{task.subscriberEmail ? (
{task.subscriberEmail}
) : (
{MailPoet.I18n.t('multipleSubscribers')}
)}
|
{task.priority} |
{showScheduledAt ? (
{`${MailPoet.Date.shortFromGmt(
task.scheduledAt,
)} ${MailPoet.Date.timeFromGmt(task.scheduledAt)}`}
|
) : null}
{showCancelledAt ? (
{`${MailPoet.Date.shortFromGmt(
task.cancelledAt,
)} ${MailPoet.Date.timeFromGmt(task.cancelledAt)}`}
|
) : null}
{`${MailPoet.Date.shortFromGmt(
task.updatedAt,
)} ${MailPoet.Date.timeFromGmt(task.updatedAt)}`}
|
{canCancelTask ? (
|
) : null}
{canRescheduleTask ? (
|
) : null}
);
}
export { TasksListDataRow };