65 lines
1.3 KiB
TypeScript
65 lines
1.3 KiB
TypeScript
'use client';
|
|
|
|
import type { ColumnDef } from '@tanstack/react-table';
|
|
import { Edit3, Trash2 } from 'lucide-react';
|
|
|
|
import { DataTable } from '@/components/data-table';
|
|
import type { Project } from '@/types';
|
|
|
|
interface ProjectTableProps {
|
|
columns: ColumnDef<Project>[];
|
|
projects: Project[];
|
|
isLoading: boolean;
|
|
skip: number;
|
|
limit: number;
|
|
total: number;
|
|
onPageChange: (skip: number) => void;
|
|
onLimitChange: (limit: number) => void;
|
|
onEdit: (project: Project) => void;
|
|
onDelete: (project: Project) => void;
|
|
}
|
|
|
|
export function ProjectTable({
|
|
columns,
|
|
projects,
|
|
isLoading,
|
|
skip,
|
|
limit,
|
|
total,
|
|
onPageChange,
|
|
onLimitChange,
|
|
onEdit,
|
|
onDelete,
|
|
}: ProjectTableProps) {
|
|
return (
|
|
<DataTable
|
|
title="Projects"
|
|
data={projects}
|
|
columns={columns}
|
|
actions={[
|
|
{
|
|
label: 'Edit',
|
|
icon: <Edit3 className="size-4" />,
|
|
onClick: onEdit,
|
|
},
|
|
{
|
|
label: 'Delete',
|
|
icon: <Trash2 className="size-4" />,
|
|
className: 'text-destructive',
|
|
onClick: onDelete,
|
|
},
|
|
]}
|
|
isLoading={isLoading}
|
|
emptyTitle="No projects found."
|
|
pagination={{
|
|
skip,
|
|
limit,
|
|
totalItems: total,
|
|
onPageChange,
|
|
onLimitChange,
|
|
}}
|
|
actionsSticky
|
|
/>
|
|
);
|
|
}
|