import { TableCell, TableRow } from "@/components/ui/table";
import { ReactNode } from "react";

interface EmptyListWrapperProps<T> {
  list: T[];
  emptyMessage: string;
  columns: string[];
  children: ReactNode;
}

function EmptyListWrapper<T>({
  list,
  emptyMessage,
  columns,
  children,
}: EmptyListWrapperProps<T>) {
  if (!list.length) {
    return (
      <TableRow>
        <TableCell className="text-center" colSpan={columns.length * 100}>
          <h2>{emptyMessage}</h2>
        </TableCell>
      </TableRow>
    );
  }

  return <>{children}</>;
}

export default EmptyListWrapper;
