45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import { useQuizSettings } from "@contexts/QuizDataContext";
|
|
import { useQuizViewStore } from "@stores/quizView";
|
|
import { TextNormal } from "./TextNormal";
|
|
import { TextSpecial } from "./TextSpecial";
|
|
|
|
import type { QuizQuestionText } from "@model/questionTypes/text";
|
|
|
|
type TextProps = {
|
|
currentQuestion: QuizQuestionText;
|
|
stepNumber: number | null;
|
|
};
|
|
|
|
export const Text = ({ currentQuestion, stepNumber }: TextProps) => {
|
|
const { settings } = useQuizSettings();
|
|
const answers = useQuizViewStore((state) => state.answers);
|
|
const { answer } = answers.find(({ questionId }) => questionId === currentQuestion.id) ?? {};
|
|
|
|
switch (settings.cfg.spec) {
|
|
case true:
|
|
return (
|
|
<TextSpecial
|
|
currentQuestion={currentQuestion}
|
|
answer={answer}
|
|
stepNumber={stepNumber}
|
|
/>
|
|
);
|
|
|
|
case undefined:
|
|
return (
|
|
<TextNormal
|
|
currentQuestion={currentQuestion}
|
|
answer={answer}
|
|
/>
|
|
);
|
|
|
|
default:
|
|
return (
|
|
<TextNormal
|
|
currentQuestion={currentQuestion}
|
|
answer={answer}
|
|
/>
|
|
);
|
|
}
|
|
};
|