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

Yoon, Daeki's avatar
Yoon, Daeki committed
4
export const AEssayForm = ({ element, answerQuestion }: AnswerProps) => {
Jiwon Yoon's avatar
Jiwon Yoon committed
5
6
7
8
  const [answer, setAnswer] = useState("");

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