import DateOptions from "./QuestionOptions/DateOptions/DateOptions";
import DropDown from "./DropDown/DropDown";
import Emoji from "./Emoji/Emoji";
import OptionsAndPicture from "./QuestionOptions/OptionsAndPicture/OptionsAndPicture";
import OptionsPicture from "./QuestionOptions/OptionsPicture/OptionsPicture";
import OwnTextField from "./OwnTextField/OwnTextField";
import PageOptions from "./QuestionOptions/PageOptions/PageOptions";
import RatingOptions from "./QuestionOptions/RatingOptions/RatingOptions";
import SliderOptions from "./QuestionOptions/SliderOptions/SliderOptions";
import UploadFile from "./UploadFile/UploadFile";
import AnswerOptions from "./QuestionOptions/answerOptions/AnswerOptions";
import { notReachable } from "../../utils/notReachable";
import { AnyTypedQuizQuestion } from "@frontend/squzanswerer";

interface Props {
  question: AnyTypedQuizQuestion;
  openBranchingPage: boolean;
  setOpenBranchingPage: (a: boolean) => void;
}

export default function SwitchQuestionsPage({ question, openBranchingPage, setOpenBranchingPage }: Props) {
  switch (question.type) {
    case "variant":
      return (
        <AnswerOptions
          question={question}
          openBranchingPage={openBranchingPage}
          setOpenBranchingPage={setOpenBranchingPage}
        />
      );

    case "images":
      return (
        <OptionsPicture
          question={question}
          openBranchingPage={openBranchingPage}
          setOpenBranchingPage={setOpenBranchingPage}
        />
      );

    case "varimg":
      return (
        <OptionsAndPicture
          question={question}
          openBranchingPage={openBranchingPage}
          setOpenBranchingPage={setOpenBranchingPage}
        />
      );

    case "emoji":
      return (
        <Emoji
          question={question}
          openBranchingPage={openBranchingPage}
          setOpenBranchingPage={setOpenBranchingPage}
        />
      );

    case "text":
      return (
        <OwnTextField
          question={question}
          openBranchingPage={openBranchingPage}
          setOpenBranchingPage={setOpenBranchingPage}
        />
      );

    case "select":
      return (
        <DropDown
          question={question}
          openBranchingPage={openBranchingPage}
          setOpenBranchingPage={setOpenBranchingPage}
        />
      );

    case "date":
      return (
        <DateOptions
          question={question}
          openBranchingPage={openBranchingPage}
          setOpenBranchingPage={setOpenBranchingPage}
        />
      );

    case "number":
      return (
        <SliderOptions
          question={question}
          openBranchingPage={openBranchingPage}
          setOpenBranchingPage={setOpenBranchingPage}
        />
      );

    case "file":
      return (
        <UploadFile
          question={question}
          openBranchingPage={openBranchingPage}
          setOpenBranchingPage={setOpenBranchingPage}
        />
      );

    case "page":
      return (
        <PageOptions
          question={question}
          openBranchingPage={openBranchingPage}
          setOpenBranchingPage={setOpenBranchingPage}
        />
      );

    case "rating":
      return (
        <RatingOptions
          question={question}
          openBranchingPage={openBranchingPage}
          setOpenBranchingPage={setOpenBranchingPage}
        />
      );

    case "result":
      return null;

    default:
      notReachable(question);
  }
}
