import type { ReactNode } from "react";

export interface DataTableColumn<TRow> {
  /** Unique column id — used as the sort key and React key */
  key: string;
  /** Already-translated header label — pass `t("...")` */
  header: ReactNode;
  /** Cell renderer for this column */
  cell: (row: TRow, index: number) => ReactNode;
  /** Enable sorting on this column */
  sortable?: boolean;
  /**
   * Client-mode sort value. Falls back to reading `row[key]` when omitted —
   * provide it whenever the column key isn't a plain row property.
   * Ignored in server mode (the backend sorts).
   */
  sortValue?: (row: TRow) => string | number | Date | null | undefined;
  /** Cell alignment — logical, flips automatically in RTL */
  align?: "start" | "center" | "end";
  /** Extra classes for the header + body cells (e.g. a width) */
  className?: string;
  /** Exclude this column from the mobile card view */
  hideOnMobile?: boolean;
  /** Label used in the mobile card row — defaults to `header` */
  mobileLabel?: ReactNode;
}

export interface DataTableSort {
  key: string;
  direction: "asc" | "desc";
}

/** The full list-query state — what a server-mode parent sends to its API */
export interface DataTableQuery {
  /** 1-based page index */
  page: number;
  pageSize: number;
  search: string;
  sort: DataTableSort | null;
}

export interface DataTableRowAction<TRow> {
  key: string;
  /** Already-translated label */
  label: ReactNode;
  icon?: ReactNode;
  destructive?: boolean;
  disabled?: boolean;
  onSelect: (row: TRow) => void;
}
