"use client";
import { Prisma, User } from "@repo/db";
import { ColumnDef } from "@tanstack/react-table";
import { PaginatedTable } from "_components/PaginatedTable";

export default function () {
	return (
		<PaginatedTable
			strictQuery
			showSearch
			prismaModel={"user"}
			getFilter={(searchTerm) =>
				({
					AND: [
						{
							vatsimCid: {
								not: "",
							},
							OR: [
								{ firstname: { contains: searchTerm, mode: "insensitive" } },
								{ lastname: { contains: searchTerm, mode: "insensitive" } },
								{ vatsimCid: { contains: searchTerm, mode: "insensitive" } },
							],
						},
					],
				}) as Prisma.UserWhereInput
			}
			leftOfSearch={<h1 className="text-2xl font-bold">Vatsim-Nutzer</h1>}
			columns={
				[
					{ header: "Vorname", accessorKey: "firstname" },
					{
						header: "Nachname",
						accessorKey: "lastname",
						cell: ({ row }) => row.original.lastname[0],
					},
					{ header: "Vatsim CID", accessorKey: "vatsimCid" },
				] as ColumnDef<User>[]
			}
		/>
	);
}
