import React, { useEffect, useState } from 'react'; import { useHistory } from 'react-router'; import { LoadingButton } from '@material-ui/lab'; import axios from 'axios'; import IconButton from "@material-ui/core/IconButton"; import PhotoCameraOutlinedIcon from '@mui/icons-material/PhotoCameraOutlined'; const ChildSignUp = (props) => { const history = useHistory(); const [submit, setSubmit] = useState(false); const [first_name, setFirstName] = useState(''); const [last_name, setLastName] = useState(''); const [identity, setIdentity] = useState(''); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [password_confirmation, setPasswordConfirmation] = useState(''); const [company, setCompany] = useState(''); const [image, setImage] = useState(null); const [_422errors, set422Errors] = useState({ first_name:'', last_name:'', identity:'', email:'', password:'', password_confirmation: '', image:'', company:'' }); const handleSubmit = (e) => { e.preventDefault(); set422Errors({ first_name:'', last_name:'', identity:'', email:'', password:'', password_confirmation: '', image:'', company:'' }); setSubmit(true); const formdata = new FormData(); formdata.append('first_name', first_name); formdata.append('last_name', last_name); formdata.append('identity', identity); formdata.append('email', email); formdata.append('password', password); formdata.append('password_confirmation', password_confirmation); formdata.append('company', company); formdata.append('image', image); formdata.append('token', props.match.params.token); axios.post('/api/children/registerMain', formdata) .then(response => { setSubmit(false); switch(response.data.status_code){ case 200: history.push({pathname: '/c-account/register/complete/'+props.match.params.token, state: response.data.success_messages}); break; case 422: set422Errors(response.data.error_messages); break; case 400: history.push({pathname: '/c-account/register/error/'+props.match.params.token, state: response.data.error_messages}); break; }; }) } const handleImageChange = (e) => { e.preventDefault(); let reader = new FileReader(); let _file = e.target.files[0]; reader.readAsDataURL(_file); reader.onloadend = () => { setImage(reader.result); }; }; return (

本登録

handleImageChange(e)}/>
{ image && avatar-img }
{ _422errors.image && { _422errors.image } }
setLastName(e.target.value)}/> { _422errors.last_name && { _422errors.last_name } }
setFirstName(e.target.value)}/> { _422errors.first_name && { _422errors.first_name } }
setIdentity(e.target.value)}/> { _422errors.identity && { _422errors.identity } }
setEmail(e.target.value)}/> { _422errors.email && { _422errors.email } }
setPassword(e.target.value)}/> { _422errors.password && { _422errors.password } }
setPasswordConfirmation(e.target.value)}/> { _422errors.password_confirmation && { _422errors.password_confirmation } }
setCompany(e.target.value)}/> { _422errors.company && { _422errors.company } }
本登録
) } export default ChildSignUp;