"use client"; import { use } from "react"; import Link from "next/link"; import { ArrowLeft, Loader2, Repeat, Trash2 } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { usePipeline, usePipelineStatuses, useDeletePipeline } from "@/hooks/use-pipelines"; import { PipelineProgress } from "@/components/pipeline/pipeline-progress"; import { toast } from "sonner"; import { useRouter } from "next/navigation"; export default function PipelineDetailPage({ params, }: { params: Promise<{ id: string }>; }) { const { id: idStr } = use(params); const id = Number(idStr); const router = useRouter(); const { data, isLoading, error } = usePipeline(id); const { data: statuses } = usePipelineStatuses(); const deleteMutation = useDeletePipeline(); const status = (statuses ?? []).find((s) => s.pipeline_id === id) ?? null; function handleDelete() { deleteMutation.mutate(id, { onSuccess: () => { toast.success("Pipeline deleted"); router.push("/automations"); }, onError: (err) => toast.error(`Failed to delete: ${err.message}`), }); } if (isLoading) { return (
Failed to load pipeline. It may have been deleted.
{config.description}
)}