SurveyForm.tsx 1.71 KB
Newer Older
Jiwon Yoon's avatar
Jiwon Yoon committed
1
2
3
4
5
import React, { useEffect, useState } from "react";
import { useParams } from "react-router-dom";
import { surveyApi } from "../apis";
import { Question } from "../questions";
import { SurveyType } from "../types";
Lee SeoYeon's avatar
Lee SeoYeon committed
6
7
8
9
import { ACheckboxForm } from "./ACheckbox";
import { ADropdownForm } from "./ADropdown";
import { AEssayForm } from "./AEssayForm";
import { ARadioForm } from "./ARadioForm";
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
10

Lee SeoYeon's avatar
0708    
Lee SeoYeon committed
11
export const SurveyForm = () => {
Jiwon Yoon's avatar
Jiwon Yoon committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  let { surveyId } = useParams<{ surveyId: string }>();
  const [survey, setSurvey] = useState<SurveyType>({
    _id: surveyId,
    user: {},
    title: "",
    comment: "",
    questions: [],
  });
  useEffect(() => {
    getSurvey();
  }, [surveyId]);
  async function getSurvey() {
    try {
      if (surveyId) {
        const thisSurvey: SurveyType = await surveyApi.getASurvey(surveyId);
        console.log(thisSurvey);
        setSurvey(thisSurvey);
        // setSuccess(true);
        // setError("");
      } else {
        // setLoading(true);
      }
    } catch (error) {
      // catchErrors(error, setError);
    } finally {
      // setLoading(false);
    }
  }
Lee SeoYeon's avatar
0708    
Lee SeoYeon committed
40
41
42
43
44
45
46
47
48
49
  return (
    <div className="flex flex-col place-items-center">
      <div className="flex flex-col container place-items-center mt-4">
        <form className="font-bold text-4xl text-center m-2">설문지 제목</form>
        <textarea
          className="font-bold text-1xl text-center m-2 resize-none"
          placeholder="설문조사에 대한 설명을 입력해주세요"
          rows={2}
          cols={60}
        ></textarea>
Lee SeoYeon's avatar
Lee SeoYeon committed
50
51
52
53
        <div>
          <button className="rounded bg-themeColor my-5 py-2 px-5 font-bold text-white">
            제출하기
          </button>
Lee SeoYeon's avatar
Lee SeoYeon committed
54
        </div>
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
55
56
      </div>
    </div>
Lee SeoYeon's avatar
0708    
Lee SeoYeon committed
57
58
  );
};