import React from 'react';
import styles from './Results.module.css';

const Results = ({ votes }) => {
    const voteCounts = Object.values(votes).reduce((acc, vote) => {
        acc[vote] = (acc[vote] || 0) + 1;
        return acc;
    }, {});

    return (
        <div className={styles.results}>
            <h2>Voting Results</h2>
            <ul>
                {Object.keys(voteCounts).map((vote, index) => (
                    <li key={index}>
                        {vote}: {voteCounts[vote]} vote(s)
                    </li>
                ))}
            </ul>
        </div>
    );
};

export default Results;
