"use client" import { z } from "zod" import { Button } from "@/components/ui/button" import { Drawer, DrawerClose, DrawerContent, DrawerFooter, DrawerHeader, DrawerTrigger } from "@/components/ui/drawer" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { useSortable } from "@dnd-kit/sortable" import { IconGripVertical } from "@tabler/icons-react" import { useIsMobile } from "@/hooks/use-mobile" import { Separator } from "@/components/ui/separator" import { ColumnDef, flexRender, Row } from "@tanstack/react-table" import { TableCell, TableRow } from "@/components/ui/table" import { CSS } from "@dnd-kit/utilities" import { schema, schemaType } from "./schema" import { dateToLocaleString } from "@/lib/utils" import { Pencil, Trash } from "lucide-react" function TableCellViewer({ item }: { item: schemaType }) { const isMobile = useIsMobile(); return (

{item.email}

User details

{/* BASIC INFO */}
{/* DATES */}
{/* TOKENS */} Tokens {(item.collectionTokens?.tokens ?? []).length === 0 && (No tokens found)} {(item.collectionTokens?.tokens ?? []).map((t, i) => (
))}
); } function DragHandle({ id }: { id: number }) { const { attributes, listeners } = useSortable({ id }) return ( ) } export function DraggableRow({ row }: { row: Row> }) { const { transform, transition, setNodeRef, isDragging } = useSortable({ id: row.original._id }) return ( {row.getVisibleCells().map((cell) => ( {flexRender(cell.column.columnDef.cell, cell.getContext())} ))} ) } function getColumns(router: any, deleteHandler: (id: string) => void): ColumnDef[] { return [ { accessorKey: "uuid", header: "UUID", cell: ({ getValue }) => (
{String(getValue())}
), }, { accessorKey: "firstName", header: "First Name", }, { accessorKey: "surname", header: "Surname", }, { accessorKey: "middleName", header: "Middle Name", }, { accessorKey: "sexCode", header: "Sex", }, { accessorKey: "personRef", header: "Person Ref", }, { accessorKey: "personTag", header: "Person Tag", }, { accessorKey: "fatherName", header: "Father Name", }, { accessorKey: "motherName", header: "Mother Name", }, { accessorKey: "countryCode", header: "Country", }, { accessorKey: "nationalIdentityId", header: "National ID", }, { accessorKey: "birthPlace", header: "Birth Place", }, { accessorKey: "active", header: "Active", cell: ({ getValue }) => getValue() ? (
Yes
) : (
No
), }, { accessorKey: "isConfirmed", header: "Confirmed", cell: ({ getValue }) => getValue() ? (
Yes
) : (
No
), }, { accessorKey: "birthDate", header: "Birth Date", cell: ({ getValue }) => dateToLocaleString(getValue() as string), }, { accessorKey: "createdAt", header: "Created", cell: ({ getValue }) => dateToLocaleString(getValue() as string), }, { accessorKey: "updatedAt", header: "Updated", cell: ({ getValue }) => dateToLocaleString(getValue() as string), }, { accessorKey: "expiryStarts", header: "Expiry Starts", cell: ({ getValue }) => getValue() ? dateToLocaleString(getValue() as string) : "-", }, { accessorKey: "expiryEnds", header: "Expiry Ends", cell: ({ getValue }) => getValue() ? dateToLocaleString(getValue() as string) : "-", }, { id: "actions", header: "Actions", cell: ({ row }) => { return (
); }, } ] } export { getColumns };