'use client';

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

import { DataTable } from '@/components/data-table';
import type { Tenant } from '@/types';

interface TenantTableProps {
  columns: ColumnDef<Tenant>[];
  tenants: Tenant[];
  isLoading: boolean;
  toolbar: ReactNode;
  skip: number;
  limit: number;
  total: number;
  sorting: SortingState;
  onPageChange: (skip: number) => void;
  onLimitChange: (limit: number) => void;
  onSortingChange: (sorting: SortingState) => void;
}

export function TenantTable({
  columns,
  tenants,
  isLoading,
  toolbar,
  skip,
  limit,
  total,
  sorting,
  onPageChange,
  onLimitChange,
  onSortingChange,
}: TenantTableProps) {
  return (
    <DataTable
      title="Tenants"
      columns={columns}
      data={tenants}
      isLoading={isLoading}
      toolbar={toolbar}
      emptyTitle="No tenants found."
      pagination={{
        skip,
        limit,
        totalItems: total,
        onPageChange,
        onLimitChange,
      }}
      sorting={sorting}
      onSortingChange={onSortingChange}
    />
  );
}
