"use client";

import React, { memo } from "react";
import { DataTable } from "@/components/ui/data-table";
import { OrdersOverview } from "./columns"; // Importing the type from columns

interface OrdersTableProps {
  columns: any[];
  data: any[];
  onRowClick: (row: OrdersOverview) => void;
  emptyState?: React.ReactNode;
}

/**
 * ⚡ Optimization: Memoized OrdersTable
 * Prevents redundant re-renders of the table wrapper when parent state changes.
 * Coupled with referentially stable props from the parent, this ensures
 * high performance in the orders dashboard.
 */
export const OrdersTable = memo(({ columns, data, onRowClick, emptyState }: OrdersTableProps) => {
  return (
    <DataTable
      columns={columns}
      data={data}
      onRowClick={onRowClick}
      emptyState={emptyState}
    />
  );
});

OrdersTable.displayName = "OrdersTable";
