ADateForm.tsx 690 Bytes
Newer Older
Jiwon Yoon's avatar
Jiwon Yoon committed
1
import React, { useState } from "react";
Yoon, Daeki's avatar
Yoon, Daeki committed
2
3
4
import { AnswerProps } from "../types";

export const ADateForm = ({ element, answerQuestion }: AnswerProps) => {
Jiwon Yoon's avatar
Jiwon Yoon committed
5
6
7
  const [answer, setAnswer] = useState("");
  const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
    const { value } = event.currentTarget;
Jiwon Yoon's avatar
Jiwon Yoon committed
8
    answerQuestion.answer = value;
Jiwon Yoon's avatar
Jiwon Yoon committed
9
    setAnswer(value);
Jiwon Yoon's avatar
Jiwon Yoon committed
10
11
12
13
14
15
    if (answerQuestion.answer) {
      answerQuestion.requiredCheck = true;
    } else {
      answerQuestion.requiredCheck = false;
    }
    console.log(answerQuestion);
Jiwon Yoon's avatar
Jiwon Yoon committed
16
  };
Lee SeoYeon's avatar
Lee SeoYeon committed
17
  return (
Lee SeoYeon's avatar
Lee SeoYeon committed
18
    <div className="justify-start w-11/12 m-3 py-4">
Jiwon Yoon's avatar
Jiwon Yoon committed
19
      <input type="date" onChange={handleChange}></input>
Lee SeoYeon's avatar
Lee SeoYeon committed
20
21
22
    </div>
  );
};