UNPKG

@100mslive/react-native-room-kit

Version:

100ms Room Kit provides simple & easy to use UI components to build Live Streaming & Video Conferencing experiences in your apps.

44 lines (42 loc) 1.65 kB
import * as React from 'react'; import { View } from 'react-native'; import { HMSPollType } from '@100mslive/react-native-hms'; import { PollAndQuizQuestionResponseCard } from './PollAndQuizQuestionResponseCard'; export const PollAndQuizQuestionResponseCards = ({ poll, onVote }) => { if (!Array.isArray(poll.questions) || poll.questions.length <= 0) { return null; } const pollQuestions = poll.questions.sort((a, b) => a.index - b.index); // Show all question cards if the pollType is a `poll` OR if all questions have been answered if (poll.type === HMSPollType.poll || pollQuestions.every(q => q.myResponses.length > 0)) { return /*#__PURE__*/React.createElement(View, null, pollQuestions.map((question, _, arr) => /*#__PURE__*/React.createElement(PollAndQuizQuestionResponseCard, { key: question.index, pollState: poll.state, pollId: poll.pollId, totalQuestions: arr.length, pollQuestion: question, containerStyle: { marginBottom: 16 }, onSubmit: onVote }))); } const unansweredQuestion = pollQuestions.find(q => !q.myResponses || q.myResponses.length <= 0); // Show question cards one at a time if the pollType is a `quiz` and not all questions have been answered if (unansweredQuestion) { return /*#__PURE__*/React.createElement(PollAndQuizQuestionResponseCard, { pollState: poll.state, pollId: poll.pollId, totalQuestions: pollQuestions.length, pollQuestion: unansweredQuestion, containerStyle: { marginBottom: 16 } }); } return null; }; //# sourceMappingURL=PollAndQuizQuestionResponseCards.js.map