diff --git a/app/soapbox/components/poll.tsx b/app/soapbox/components/poll.tsx index 3f7139c30..0eae7c93e 100644 --- a/app/soapbox/components/poll.tsx +++ b/app/soapbox/components/poll.tsx @@ -40,32 +40,13 @@ const PollPercentageBar: React.FC = ({ percent, leading }): ); }; -interface IPollOption { - poll: PollEntity, - option: PollOptionEntity, - index: number, - showResults?: boolean, - disabled?: boolean, - active: boolean, - onToggle: (value: number) => void, +interface IPollOptionText extends IPollOption { + percent: number, } -const PollOption: React.FC = ({ - poll, - option, - index, - showResults, - disabled, - active, - onToggle, -}): JSX.Element | null => { +const PollOptionText: React.FC = ({ poll, option, index, active, disabled, percent, showResults, onToggle }) => { const intl = useIntl(); - - if (!poll) return null; - - const percent = poll.votes_count === 0 ? 0 : (option.votes_count / poll.votes_count) * 100; - const leading = poll.options.filterNot(other => other.title === option.title).every(other => option.votes_count >= other.votes_count); - const voted = poll.own_votes?.includes(index); + const voted = poll.own_votes?.includes(index); const handleOptionChange = (): void => { onToggle(index); @@ -79,43 +60,65 @@ const PollOption: React.FC = ({ } }; + return ( + + ); +}; + +interface IPollOption { + poll: PollEntity, + option: PollOptionEntity, + index: number, + showResults?: boolean, + disabled?: boolean, + active: boolean, + onToggle: (value: number) => void, +} + +const PollOption: React.FC = (props): JSX.Element | null => { + const { poll, option, showResults } = props; + if (!poll) return null; + + const percent = poll.votes_count === 0 ? 0 : (option.votes_count / poll.votes_count) * 100; + const leading = poll.options.filterNot(other => other.title === option.title).every(other => option.votes_count >= other.votes_count); + return (
  • {showResults && ( )} - +
  • ); };