import { useState, useEffect } from 'react';
import { fetchVotes } from '../services/voteService';

export const useVotes = () => {
  const [votes, setVotes] = useState([]);

  useEffect(() => {
    fetchVotes().then((snapshot) => {
      if (snapshot.exists()) {
        setVotes(snapshot.val());
      }
    });
  }, []);

  return votes;
};
