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.

PollAnswer.js 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // @flow
  2. import { Checkbox } from '@atlaskit/checkbox';
  3. import React from 'react';
  4. import { isSubmitAnswerDisabled } from '../../functions';
  5. import AbstractPollAnswer from '../AbstractPollAnswer';
  6. import type { AbstractProps } from '../AbstractPollAnswer';
  7. const PollAnswer = (props: AbstractProps) => {
  8. const {
  9. checkBoxStates,
  10. poll,
  11. setCheckbox,
  12. skipAnswer,
  13. skipChangeVote,
  14. submitAnswer,
  15. t
  16. } = props;
  17. const { changingVote } = poll;
  18. return (
  19. <div className = 'poll-answer'>
  20. <div className = 'poll-header'>
  21. <div className = 'poll-question'>
  22. <span>{ poll.question }</span>
  23. </div>
  24. </div>
  25. <ol className = 'poll-answer-list'>
  26. {
  27. poll.answers.map((answer, index) => (
  28. <li
  29. className = 'poll-answer-container'
  30. key = { index }>
  31. <Checkbox
  32. isChecked = { checkBoxStates[index] }
  33. key = { index }
  34. label = { <span className = 'poll-answer-option'>{ answer.name }</span> }
  35. // eslint-disable-next-line react/jsx-no-bind
  36. onChange = { ev => setCheckbox(index, ev.target.checked) }
  37. size = 'large' />
  38. </li>
  39. ))
  40. }
  41. </ol>
  42. <div className = 'poll-footer poll-answer-footer' >
  43. <button
  44. aria-label = { t('polls.answer.skip') }
  45. className = 'poll-button poll-button-secondary poll-button-shortest'
  46. onClick = { changingVote ? skipChangeVote : skipAnswer } >
  47. <span>{t('polls.answer.skip')}</span>
  48. </button>
  49. <button
  50. aria-label = { t('polls.answer.submit') }
  51. className = 'poll-button poll-button-primary poll-button-shortest'
  52. disabled = { isSubmitAnswerDisabled(checkBoxStates) }
  53. onClick = { submitAnswer }>
  54. <span>{t('polls.answer.submit')}</span>
  55. </button>
  56. </div>
  57. </div>
  58. );
  59. };
  60. /*
  61. * We apply AbstractPollAnswer to fill in the AbstractProps common
  62. * to both the web and native implementations.
  63. */
  64. // eslint-disable-next-line new-cap
  65. export default AbstractPollAnswer(PollAnswer);