import { useMemo } from 'react';
import useContestCollectionMetadata from '../useContestCollectionMetadata';
function useContestCollectionHasIncumbent(id) {
  const metadata = useContestCollectionMetadata(id);
  return useMemo(() => {
    if (!metadata) return false;
    const contests = Object.values(metadata);
    return contests.some(contest => {
      const candidates = Object.values(contest.candidates);
      return candidates.some(candidate => candidate.isIncumbent);
    });
  }, [metadata]);
}
export default useContestCollectionHasIncumbent;