import { EmptyPlaceholder } from "@/components/dashboard/empty-placeholder"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; // import { db } from "@/lib/db"; import { ChevronRight, Scan, User, VenetianMask } from "lucide-react"; import Link from "next/link"; type Props = { keyAuthId: string; }; export const Keys: React.FC = async ({ keyAuthId }) => { // const keys = await db.query.keys.findMany({ // where: (table, { and, eq, isNull }) => // and(eq(table.keyAuthId, keyAuthId), isNull(table.deletedAt)), // limit: 100, // with: { // roles: true, // permissions: true, // }, // }); const nullOwnerId = "UNKEY_NULL_OWNER_ID"; type KeysByOwnerId = { [ownerId: string]: { id: string; keyAuthId: string; name: string | null; start: string | null; roles: number; permissions: number; environment: string | null; }[]; }; // const keysByOwnerId = keys.reduce((acc, curr) => { // const ownerId = curr.ownerId ?? nullOwnerId; // if (!acc[ownerId]) { // acc[ownerId] = []; // } // acc[ownerId].push({ // id: curr.id, // keyAuthId: curr.keyAuthId, // name: curr.name, // start: curr.start, // roles: curr.roles.length, // permissions: curr.permissions.length, // environment: curr.environment, // }); // return acc; // }, {} as KeysByOwnerId); return (

Keys

{/* {Intl.NumberFormat().format(keys.length)} /{" "} {Intl.NumberFormat().format(Number.POSITIVE_INFINITY)} used{" "} */} {/* Create New Role} /> */}
{true ? ( No keys found Create your first key {/* Create New Role} /> */} ) : ( [ { ownerId: "" } ].map((ownerId) => (
{/* {ownerId === nullOwnerId ? (
Without OwnerID You can associate keys with the a userId or other identifier from your own system.
) : (
{ownerId}
)} */}
    {/* {ks.map((k) => (
    {k.name}
    {k.id}
    {k.environment ? env: {k.environment} : null}
    {Intl.NumberFormat(undefined, { notation: "compact" }).format(k.permissions)}{" "} Permission {k.permissions !== 1 ? "s" : ""} {Intl.NumberFormat(undefined, { notation: "compact" }).format(k.roles)} Role {k.roles !== 1 ? "s" : ""}
    ))} */}
)) )}
); };