"use client"; import { ColumnDef } from "@tanstack/react-table"; import { DataTable } from "@app/components/ui/data-table"; import { Button } from "@app/components/ui/button"; import { Badge } from "@app/components/ui/badge"; import { LicenseKeyCache } from "@server/license/license"; import { ArrowUpDown } from "lucide-react"; import moment from "moment"; import CopyToClipboard from "@app/components/CopyToClipboard"; import { useTranslations } from "next-intl"; type LicenseKeysDataTableProps = { licenseKeys: LicenseKeyCache[]; onDelete: (key: LicenseKeyCache) => void; onCreate: () => void; }; function obfuscateLicenseKey(key: string): string { if (key.length <= 8) return key; const firstPart = key.substring(0, 4); const lastPart = key.substring(key.length - 4); return `${firstPart}••••••••••••••••••••${lastPart}`; } export function LicenseKeysDataTable({ licenseKeys, onDelete, onCreate }: LicenseKeysDataTableProps) { const t = useTranslations(); const columns: ColumnDef[] = [ { accessorKey: "licenseKey", header: ({ column }) => { return ( ); }, cell: ({ row }) => { const licenseKey = row.original.licenseKey; return ( ); } }, { accessorKey: "valid", header: ({ column }) => { return ( ); }, cell: ({ row }) => { return row.original.valid ? t('yes') : t('no'); } }, { accessorKey: "type", header: ({ column }) => { return ( ); }, cell: ({ row }) => { const type = row.original.type; const label = type === "SITES" ? t('sitesAdditional') : t('licenseHost'); const variant = type === "SITES" ? "secondary" : "default"; return row.original.valid ? ( {label} ) : null; } }, { accessorKey: "numSites", header: ({ column }) => { return ( ); } }, { id: "delete", cell: ({ row }) => (
) } ]; return ( ); }