"use client";

import { useMemo } from "react";
import { getSectorForIndustry } from "@/lib/config/industry-sector-map";
import { getSectorCustomFields } from "@/lib/config/sector-custom-fields";
import { getSectorTransactionConfig } from "@/lib/config/sector-transaction-config";
import type { SectorFieldDefinition } from "@/lib/config/sector-custom-fields";
import type { SectorTransactionConfig } from "@/lib/config/sector-transaction-config";

export interface UseSectorFieldsResult {
  sector: string;
  customFields: SectorFieldDefinition[];
  transactionConfig: SectorTransactionConfig;
}

export function useSectorFields(
  userIndustry?: string | null,
): UseSectorFieldsResult {
  return useMemo(() => {
    const sector = getSectorForIndustry(userIndustry);
    const customFields = getSectorCustomFields(sector);
    const transactionConfig = getSectorTransactionConfig(userIndustry);
    return { sector, customFields, transactionConfig };
  }, [userIndustry]);
}
