"use client"; import { ColumnDef } from "@tanstack/react-table"; import { ExtendedColumnDef } from "@app/components/ui/data-table"; import { Button } from "@app/components/ui/button"; import { ArrowRight, ArrowUpDown, Globe, Terminal, Webhook } from "lucide-react"; import { useTransition } from "react"; import { Badge } from "@app/components/ui/badge"; import { useRouter } from "next/navigation"; import { useTranslations } from "next-intl"; import { DataTable } from "./ui/data-table"; import Link from "next/link"; import { ListBlueprintsResponse } from "@server/routers/blueprints"; export type BlueprintRow = ListBlueprintsResponse["blueprints"][number]; type Props = { blueprints: BlueprintRow[]; orgId: string; }; export default function BlueprintsTable({ blueprints, orgId }: Props) { const t = useTranslations(); const [isRefreshing, startTransition] = useTransition(); const router = useRouter(); const columns: ExtendedColumnDef[] = [ { accessorKey: "name", enableHiding: false, friendlyName: t("name"), header: ({ column }) => { return ( ); } }, { accessorKey: "createdAt", friendlyName: t("appliedAt"), header: ({ column }) => { return ( ); }, cell: ({ row }) => { return ( ); } }, { accessorKey: "source", friendlyName: t("source"), header: ({ column }) => { return ( ); }, cell: ({ row }) => { const originalRow = row.original; switch (originalRow.source) { case "API": { return ( API ); } case "NEWT": { return ( Newt CLI ); } case "UI": { return ( Dashboard ); } case "CLI": { return ( CLI ); } } } }, { accessorKey: "succeeded", header: ({ column }) => { return ( ); }, cell: ({ row }) => { const { succeeded } = row.original; if (succeeded) { return {t("success")}; } else { return ( {t("failed", { fallback: "Failed" })} ); } } }, { id: "actions", enableHiding: false, header: () => , cell: ({ row }) => { return (
); } } ]; return ( { router.push(`/${orgId}/settings/blueprints/create`); }} addButtonText={t("blueprintAdd")} onRefresh={() => { startTransition(() => router.refresh()); }} isRefreshing={isRefreshing} defaultSort={{ id: "createdAt", desc: true }} /> ); }