'use client' import { useMemo } from 'react' import { useReactTable, getCoreRowModel, getPaginationRowModel, flexRender, } from '@tanstack/react-table' import { Level } from '@/types' import { createColumns } from './level-columns' import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table' import { Button } from '@/components/ui/button' import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight, } from 'lucide-react' interface LevelTableProps { levels: Level[] onEdit: (level: Level) => void onDelete: (id: string) => void deleteConfirmId: string | null } export function LevelTable({ levels, onEdit, onDelete, deleteConfirmId, }: LevelTableProps) { const columns = useMemo( () => createColumns({ onEdit, onDelete, deleteConfirmId }), [onEdit, onDelete, deleteConfirmId] ) const table = useReactTable({ data: levels, columns, getCoreRowModel: getCoreRowModel(), getPaginationRowModel: getPaginationRowModel(), initialState: { pagination: { pageSize: 10, }, }, }) if (levels.length === 0) { return (
暂无关卡数据
点击上方“添加关卡”按钮创建第一个关卡