import { useFetcher } from "@remix-run/react"; import { type ColumnDef } from "@tanstack/react-table"; import { format } from "date-fns"; import { Button } from "../ui"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "~/components/ui/dialog"; import React from "react"; export interface PersonalAccessToken { name: string; id: string; obfuscatedToken: string; lastAccessedAt: Date | null; createdAt: Date; } export const useTokensColumns = (): Array> => { const fetcher = useFetcher(); const [open, setOpen] = React.useState(false); const onDelete = (id: string) => { fetcher.submit({ id }, { method: "DELETE", action: "/home/api" }); }; return [ { accessorKey: "name", header: () => { return Name; }, cell: ({ row }) => { return (
{row.original.name}
); }, }, { accessorKey: "obfuscatedToken", header: () => { return Token; }, cell: ({ row }) => { return (
{row.original.obfuscatedToken}
); }, }, { accessorKey: "lastAccessedAt", header: () => { return Last accessed; }, cell: ({ row }) => { return (
{row.original.lastAccessedAt ? format(row.original.lastAccessedAt, "MMM d, yyyy") : "Never"}
); }, }, { accessorKey: "actions", header: () => { return Actions; }, cell: ({ row }) => { return ( Are you sure? This action cannot be undone. This will permanently delete your API token. ); }, }, ]; };