Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

PollAnswer.tsx 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { Theme } from '@mui/material';
  2. import React from 'react';
  3. import { makeStyles } from 'tss-react/mui';
  4. import Button from '../../../base/ui/components/web/Button';
  5. import Checkbox from '../../../base/ui/components/web/Checkbox';
  6. import { BUTTON_TYPES } from '../../../base/ui/constants';
  7. import { isSubmitAnswerDisabled } from '../../functions';
  8. import AbstractPollAnswer, { AbstractProps } from '../AbstractPollAnswer';
  9. const useStyles = makeStyles()((theme: Theme) => {
  10. return {
  11. buttonMargin: {
  12. marginRight: theme.spacing(2)
  13. }
  14. };
  15. });
  16. const PollAnswer = ({
  17. creatorName,
  18. checkBoxStates,
  19. poll,
  20. setCheckbox,
  21. skipAnswer,
  22. skipChangeVote,
  23. submitAnswer,
  24. t
  25. }: AbstractProps) => {
  26. const { changingVote } = poll;
  27. const { classes: styles } = useStyles();
  28. return (
  29. <div className = 'poll-answer'>
  30. <div className = 'poll-header'>
  31. <div className = 'poll-question'>
  32. <span>{ poll.question }</span>
  33. </div>
  34. <div className = 'poll-creator'>
  35. { t('polls.by', { name: creatorName }) }
  36. </div>
  37. </div>
  38. <ol className = 'poll-answer-list'>
  39. {
  40. poll.answers.map((answer: any, index: number) => (
  41. <li
  42. className = 'poll-answer-container'
  43. key = { index }>
  44. <Checkbox
  45. checked = { checkBoxStates[index] }
  46. key = { index }
  47. label = { answer.name }
  48. // eslint-disable-next-line react/jsx-no-bind
  49. onChange = { ev => setCheckbox(index, ev.target.checked) } />
  50. </li>
  51. ))
  52. }
  53. </ol>
  54. <div className = 'poll-footer poll-answer-footer' >
  55. <Button
  56. accessibilityLabel = { t('polls.answer.skip') }
  57. className = { styles.buttonMargin }
  58. fullWidth = { true }
  59. labelKey = { 'polls.answer.skip' }
  60. onClick = { changingVote ? skipChangeVote : skipAnswer }
  61. type = { BUTTON_TYPES.SECONDARY } />
  62. <Button
  63. accessibilityLabel = { t('polls.answer.submit') }
  64. disabled = { isSubmitAnswerDisabled(checkBoxStates) }
  65. fullWidth = { true }
  66. labelKey = { 'polls.answer.submit' }
  67. onClick = { submitAnswer } />
  68. </div>
  69. </div>
  70. );
  71. };
  72. /*
  73. * We apply AbstractPollAnswer to fill in the AbstractProps common
  74. * to both the web and native implementations.
  75. */
  76. // eslint-disable-next-line new-cap
  77. export default AbstractPollAnswer(PollAnswer);