import {
  SingleSelectFilterProps,
  SingleSelectFilter,
} from '../components/SingleSelectFilter';
import React from 'react';
import { useStaticListFilterCollection } from '../hooks/useStaticListFilterCollection';

type SingleSelectStaticFilterCompatProps<V> = Omit<
  SingleSelectFilterProps<V, {}>,
  'collection' | 'data'
> & {
  data: V[];
};

export function SingleSelectStaticListFilter<V>(
  props: SingleSelectStaticFilterCompatProps<V>,
) {
  const { filter, data, ...rest } = props;
  const collection = useStaticListFilterCollection(filter, data);
  return (
    <SingleSelectFilter filter={filter} collection={collection} {...rest} />
  );
}
