import React, { useState } from "react"; import { FileType, AnswersType } from "../types"; type Props = { element: FileType; answers: AnswersType; handleAnswer: () => void; addFiles: (oneFile: { questionId: string; file: File }) => void; }; export const AFileForm = ({ element, answers, handleAnswer, addFiles, }: Props) => { const handleChange = (event: React.ChangeEvent) => { if (event.currentTarget.files) { const uploadFile = event.currentTarget.files[0]; addFiles({ questionId: element._id, file: uploadFile }); // response.answers.map((a) => { // if (a.questionId === element._id) { // a.answer = uploadFile.name; // } // }); answers[element._id] = uploadFile.name; handleAnswer(); } }; return (
); };