// @flow import React from 'react'; import AbstractPollResults from '../AbstractPollResults'; import type { AbstractProps } from '../AbstractPollResults'; /** * Component that renders the poll results. * * @param {Props} props - The passed props. * @returns {React.Node} */ const PollResults = (props: AbstractProps) => { const { answers, changeVote, creatorName, haveVoted, showDetails, question, t, toggleIsDetailed } = props; return (
{ question }
{ t('polls.by', { name: creatorName }) }
    {answers.map(({ name, percentage, voters, voterCount }, index) => (
  1. {name}
    ({voterCount}) {percentage}%
    { showDetails && voters && voterCount > 0 &&
      {voters.map(voter =>
    • {voter.name}
    • )}
    }
  2. ) )}
{showDetails ? t('polls.results.hideDetailedResults') : t('polls.results.showDetailedResults')} {haveVoted ? t('polls.results.changeVote') : t('polls.results.vote')}
); }; /* * We apply AbstractPollResults to fill in the AbstractProps common * to both the web and native implementations. */ // eslint-disable-next-line new-cap export default AbstractPollResults(PollResults);