"use client"; import { Alert } from "@/components/ui/alert"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Checkbox } from "@/components/ui/checkbox"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { toast } from "@/components/ui/toaster"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; // import { trpc } from "@/lib/trpc/client"; // import { ColumnDef } from "@tanstack/react-table"; import { ArrowUpDown, Check, FileClock, Minus, MoreHorizontal, MoreVertical, Trash, X, } from "lucide-react"; // import ms from "ms"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { Loading } from "../loading"; import { DataTable } from "./table"; type Column = { id: string; start: string; createdAt: Date; expires: Date | null; enabled: boolean; ownerId: string | null; name: string | null; ratelimitType: string | null; ratelimitLimit: number | null; ratelimitRefillRate: number | null; ratelimitRefillInterval: number | null; remaining: number | null; refillInterval: string | null; refillAmount: number | null; }; type Props = { data: Column[]; }; export const ApiKeyTable: React.FC = ({ data }) => { const router = useRouter(); // const deleteKey = trpc.key.delete.useMutation({ // onSuccess: () => { // toast.success("Key was deleted"); // router.refresh(); // }, // onError: (err, variables) => { // toast.error(`Could not delete key ${JSON.stringify(variables)}`, { // description: err.message, // }); // router.refresh(); // }, // }); // const columns: ColumnDef[] = [ // { // id: "select", // header: ({ table }) => ( //
// table.toggleAllPageRowsSelected(!!value)} // aria-label="Select all" // /> //
// ), // cell: ({ row }) => ( //
// row.toggleSelected(!!value)} // aria-label="Select row" // /> //
// ), // enableSorting: false, // enableHiding: false, // }, // { // accessorKey: "start", // header: "Key", // cell: ({ row }) => ( // // // {row.getValue("start")}... // // // This is the first part of the key to visually match it. We don't store the full key for // security reasons. // // // ), // }, // { // accessorKey: "createdAt", // header: ({ column }) => ( // // ), // cell: ({ row }) => row.original.createdAt.toUTCString(), // }, // { // accessorKey: "enabled", // header: "Enabled", // cell: ({ row }) => // row.original.enabled ? ( // // // // ) : ( // // // // ), // }, // { // accessorKey: "expires", // header: "Expires", // cell: ({ row }) => // row.original.expires ? ( // row.original.expires.getTime() < Date.now() ? ( // // // Expired // // //

// This key expired{" "} // {ms(Date.now() - row.original.expires.getTime(), { // long: true, // })}{" "} // ago. // // // //

//
//
// ) : ( // in {ms(row.original.expires.getTime() - Date.now(), { long: true })} // ) // ) : ( // // ), // }, // { // accessorKey: "remaining", // header: "Remaining", // cell: ({ row }) => // row.original.remaining ? ( // {row.original.remaining.toLocaleString()} // ) : ( // // ), // }, // { // accessorKey: "refillInterval", // header: "Refill Rate", // cell: ({ row }) => // row.original.refillInterval && row.original.refillAmount && row.original.remaining ? ( //
// {row.original.refillInterval} //
// ) : ( // // ), // }, // { // accessorKey: "ownerId", // header: "Owner", // cell: ({ row }) => // row.original.ownerId ? ( // {row.original.ownerId} // ) : ( // // ), // }, // { // accessorKey: "name", // header: "Name", // cell: ({ row }) => // row.original.name ? ( // {row.original.name} // ) : ( // // ), // }, // { // accessorKey: "ratelimit", // header: "Ratelimit", // cell: ({ row }) => // row.original.ratelimitType && // row.original.ratelimitLimit && // row.original.ratelimitRefillInterval && // row.original.ratelimitRefillRate ? ( //
// {row.original.ratelimitRefillRate} /{" "} // {ms(row.original.ratelimitRefillInterval)} //
// ) : ( // // ), // }, // { // id: "actions", // cell: ({ row }) => ( //
// // // // // // // { // e.preventDefault(); // }} // > // // Details // // // { // e.preventDefault(); // }} // > // // Revoke Key // // // // // Revoke Api Key // // Delete the key {row.original.start}...{" "} // permanenty // // // This action can not be undone. Your users will no longer be able to // authenticate using this key. // // // // // // // // // //
// ), // }, // ]; return ; };