"use client"; import { ColumnDef } from "@tanstack/react-table"; import { ExtendedColumnDef } from "@app/components/ui/data-table"; import { useTranslations } from "next-intl"; import { Badge } from "@app/components/ui/badge"; import { DNSRecordsDataTable } from "./DNSRecordsDataTable"; import CopyToClipboard from "@app/components/CopyToClipboard"; import { useEnvContext } from "@app/hooks/useEnvContext"; export type DNSRecordRow = { id: string; recordType: string; // "NS" | "CNAME" | "A" | "TXT" baseDomain: string | null; value: string; verified?: boolean; }; type Props = { records: DNSRecordRow[]; type: string | null; }; export default function DNSRecordsTable({ records, type }: Props) { const t = useTranslations(); const env = useEnvContext(); const statusColumn: ColumnDef = { accessorKey: "verified", header: ({ column }) => { return
{t("status")}
; }, cell: ({ row }) => { const verified = row.original.verified; return verified ? ( type === "wildcard" ? ( {t("manual", { fallback: "Manual" })} ) : ( {t("verified")} ) ) : ( {t("pending", { fallback: "Pending" })} ); } }; const columns: ExtendedColumnDef[] = [ { accessorKey: "baseDomain", friendlyName: t("recordName", { fallback: "Record name" }), header: ({ column }) => { return (
{t("recordName", { fallback: "Record name" })}
); }, cell: ({ row }) => { const baseDomain = row.original.baseDomain; return baseDomain ? ( ) : (
-
); } }, { accessorKey: "recordType", friendlyName: t("type"), header: ({ column }) => { return
{t("type")}
; }, cell: ({ row }) => { const type = row.original.recordType; return
{type}
; } }, { accessorKey: "ttl", friendlyName: t("TTL"), header: ({ column }) => { return
{t("TTL")}
; }, cell: ({ row }) => { return
{t("auto")}
; } }, { accessorKey: "value", friendlyName: t("value"), header: () => { return
{t("value")}
; }, cell: ({ row }) => { const value = row.original.value; return ( ); } }, ...(env.env.flags.usePangolinDns ? [statusColumn] : []) ]; return ( ); }