import type { FilterDefinition } from '@/components/shared/filter-bar';
import { DEFAULT_RESIDENTIAL_PIPELINE_STAGES, PIPELINE_STAGES } from '@/lib/validators/residential';

/**
 * Filter definitions for the residential interests list - mirrors the
 * shape used by the main interests list (`interestFilterDefinitions`)
 * so the FilterBar + saved-views infra works identically. Residential
 * has its own pipeline (new / contacted / viewing_scheduled / …) and
 * narrower source enum.
 */

const RESIDENTIAL_STAGE_LABELS: Record<string, string> = {
  new: 'New',
  contacted: 'Contacted',
  viewing_scheduled: 'Viewing scheduled',
  offer_made: 'Offer made',
  offer_accepted: 'Offer accepted',
  closed_won: 'Closed - won',
  closed_lost: 'Closed - lost',
};

export const residentialInterestFilterDefinitions: FilterDefinition[] = [
  {
    key: 'search',
    label: 'Search',
    type: 'text',
    placeholder: 'Search notes or preferences…',
  },
  {
    key: 'pipelineStage',
    label: 'Stage',
    type: 'multi-select',
    options: PIPELINE_STAGES.map((s: string) => ({
      label: RESIDENTIAL_STAGE_LABELS[s] ?? s,
      value: s,
    })),
  },
  {
    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: 'includeArchived',
    label: 'Include Archived',
    type: 'boolean',
  },
];

export { RESIDENTIAL_STAGE_LABELS };
export { DEFAULT_RESIDENTIAL_PIPELINE_STAGES };
