import React, { useEffect, useState } from 'react'; import { useHistory } from 'react-router-dom'; import { LoadingButton } from '@material-ui/lab'; import axios from 'axios'; import Alert from '../../component/alert'; const ParentRegister = () => { const history = useHistory(); const [email, setEmail] = useState(''); const [_422errors, set422Errors] = useState({ email: '' }); const [_400error, set400Error] = useState(''); const [_success, setSuccess] = useState(''); const [submit, setSubmit] = useState(false); const handleSubmit = (e) => { e.preventDefault(); setSubmit(true); const formdata = new FormData(); formdata.append('email', email); axios.post('/api/admin/fathers/registerTemporary', formdata) .then(response => { setSubmit(false); switch(response.data.status_code){ case 200: setSuccess(response.data.success_messages); break; case 422: set422Errors(response.data.error_messages); break; case 400: set400Error(response.data.error_messages); break; } }) .catch(err=>console.log(err)) } return (