Questions.tsx 1.27 KB
Newer Older
Jiwon Yoon's avatar
Jiwon Yoon committed
1
import React, { useState } from "react";
Jiwon Yoon's avatar
Jiwon Yoon committed
2
import { QEssay } from "./QEssay";
Jiwon Yoon's avatar
Jiwon Yoon committed
3
4
import { QCheckbox } from "./QCheckbox";
import { QRadio } from "./QRadio";
Jiwon Yoon's avatar
Jiwon Yoon committed
5
6
import { QDropdown } from "./QDropdown";
import { QFile } from "./QFile";
Jiwon Yoon's avatar
QRating    
Jiwon Yoon committed
7
import { QRating } from "./QRating";
Jiwon Yoon's avatar
Jiwon Yoon committed
8
import { useQuestion } from "./question.context";
9

Jiwon Yoon's avatar
Jiwon Yoon committed
10
11
type Props = {};

12
export const Questions = ({}: Props) => {
Jiwon Yoon's avatar
Jiwon Yoon committed
13
  const { addQuestion, questionList, currentId } = useQuestion();
14

Jiwon Yoon's avatar
Jiwon Yoon committed
15
16
  return (
    <>
Jiwon Yoon's avatar
Jiwon Yoon committed
17
      {console.log(questionList, currentId)}
Jiwon Yoon's avatar
Jiwon Yoon committed
18
19
      {questionList.map((element) => {
        switch (element.type) {
Jiwon Yoon's avatar
Jiwon Yoon committed
20
          case "essay":
Jiwon Yoon's avatar
Jiwon Yoon committed
21
            return <QEssay element={element} />;
Jiwon Yoon's avatar
Jiwon Yoon committed
22
          case "radio":
Jiwon Yoon's avatar
Jiwon Yoon committed
23
            return <QRadio element={element} />;
Jiwon Yoon's avatar
Jiwon Yoon committed
24
          case "checkbox":
Jiwon Yoon's avatar
Jiwon Yoon committed
25
            return <QCheckbox element={element} />;
Jiwon Yoon's avatar
Jiwon Yoon committed
26
          case "dropdown":
Jiwon Yoon's avatar
Jiwon Yoon committed
27
            return <QDropdown element={element} />;
Jiwon Yoon's avatar
Jiwon Yoon committed
28
          case "file":
Jiwon Yoon's avatar
Jiwon Yoon committed
29
            return <QFile element={element} />;
Jiwon Yoon's avatar
QRating    
Jiwon Yoon committed
30
          case "rating":
Jiwon Yoon's avatar
Jiwon Yoon committed
31
            return <QRating element={element} />;
Jiwon Yoon's avatar
Jiwon Yoon committed
32
33
34
35
          default:
            break;
        }
      })}
Jiwon Yoon's avatar
Jiwon Yoon committed
36
      <div className="flex w-4/5 content-center justify-center border-2 border-black h-8 mt-3">
Jiwon Yoon's avatar
Jiwon Yoon committed
37
38
39
        <button type="button" onClick={addQuestion}>
          질문 추가
        </button>
Jiwon Yoon's avatar
Jiwon Yoon committed
40
      </div>
Jiwon Yoon's avatar
Jiwon Yoon committed
41
42
43
    </>
  );
};