import type { FilterConfig } from '@assets/filters/common/contexts/config';

type FlatConfigKeys = 'sections' | 'labels';

export const mergeFlatValuesConfig = <T extends FlatConfigKeys>(old: FilterConfig[T], updated: FilterConfig[T]) => {
   return old.map(
      (oldConfig) => {
         const newCount = updated
            ?.find(u => u.id === oldConfig.id)
            ?.count ?? 0;

         return { ...oldConfig, count: newCount };
      },
   );
};
