'use client'

import { createContext, useContext } from 'react'
import { LEAD_KINDS, type LeadKind, type LeadKindConfig } from '@/lib/domain/broker-leads'

/**
 * Which kind of lead the manager is showing (2026-09-25). The tabs read the
 * page path, API base, labels and template keys from here, so the Carrier
 * Leads page is the Freight Broker Leads page pointed at kind = 'carrier'.
 */
const Ctx = createContext<LeadKindConfig>(LEAD_KINDS.broker)

export function LeadKindProvider({ kind, children }: { kind: LeadKind; children: React.ReactNode }) {
  return <Ctx.Provider value={LEAD_KINDS[kind]}>{children}</Ctx.Provider>
}

export function useLeadKind(): LeadKindConfig {
  return useContext(Ctx)
}
