frontPanel/src/pages/Questions/SwitchQuestionsPage.tsx

73 lines
2.2 KiB
TypeScript
Raw Normal View History

import * as React from 'react';
import AnswerOptions from "./answerOptions/AnswerOptions";
import OptionsPicture from "./OptionsPicture/OptionsPicture";
import DataOptions from "./DataOptions/DataOptions";
import SliderOptions from "./SliderOptions/SliderOptions";
import OwnTextField from "./OwnTextField/OwnTextField";
import PageOptions from "./PageOptions/PageOptions";
import OptionsAndPicture from "./OptionsAndPicture/OptionsAndPicture";
import RatingOptions from "./RatingOptions/RatingOptions";
import Emoji from "./Emoji/Emoji";
import DropDown from "./DropDown/DropDown";
import UploadFile from "./UploadFile/UploadFile";
import {useParams} from "react-router-dom";
import {questionStore} from "@root/questions";
interface Props {
totalIndex: number,
}
export default function SwitchQuestionsPage ({totalIndex }: Props) {
const params = Number(useParams().quizId);
const {listQuestions, updateQuestionsList, createQuestion, removeQuestion} = questionStore()
const switchState = listQuestions[params][totalIndex].type
switch (switchState) {
case 'answer':
return (<AnswerOptions totalIndex={totalIndex}/>);
break;
case 'answerpict':
return (<OptionsPicture totalIndex={totalIndex}/>);
break;
case 'answerandpict':
return (<OptionsAndPicture totalIndex={totalIndex}/>);
break;
case 'emoji':
return (<Emoji totalIndex={totalIndex}/>);
break;
case 'textfield':
return (<OwnTextField totalIndex={totalIndex}/>);
break;
case 'dropdown':
return (<DropDown totalIndex={totalIndex}/>);
break;
case 'date':
return (<DataOptions totalIndex={totalIndex}/>);
break;
case 'slider':
return (<SliderOptions totalIndex={totalIndex}/>);
break;
case 'uploader':
return (<UploadFile totalIndex={totalIndex}/>);
break;
case 'page':
return (<PageOptions totalIndex={totalIndex}/>);
break;
case 'rating':
return (<RatingOptions totalIndex={totalIndex}/>);
break;
default:
return (<></>)
}
}