Update TaskButton component to accept the whole task, not just ID
[MAILPOET-5755]
This commit is contained in:
committed by
Ján Mikláš
parent
e8de391741
commit
7d4a737fb6
@@ -1,7 +1,29 @@
|
|||||||
import { Button } from '@wordpress/components';
|
import { Button } from '@wordpress/components';
|
||||||
import { __ } from '@wordpress/i18n';
|
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';
|
const isCancelButton = type === 'cancel';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -17,10 +39,14 @@ function TaskButton({ id, type }: { id: number, type: string }): JSX.Element {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CancelTaskButton({ id }: { id: number }): JSX.Element {
|
type ButtonProps = {
|
||||||
return <TaskButton id={id} type="cancel" />;
|
task: TasksListDataRowProps;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function CancelTaskButton({ task }: ButtonProps): JSX.Element {
|
||||||
|
return <TaskButton task={task} type="cancel" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RescheduleTaskButton({ id }: { id: number }): JSX.Element {
|
export function RescheduleTaskButton({ task }: ButtonProps): JSX.Element {
|
||||||
return <TaskButton id={id} type="reschedule" />;
|
return <TaskButton task={task} type="reschedule" />;
|
||||||
}
|
}
|
||||||
|
@@ -95,12 +95,12 @@ function TasksListDataRow({
|
|||||||
</td>
|
</td>
|
||||||
{showScheduledAt ? (
|
{showScheduledAt ? (
|
||||||
<td>
|
<td>
|
||||||
<CancelTaskButton id={task.id} />
|
<CancelTaskButton task={task} />
|
||||||
</td>
|
</td>
|
||||||
) : null}
|
) : null}
|
||||||
{showCancelledAt ? (
|
{showCancelledAt ? (
|
||||||
<td>
|
<td>
|
||||||
<RescheduleTaskButton id={task.id} />
|
<RescheduleTaskButton task={task} />
|
||||||
</td>
|
</td>
|
||||||
) : null}
|
) : null}
|
||||||
</tr>
|
</tr>
|
||||||
|
Reference in New Issue
Block a user