AQuestion.tsx 1.55 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
import { AFileForm } from "./AFileForm";
9
import { ARadioForm } from "./ARadioForm";
Lee SeoYeon's avatar
Lee SeoYeon committed
10
import { ARatingForm } from "./ARatingForm";
11
12
13
14

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

16
17
18
19
20
21
22
23
24
25
26
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
27
28
29
30
31
32
      case "file":
        return <AFileForm element={question} />;
      case "rating":
        return <ARatingForm element={question} />;
      case "date":
        return <ADateForm />;
33
34
35
36
37
38
39
40
      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
41
        <div className="text-xl font-bold ml-6 w-1/2">{question.title}</div>
42
      </div>
Lee SeoYeon's avatar
Lee SeoYeon committed
43
      <div className="w-11/12 my-3">{question.comment}</div>
44
45
46
47
      {getContent(question)}
    </div>
  );
};