import { useQuizViewStore } from "@stores/quizView";
import { TextNormal } from "./TextNormal";
import { TextSpecial } from "./TextSpecial";
import { TextSpecialHorisontal } from "./TextSpecialHorisontal";

import type { QuizQuestionText } from "@model/questionTypes/text";
import { useQuizStore } from "@/stores/useQuizStore";

type TextProps = {
  currentQuestion: QuizQuestionText;
  stepNumber: number | null;
};

const pathOnly = window.location.pathname;

export const Text = ({ currentQuestion, stepNumber }: TextProps) => {
  const { settings } = useQuizStore();
  const answers = useQuizViewStore((state) => state.answers);
  const { answer } = answers.find(({ questionId }) => questionId === currentQuestion.id) ?? {};

  if (pathOnly === "/92ed5e3e-8e6a-491e-87d0-d3197682d0e3" || pathOnly === "/cc006b40-ccbd-4600-a1d3-f902f85aa0a0")
    return (
      <TextSpecialHorisontal
        currentQuestion={currentQuestion}
        answer={answer}
        stepNumber={stepNumber}
      />
    );
  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}
        />
      );
  }
};
