import { TableColumn as TableColumnWSR } from '@wix/design-system/dist/types/Table';
import { ActionCell } from '../ActionCell';
import { FiltersMap } from '@wix/bex-core';
import { KanbanState } from '../../state/KanbanState';
import React, { ReactElement, ReactNode } from 'react';
import { ToolbarBaseProps } from '../ToolbarCollection';
import { CollectionToolbarFiltersElement } from '../assertComponentType';
import { DragAndDropCategoriesProps } from '../DragAndDrop/DragAndDropCategoriesProps';
import type { DataExtensionElement, DataExtensionType } from '../DataExtension';
import type { TagsElement } from '../Tags';

interface KanbanItemField<T> {
  key: string;
  title: string;
  render: TableColumnWSR<T>['render'];
}

export interface KanbanBaseProps<T, S, F extends FiltersMap>
  extends ToolbarBaseProps,
    DragAndDropCategoriesProps<{}> {
  dataHook?: string;
  state: KanbanState<T, S, F>;
  filters?: CollectionToolbarFiltersElement;
  errorState?: (
    err: unknown,
    params: {
      isOnline: boolean;
      retry: () => void;
    },
  ) => ReactElement;
  emptyState?: ReactNode;
  noResultsState?: ReactNode;
  stageSummary?: ({ stage }: { stage: S }) => React.ReactNode;
  renderItem?: ({ stage, item }: { stage: S; item: T }) => {
    title: string | ReactNode;
    subtitle?: ReactNode;
    additionalInfo?: ReactNode;
    additionalFields?: ReactNode | KanbanItemField<T>[];
    badge?: ReactNode;
  };
  actionCell?: ActionCell<T, F>;
  dataExtension?: DataExtensionType | DataExtensionElement;
  tags?: TagsElement<T, F>;
  entityPageId?: string;
}
