"use client"; import { ColumnDef } from "@tanstack/react-table"; import { aime_user_game_locks } from "@/prisma/schemas/artemis/generated/artemis"; import { Button } from "@/components/ui/button"; import { Trash2, UnlockIcon } from "lucide-react"; import { deleteUserGameLocks } from "./action"; import { toast } from "@/components/ui/use-toast"; type chunithm = aime_user_game_locks & { userName: string | null }; const handleDelete = async (userId: number) => { try { const result = await deleteUserGameLocks(userId); if (result.success) { toast({ title: "User Unlocked", description: (
            
Successfully unlocked the user
), }); } else { toast({ title: "Failed to unlock user", description: (
            
User has already been unlocked
), }); } } catch (error) { console.error("Error deleting user game locks:", error); } }; export const columns: ColumnDef[] = [ { accessorKey: "Username", header: "Username", cell: ({ row }) => (
{row.original.userName || `User ID: ${row.original.user}`}{" "}
), }, { accessorKey: "ExpiresDate", header: "Expiration Date", cell: ({ row }) => { const expirationDate = row.original.expires_at; const currentDate = new Date(); if (!expirationDate) { return
N/A
; } const expirationDateTime = new Date(expirationDate).getTime(); const currentDateTime = currentDate.getTime(); const fifteenMinuteBuffer = 15 * 60 * 1000; if (expirationDateTime < currentDateTime - fifteenMinuteBuffer) { return
Expired
; } return
{new Date(expirationDate).toLocaleDateString()}
; }, }, { accessorKey: "deletelock", header: "Remove Lock", cell: ({ row }) => (
), }, ];