import { QuizQuestionText } from "@frontend/squzanswerer";
import HelpQuestions from "../helpQuestions";
import SettingTextField from "./settingTextField";
import UploadImage from "../UploadImage";

interface Props {
  switchState: string;
  question: QuizQuestionText;
}

export default function SwitchTextField({ switchState = "setting", question }: Props) {
  switch (switchState) {
    case "setting":
      return (
        <SettingTextField
          questionId={question.id}
          isRequired={question.content.required}
          isAutofill={question.content.autofill}
          answerType={question.content.answerType}
          detailedAnswer={Boolean(question.content?.detailedAnswer)}
          multi={Boolean(question.content?.multi)}
        />
      );
    case "image":
      return (
        <UploadImage
          question={question}
          cropAspectRatio={{ width: 400, height: 300 }}
        />
      );
    case "help":
      return (
        <HelpQuestions
          questionId={question.id}
          hintText={question.content.hint.text}
          hintVideo={question.content.hint.video}
        />
      );
    default:
      return <></>;
  }
}
