import React, { useEffect, useState } from 'react'; import Notification from '../../component/notification'; import ModalAlert from '../../component/modal_alert'; import axios from 'axios'; import { useHistory } from 'react-router-dom' const Profile = () => { const [father, setFather] = useState(null); const history = useHistory(); const fatherId = document.getElementById('father_id').value; const [image, setImage] = useState(null); const [showAlert, setShowAlert] = useState(false); const [messageAlert, setMessageAlert] = useState(null); const [textColor, setTextColor] = useState(null); useEffect(() => { axios.get(`/api/fathers/detail/${fatherId}`).then((response) => { if(response.data.status_code==200){ //console.log(response.data.params[0]); setFather(response.data.params[0]); setImage(response.data.params[0]?.image); } else if(response.data.status_code==400){ //TODO } }); }, []); if (!father) return null; const handleImageChange = (e) => { e.preventDefault(); let reader = new FileReader(); let _file = e.target.files[0]; reader.readAsDataURL(_file); reader.onloadend = () => { setImage(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); } }; async function handleCloseAlert() { setShowAlert(false); }; return (

プロフィール

{/* */}

{ father.last_name } { father.first_name }

メール

{ father.email }

電話

{ father.tel }

会社名

{ father.company }

) } export default Profile;