You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PollItem.tsx 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import React from 'react';
  2. import { View, ViewStyle } from 'react-native';
  3. import { useSelector } from 'react-redux';
  4. import { shouldShowResults } from '../../functions';
  5. import PollAnswer from './PollAnswer';
  6. import PollResults from './PollResults';
  7. import { pollsStyles } from './styles';
  8. interface IProps {
  9. /**
  10. * Id of the poll.
  11. */
  12. pollId: string;
  13. /**
  14. * Create mode control.
  15. */
  16. setCreateMode: (mode: boolean) => void;
  17. }
  18. const PollItem = ({ pollId, setCreateMode }: IProps) => {
  19. const showResults = useSelector(shouldShowResults(pollId));
  20. return (
  21. <View
  22. id = 'poll-item-container'
  23. style = { pollsStyles.pollItemContainer as ViewStyle }>
  24. { showResults
  25. ? <PollResults
  26. key = { pollId }
  27. pollId = { pollId } />
  28. : <PollAnswer
  29. pollId = { pollId }
  30. setCreateMode = { setCreateMode } />
  31. }
  32. </View>
  33. );
  34. };
  35. export default PollItem;