'use client';

import type { ReactNode } from 'react';
import type { ColumnDef } from '@tanstack/react-table';

import { DataTable, type DataTableAction } from '@/components/data-table';
import type { TicketExtensionRequest } from '@/types';

interface ExtensionRequestTableProps {
  columns: ColumnDef<TicketExtensionRequest>[];
  requests: TicketExtensionRequest[];
  isLoading: boolean;
  toolbar: ReactNode;
  skip: number;
  limit: number;
  total: number;
  onPageChange: (skip: number) => void;
  onLimitChange: (limit: number) => void;
  onView: (request: TicketExtensionRequest) => void;
  actions: DataTableAction<TicketExtensionRequest>[];
}

export function ExtensionRequestTable({
  columns,
  requests,
  isLoading,
  toolbar,
  skip,
  limit,
  total,
  onPageChange,
  onLimitChange,
  onView,
  actions,
}: ExtensionRequestTableProps) {
  return (
    <DataTable
      title="Extension Requests"
      columns={columns}
      data={requests}
      isLoading={isLoading}
      toolbar={toolbar}
      emptyTitle="No extension requests found."
      emptyDescription="Try changing the ticket or status filters."
      onRowClick={onView}
      actions={actions}
      actionsSticky
      minColumnSize={130}
      pagination={{
        skip,
        limit,
        totalItems: total,
        onPageChange,
        onLimitChange,
      }}
    />
  );
}
