import { ExtractFilterValue, FiltersMap } from '@wix/bex-core';

export const transformCustomCheckboxToWQL = <F extends FiltersMap>(
  filterName: string,
  filterValue: { [P in keyof F]: ExtractFilterValue<F[P]> }[string],
) => {
  const filterValueBoolean = filterValue[0];
  if (!filterValueBoolean) {
    return [];
  }

  const condition = { [filterName]: { $eq: true } };

  return filterValueBoolean.value ? [condition] : [{ $not: condition }];
};
