import React, { useMemo } from 'react';
import { HMSPollQuestion } from '@100mslive/react-sdk';
import { CheckCircleIcon } from '@100mslive/react-icons';
import { Button, Flex, Text } from '../../../../';
import { QUESTION_TYPE_TITLE } from '../../../common/constants';
export const SavedQuestion = ({
question,
index,
length,
convertToDraft,
}: {
question: HMSPollQuestion & { draftID: number };
index: number;
length: number;
convertToDraft: (draftID: number) => void;
}) => {
const answerArray = useMemo(() => {
const updatedAnswerArray = [];
const { option, options } = question?.answer ?? {};
if (option) {
updatedAnswerArray.push(option);
}
if (options) {
updatedAnswerArray.push(...options);
}
return updatedAnswerArray;
}, [question?.answer]);
return (
<>
{/* @ts-ignore */}
Question {index + 1} of {length}: {QUESTION_TYPE_TITLE[question.type]}
{question.text}
{question.options?.map((option, index) => (
{option.text}
{/* @ts-ignore */}
{(answerArray.includes(index + 1) || option.isCorrectAnswer) && (
)}
))}
{question.skippable ? (
Not required to answer
) : null}
>
);
};