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

4
export const AEssay = ({ element, answer: answerQuestion }: IAnswerProps) => {
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;
9
    answerQuestion.content = value;
Jiwon Yoon's avatar
Jiwon Yoon committed
10
    setAnswer(value);
11
    if (answerQuestion.content) {
Jiwon Yoon's avatar
Jiwon Yoon committed
12
13
14
15
16
      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>
  );
};