frontPanel/src/ui_kit/switchStepPages.tsx

64 lines
1.8 KiB
TypeScript
Executable File

import {
QuizResultsType,
QuizStartpageType,
QuizType,
} from "@model/quizSettings";
import ContactFormPage from "../pages/ContactFormPage/ContactFormPage";
import InstallQuiz from "../pages/InstallQuiz/InstallQuiz";
import FormQuestionsPage from "../pages/Questions/Form/FormQuestionsPage";
import QuestionsPage from "../pages/Questions/QuestionsPage";
import { QuestionsMap } from "../pages/QuestionsMap";
import { ResultPage } from "../pages/ResultPage/ResultPage";
import { ResultSettings } from "../pages/ResultPage/ResultSettings";
import StartPageSettings from "../pages/startPage/StartPageSettings";
import StepOne from "../pages/startPage/stepOne";
import Steptwo from "../pages/startPage/steptwo";
interface Props {
activeStep: number;
quizType: QuizType;
quizStartPageType: QuizStartpageType;
quizResults: QuizResultsType;
openBranchingPage: boolean;
setOpenBranchingPage: (a: boolean) => void;
widthMain: number;
}
export default function SwitchStepPages({
activeStep = 1,
quizType,
quizStartPageType,
quizResults,
openBranchingPage,
setOpenBranchingPage,
widthMain,
}: Props) {
switch (activeStep) {
case 0: {
if (!quizType) return <StepOne />;
if (!quizStartPageType) return <Steptwo />;
return <StartPageSettings />;
}
case 1:
return quizType === "form" ? (
<FormQuestionsPage />
) : (
<QuestionsPage
openBranchingPage={openBranchingPage}
setOpenBranchingPage={setOpenBranchingPage}
widthMain={widthMain}
/>
);
case 2:
return <ResultPage />;
case 3:
return <ContactFormPage />;
case 4:
return <InstallQuiz />;
// case 5: return <InstallQuiz />;
// case 6: return <>Реклама</>;
default:
throw new Error(`Invalid quiz setup step: ${activeStep}`);
}
}