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

export const ADateForm = ({ element, answers, handleAnswer }: 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;
8
9
10
11
12
    // response.answers.map((a) => {
    //   if (a.questionId === element._id) {
    //     a.answer = value;
    //   }
    // });
Yoon, Daeki's avatar
Yoon, Daeki committed
13
    answers && (answers.answer = value);
Jiwon Yoon's avatar
Jiwon Yoon committed
14
15
16
    setAnswer(value);
    handleAnswer();
  };
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
20
21
22
23
      <input
        type="date"
        onChange={handleChange}
        required={element.isRequired}
      ></input>
Lee SeoYeon's avatar
Lee SeoYeon committed
24
25
26
    </div>
  );
};