Update TaskButton component to accept the whole task, not just ID

[MAILPOET-5755]
This commit is contained in:
 Ján Mikláš
2024-06-18 15:06:05 +02:00
committed by Ján Mikláš
parent e8de391741
commit 7d4a737fb6
2 changed files with 33 additions and 7 deletions

View File

@@ -1,7 +1,29 @@
import { Button } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
function TaskButton({ id, type }: { id: number, type: string }): JSX.Element {
type TasksListDataRowProps = {
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;
};
type Props = {
task: TasksListDataRowProps;
type: 'cancel' | 'reschedule';
};
function TaskButton({ task, type }: Props): JSX.Element {
const isCancelButton = type === 'cancel';
return (
@@ -17,10 +39,14 @@ function TaskButton({ id, type }: { id: number, type: string }): JSX.Element {
);
}
export function CancelTaskButton({ id }: { id: number }): JSX.Element {
return <TaskButton id={id} type="cancel" />;
type ButtonProps = {
task: TasksListDataRowProps;
};
export function CancelTaskButton({ task }: ButtonProps): JSX.Element {
return <TaskButton task={task} type="cancel" />;
}
export function RescheduleTaskButton({ id }: { id: number }): JSX.Element {
return <TaskButton id={id} type="reschedule" />;
export function RescheduleTaskButton({ task }: ButtonProps): JSX.Element {
return <TaskButton task={task} type="reschedule" />;
}

View File

@@ -95,12 +95,12 @@ function TasksListDataRow({
</td>
{showScheduledAt ? (
<td>
<CancelTaskButton id={task.id} />
<CancelTaskButton task={task} />
</td>
) : null}
{showCancelledAt ? (
<td>
<RescheduleTaskButton id={task.id} />
<RescheduleTaskButton task={task} />
</td>
) : null}
</tr>