"use client"; import type { RouterOutputs } from "@openstatus/api"; import type { PrivateLocation } from "@openstatus/db/src/schema"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "@openstatus/ui/components/ui/tooltip"; import type { ColumnDef } from "@tanstack/react-table"; import { Clock, Workflow } from "lucide-react"; import { HoverCardTimestamp } from "@/components/common/hover-card-timestamp"; import { HoverCardTiming } from "@/components/common/hover-card-timing"; import { TableCellDate } from "@/components/data-table/table-cell-date"; import { TableCellNumber } from "@/components/data-table/table-cell-number"; import { TableCellRegion } from "@/components/data-table/table-cell-region"; import { getStatusCodeVariant, textColors } from "@/data/status-codes"; type ResponseLog = RouterOutputs["tinybird"]["list"]["data"][number]; // export const columns: ColumnDef[] = export function getColumns( privateLocations: PrivateLocation[], ): ColumnDef[] { return [ { accessorKey: "requestStatus", header: () => null, enableSorting: false, enableHiding: false, cell: ({ row }) => { const value = row.getValue("requestStatus"); if (value === "error") { return
; } if (value === "degraded") { return
; } if (value === "success") { return
; } return
-
; }, }, { accessorKey: "timestamp", header: "Timestamp", enableSorting: false, enableHiding: false, cell: ({ row }) => { const value = new Date(row.getValue("timestamp")); return ( ); }, }, { accessorKey: "statusCode", header: "Status", enableSorting: false, enableHiding: false, cell: ({ row }) => { const log = row.original; if (log.type === "http") { const value = log.statusCode; const variant = getStatusCodeVariant(value); return ( ); } return
-
; }, }, { accessorKey: "latency", header: "Latency", enableSorting: false, enableHiding: false, cell: ({ row }) => { return ; }, }, { accessorKey: "region", header: "Region", cell: ({ row }) => ( ), enableSorting: false, enableHiding: false, filterFn: "arrIncludesSome", meta: { cellClassName: "text-muted-foreground font-mono", }, }, { accessorKey: "timing", header: "Timing", cell: ({ row }) => { const log = row.original; if (log.type === "http" && log.timing) { return ; } return
-
; }, enableSorting: false, enableHiding: false, }, { accessorKey: "trigger", header: "Trigger", cell: ({ row }) => { const value = row.getValue("trigger"); if (value === "cron" || value === "api") { const Icon = value === "cron" ? Clock : Workflow; const label = value === "cron" ? "Scheduled" : "API"; return (

{label}

); } return
-
; }, enableSorting: false, enableHiding: false, meta: { cellClassName: "font-mono", headerClassName: "sr-only", }, }, ]; }