Files
2026-07-08 16:15:37 +02:00

46 lines
2.3 KiB
TypeScript

import { Link, useLoaderData } from "react-router";
import { useTranslation } from "react-i18next";
import type { LoaderFunctionArgs } from "react-router";
import { loadAutomationExecutionsVM, type AutomationExecutionListVM } from "~/services/automation/automation.server";
export async function loader({ request, params }: LoaderFunctionArgs) {
return Response.json(await loadAutomationExecutionsVM({ request, params }));
}
export default function AutomationExecutionsRoute() {
const data = useLoaderData() as AutomationExecutionListVM;
const { t } = useTranslation();
return (
<main className="mx-auto flex w-full max-w-6xl flex-col gap-6 p-6">
<header className="flex flex-col gap-2">
<h1 className="text-foreground text-2xl font-semibold">{data.rule.name}</h1>
<p className="text-muted-foreground text-sm">{t("automation.executions.subtitle", { trigger: data.rule.triggerKey ?? t("automation.values.noTrigger") })}</p>
</header>
<section className="overflow-hidden rounded-lg border">
<div className="border-b px-4 py-3">
<h2 className="text-foreground text-sm font-semibold">{t("automation.sections.executions")}</h2>
</div>
{data.executions.length === 0 ? (
<div className="text-muted-foreground px-4 py-8 text-sm">{t("automation.empty.executions")}</div>
) : (
<div className="divide-y">
{data.executions.map((execution) => (
<Link className="hover:bg-muted/40 grid gap-2 px-4 py-3 md:grid-cols-[1fr_140px_120px_180px]" key={execution.id} to={execution.detailUrl}>
<span>
<span className="text-foreground block text-sm font-medium">{execution.summaryText}</span>
<span className="text-muted-foreground block text-xs">{execution.triggerKey}</span>
</span>
<span className="text-muted-foreground text-sm">{t(`automation.status.${execution.status}`, { defaultValue: execution.status })}</span>
<span className="text-muted-foreground text-sm">{execution.dryRun ? t("automation.values.dryRun") : t("automation.values.liveRun")}</span>
<span className="text-muted-foreground text-sm">{execution.createdAt}</span>
</Link>
))}
</div>
)}
</section>
</main>
);
}