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 = () => { const history = useHistory(); const [submit, setSubmit] = useState(false); const [first_name, setFirstName] = useState(''); const [last_name, setLastName] = useState(''); const [identify, setIdentify] = useState(''); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [company, setCompany] = useState(''); const [image, setImage] = useState(''); const [_422errors, set422Errors] = useState({ first_name:'', last_name:'', identify:'', email:'', password:'', image:'', company:'' }); const handleSubmit = (e) => { e.preventDefault(); set422Errors({ first_name:'', last_name:'', identify:'', email:'', password:'', image:'', company:'' }); setSubmit(true); const formdata = new FormData(); formdata.append('first_name', first_name); formdata.append('last_name', last_name); formdata.append('identify', identify); formdata.append('email', email); formdata.append('password', password); formdata.append('company', company); formdata.append('image', image); axios.post('/api/children/registerMain', formdata) .then(response => { setSubmit(false); switch(response.data.status_code){ case 200: history.push({pathname: '/c-account/register/complete', state: {}}); break; case 422: set422Errors(response.data.error_messages); break; case 400: history.push({pathname: '/c-account/register/error', state: {}}); break; }; }) .catch(err=>console.log(err)) } const handleImageChange = (e) => { e.preventDefault(); let reader = new FileReader(); let _file = e.target.files[0]; reader.readAsDataURL(_file); reader.onloadend = () => { setImage(reader.result); }; }; return (
) } export default ChildSignUp;