import React, { useEffect, useState } from 'react'; import Notification from '../../component/notification'; import axios from 'axios'; import { useHistory } from 'react-router-dom' const MeetingAdd = () => { const [textColor, setTextColor] = useState(null); const [showAlert, setShowAlert] = useState(false); const [messageAlert, setMessageAlert] = useState(null); const fatherId = document.getElementById('father_id').value; const [images, setImages] = useState([]); const [pdf, setPdf] = useState(null); const [title, setTitle] = useState(null); const [memo, setMemo] = useState(null); const [text, setText] = useState(null); const history = useHistory(); const [errors, setErrors] = useState({ title:'', memo:'', text:'', pdf:'', images:'' }) async function handleClick() { setErrors({ title:'', memo:'', text:'', pdf:'', images:'' }); try { const formdata = new FormData(); formdata.append('father_id', fatherId); formdata.append('title', title); formdata.append('memo', memo); formdata.append('text', text); formdata.append('pdf', pdf); formdata.append('images', images); axios.post('/api/meetings/register', formdata) .then(response => { if(response.data.status_code==200){ history.push({ pathname: "/p-account/meetings/detail/1", state: {message : "ミーティングを作成しました!"} }); } else { setMessageAlert('error'); setShowAlert(true); } }); } catch (error) { console.log('error', error); } } const handleImageChange = (e) => { e.preventDefault(); let reader = new FileReader(); let _file = e.target.files[0]; reader.readAsDataURL(_file); reader.onloadend = () => { setImages([...images, reader.result]); }; // //upload image // try { // const formdata = new FormData(); // formdata.append('father_id', fatherId); // formdata.append('image', _file); // axios.put("/api/fathers/updateImage", formdata) // .then(response => { // if(response.data.status_code == 200){ // setMessageAlert(response.data.success_messages); // setTextColor("black"); // } else { // setMessageAlert(response.data.success_messages); // } // setShowAlert(true); // }); // } catch (error) { // console.log('error', error); // } }; const handlePdfChange = (e) => { e.preventDefault(); let reader = new FileReader(); let _file = e.target.files[0]; reader.readAsDataURL(_file); reader.onloadend = () => { setPdf(reader.result); }; }; async function handleCloseAlert() { setShowAlert(false); }; return (

ミーティング作成

setTitle(e.target.value)} className="input-default input-title input-h60 input-w480" id="title" />