import React, { useState } from 'react' import styles from './feedbackArea.module.css' import constants from '../constants.json' function FileUploader({ onChange }) { return (
Fájl csatolása (Több fájlt ZIP-be tömörítve lehet egyszerre)
) } function submitFeedback(from, content, file) { return new Promise((resolve) => { const promises = [ fetch(constants.apiUrl + 'postfeedback', { method: 'POST', credentials: 'include', headers: { Accept: 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify({ content: content, from: from, }), }).then((res) => { return res.json() }), ] if (file) { const formData = new FormData() // eslint-disable-line formData.append('file', file) promises.push( fetch(constants.apiUrl + 'postfeedbackfile', { method: 'POST', credentials: 'include', headers: { Accept: 'application/json', }, body: formData, }).then((res) => { return res.json() }) ) } Promise.all(promises).then((res) => { resolve(res) }) }) } export default function FeedbackArea({ from, allowFile }) { const [feedback, setFeedback] = useState('') const [file, setFile] = useState() return (