import type { FilterDefinition } from '@/components/shared/filter-bar';
import { PIPELINE_STAGES, STAGE_LABELS, LEAD_CATEGORIES } from '@/lib/constants';

const CATEGORY_LABELS: Record<string, string> = {
  general_interest: 'General interest',
  specific_qualified: 'Specific qualified',
  hot_lead: 'Hot lead',
};

export const interestFilterDefinitions: FilterDefinition[] = [
  {
    key: 'search',
    label: 'Search',
    type: 'text',
    placeholder: 'Search interests...',
  },
  {
    key: 'pipelineStage',
    label: 'Stage',
    type: 'multi-select',
    options: PIPELINE_STAGES.map((s) => ({
      label: STAGE_LABELS[s],
      value: s,
    })),
  },
  {
    key: 'leadCategory',
    label: 'Category',
    type: 'select',
    options: LEAD_CATEGORIES.map((c) => ({
      label: CATEGORY_LABELS[c] ?? c,
      value: c,
    })),
  },
  {
    key: 'source',
    label: 'Source',
    type: 'select',
    options: [
      { label: 'Website', value: 'website' },
      { label: 'Manual', value: 'manual' },
      { label: 'Referral', value: 'referral' },
      { label: 'Broker', value: 'broker' },
      { label: 'Other', value: 'other' },
    ],
  },
  {
    key: 'eoiStatus',
    label: 'EOI Status',
    type: 'select',
    options: [
      { label: 'Waiting for Signatures', value: 'waiting_for_signatures' },
      { label: 'Signed', value: 'signed' },
      { label: 'Expired', value: 'expired' },
    ],
  },
  {
    key: 'includeArchived',
    label: 'Include Archived',
    type: 'boolean',
  },
  // Rendered OUTSIDE the FilterBar by `<TagPicker>` in interest-list, but
  // declared here so URL round-trip + saved-views capture the value.
  // `relation` skips the FilterBar's render switch.
  {
    key: 'tagIds',
    label: 'Tags',
    type: 'relation',
  },
];
