AQuestion.tsx 1.65 KB
Newer Older
1
2
3
import React, { useState } from "react";
import { useNavigate } from "react-router-dom";
import { BasicQuestionType, SurveyType } from "../types";
Lee SeoYeon's avatar
Lee SeoYeon committed
4
5
6
import { ACheckboxForm } from "./ACheckboxForm";
import { ADateForm } from "./ADateForm";
import { ADropdownForm } from "./ADropdownForm";
7
import { AEssayForm } from "./AEssayForm";
Lee SeoYeon's avatar
Lee SeoYeon committed
8
9
import { AFileForm } from "./AFileForm";
// import { AMatrixForm } from "./AMatrixForm";
10
import { ARadioForm } from "./ARadioForm";
Lee SeoYeon's avatar
Lee SeoYeon committed
11
import { ARatingForm } from "./ARatingForm";
12
13
14
15

type PropsType = {
  question: BasicQuestionType;
};
Lee SeoYeon's avatar
Lee SeoYeon committed
16

17
18
19
20
21
22
23
24
25
26
27
export const AQuestion = ({ question }: PropsType) => {
  function getContent(question: BasicQuestionType) {
    switch (question.type) {
      case "essay":
        return <AEssayForm element={question} />;
      case "radio":
        return <ARadioForm element={question} />;
      case "checkbox":
        return <ACheckboxForm element={question} />;
      case "dropdown":
        return <ADropdownForm element={question} />;
Lee SeoYeon's avatar
Lee SeoYeon committed
28
29
30
31
32
33
34
35
      case "file":
        return <AFileForm element={question} />;
      case "rating":
        return <ARatingForm element={question} />;
      case "date":
        return <ADateForm />;
      // case "matrix":
      //   return <AMatrixForm />;
36
37
38
39
40
41
42
43
      default:
        return <></>;
    }
  }

  return (
    <div className="flex flex-col container w-4/5 h-auto border-2 border-themeColor items-center m-3 py-3">
      <div className="flex flexgi-row h-16 w-full place-content-between items-center">
Lee SeoYeon's avatar
Lee SeoYeon committed
44
        <div className="text-xl font-bold ml-6 w-1/2">{question.title}</div>
45
      </div>
Lee SeoYeon's avatar
Lee SeoYeon committed
46
      <div className="w-11/12 my-3">{question.comment}</div>
47
48
49
50
      {getContent(question)}
    </div>
  );
};