AEssayForm.tsx 890 Bytes
Newer Older
Jiwon Yoon's avatar
Jiwon Yoon committed
1
import React, { useState } from "react";
2
import { AnswerProps, EssayType } from "../types";
Lee SeoYeon's avatar
Lee SeoYeon committed
3

4
5
type Props = {
  element: EssayType;
Jiwon Yoon's avatar
Jiwon Yoon committed
6
  answerQuestion: any | undefined;
7
8
};

Jiwon Yoon's avatar
Jiwon Yoon committed
9
export const AEssayForm = ({ element, answerQuestion }: Props) => {
Jiwon Yoon's avatar
Jiwon Yoon committed
10
11
12
13
  const [answer, setAnswer] = useState("");

  const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
    const { value } = event.currentTarget;
Jiwon Yoon's avatar
Jiwon Yoon committed
14
    answerQuestion.answer = value;
Jiwon Yoon's avatar
Jiwon Yoon committed
15
    setAnswer(value);
Jiwon Yoon's avatar
Jiwon Yoon committed
16
17
18
19
20
21
    if (answerQuestion.answer) {
      answerQuestion.requiredCheck = true;
    } else {
      answerQuestion.requiredCheck = false;
    }
    console.log(answerQuestion);
Jiwon Yoon's avatar
Jiwon Yoon committed
22
  };
Lee SeoYeon's avatar
Lee SeoYeon committed
23
  return (
Jiwon Yoon's avatar
Jiwon Yoon committed
24
25
26
27
28
29
30
31
    <div className="flex mt-3 w-full justify-center">
      <input
        type="text"
        className="border w-11/12 h-36 my-3"
        id={element._id}
        onChange={handleChange}
        value={answer}
      ></input>
Lee SeoYeon's avatar
Lee SeoYeon committed
32
33
34
    </div>
  );
};