import type { FloatParameter as FloatParameterConfig } from '@assets/filters/common/state-parsers/filterValuesCache';
import * as GTM from '@assets/filters/common/utils/gtm';

export function trackFloatParameterChange(
   parameterId: number,
   parameter: FloatParameterConfig,
   selectedRange: { from: number, to: number } | undefined,
) {
   const parameterValue = {
      min: selectedRange?.from ?? parameter.values.min ?? 0,
      max: selectedRange?.to ?? parameter.values.max ?? 0,
   };

   GTM.dataCollector.applyFilterParams(
      { ...parameter, id: parameterId },
      parameterValue,
      !!selectedRange,
   );
}
