import { useMemo } from 'react';
import { useRecoilValue } from 'recoil';
import { voteHistory } from "../../../atoms/election/index.js";
import { getContestMargins } from '../../../utils/election';
const useVoteHistory = function useVoteHistory(office) {
  const votes = useRecoilValue(voteHistory);
  return useMemo(() => {
    if (!votes) return undefined;
    return votes.data.filter(d => d.office === office).map(d => getContestMargins('historical', d));
  }, [votes]);
};
export default useVoteHistory;