import { useMemo } from 'react' import { unitMatchService } from '../services/unitMatchService' import type { Property, PropertyUnit } from '../domain/property' /** * Synchronous wrappers — unitMatchService methods are pure synchronous computations. * useMemo ensures we don't recompute on every render unnecessarily. */ export function useUnitMatchesMap(freeUnits: PropertyUnit[], property: Property) { return useMemo( () => Object.fromEntries( freeUnits.map(u => [u.id, unitMatchService.getMatchesForUnit(u, property)]), ), [freeUnits, property], ) } export function useUnitBundle(selectedUnits: PropertyUnit[]) { return useMemo( () => (selectedUnits.length >= 2 ? unitMatchService.buildBundle(selectedUnits) : null), [selectedUnits], ) } export function useBundleMatches(selectedUnits: PropertyUnit[], property: Property) { return useMemo( () => selectedUnits.length >= 2 ? unitMatchService.getMatchesForBundle(selectedUnits, property) : [], [selectedUnits, property], ) }