import { AnyTypedQuizQuestion } from "@model/questionTypes/shared";
import DataOptions from "./DataOptions/DataOptions";
import DropDown from "./DropDown/DropDown";
import Emoji from "./Emoji/Emoji";
import OptionsAndPicture from "./OptionsAndPicture/OptionsAndPicture";
import OptionsPicture from "./OptionsPicture/OptionsPicture";
import OwnTextField from "./OwnTextField/OwnTextField";
import PageOptions from "./PageOptions/PageOptions";
import RatingOptions from "./RatingOptions/RatingOptions";
import SliderOptions from "./SliderOptions/SliderOptions";
import UploadFile from "./UploadFile/UploadFile";
import AnswerOptions from "./answerOptions/AnswerOptions";
import { notReachable } from "../../utils/notReachable";

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 (
        <DataOptions
          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);
  }
}
