ADateForm.tsx 767 Bytes
Newer Older
Jiwon Yoon's avatar
Jiwon Yoon committed
1
import React, { useState } from "react";
2
import { DateType, AnswersType } from "../types";
Jiwon Yoon's avatar
Jiwon Yoon committed
3
4
type Props = {
  element: DateType;
Jiwon Yoon's avatar
Jiwon Yoon committed
5
  answerQuestion: any | undefined;
Jiwon Yoon's avatar
Jiwon Yoon committed
6
};
Jiwon Yoon's avatar
Jiwon Yoon committed
7
export const ADateForm = ({ element, answerQuestion }: Props) => {
Jiwon Yoon's avatar
Jiwon Yoon committed
8
9
10
  const [answer, setAnswer] = useState("");
  const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
    const { value } = event.currentTarget;
Jiwon Yoon's avatar
Jiwon Yoon committed
11
    answerQuestion.answer = value;
Jiwon Yoon's avatar
Jiwon Yoon committed
12
    setAnswer(value);
Jiwon Yoon's avatar
Jiwon Yoon committed
13
14
15
16
17
18
    if (answerQuestion.answer) {
      answerQuestion.requiredCheck = true;
    } else {
      answerQuestion.requiredCheck = false;
    }
    console.log(answerQuestion);
Jiwon Yoon's avatar
Jiwon Yoon committed
19
  };
Lee SeoYeon's avatar
Lee SeoYeon committed
20
  return (
Lee SeoYeon's avatar
Lee SeoYeon committed
21
    <div className="justify-start w-11/12 m-3 py-4">
Jiwon Yoon's avatar
Jiwon Yoon committed
22
      <input type="date" onChange={handleChange}></input>
Lee SeoYeon's avatar
Lee SeoYeon committed
23
24
25
    </div>
  );
};