import * as GTM from '@assets/filters/common/utils/gtm';
import type { FiltersState } from '@assets/filters/state';
import type { OptRange } from '@assets/filters/common/components/RangeFilter';

export function trackPriceRangeChange(
   config: FiltersState['config']['priceRange'],
   newRange: OptRange,
) {
   const activeRange = newRange ?? {
      from: config.from,
      to: config.to,
   };

   GTM.dataCollector.applyFilterPrice(
      activeRange,
      config,
      typeof newRange !== 'undefined',
   );
}
