export type CatalogFieldType = 'text' | 'number' | 'textarea' | 'select' | 'date';
export type CatalogHttpMethod = 'PUT' | 'PATCH';

export interface CatalogOption {
  label: string;
  value: number | string | boolean | null;
}

export interface CatalogColumnConfig {
  key: string;
  label: string;
}

export interface CatalogFieldConfig {
  key: string;
  label: string;
  type: CatalogFieldType;
  required?: boolean;
  min?: number;
  placeholder?: string;
  options?: CatalogOption[];
  lookupKey?: string;
}

export interface CatalogLookupConfig {
  key: string;
  endpoint: string;
  labelKey?: string;
  valueKey?: string;
}

export type CatalogLookupData = Record<string, Record<string, unknown>[]>;

export interface CatalogCrudConfig<T = any> {
  key: string;
  title: string;
  singular: string;
  description: string;
  endpoint: string;
  createButtonLabel: string;
  emptyMessage: string;
  searchPlaceholder: string;
  searchKeys: string[];
  updateMethod?: CatalogHttpMethod;
  columns: CatalogColumnConfig[];
  fields: CatalogFieldConfig[];
  lookups?: CatalogLookupConfig[];
  toPayload: (rawValue: Record<string, unknown>) => Record<string, unknown>;
  toFormValue?: (entity: T) => Record<string, unknown>;
  toTableRow: (entity: T, lookupData: CatalogLookupData) => Record<string, unknown>;
}
