import { useEffect, useState } from 'react'; import { useHistory } from 'react-router-dom'; import { LoadingButton } from '@material-ui/lab'; import Notification from '../notification'; import Alert from '../../component/alert'; const ProfilePasswordEdit = () => { const history = useHistory(); const [notice, setNotice] = useState(localStorage.getItem('notice')); const father_id = document.getElementById('father_id').value; const [password, setPassword] = useState(''); const [password_confirmation, setConfirmPassword] = useState(''); const [_422errors, set422Errors] = useState({ password:'', password_confirmation:'' }); const [_400error, set400Error] = useState(''); const [_success, setSuccess] = useState(''); const [submit, setSubmit] = useState(false); const handleSubmit = (e) => { e.preventDefault(); set422Errors({ password:'', password_confirmation:'' }); setSubmit(true); const post = { password: password, password_confirmation: password_confirmation } axios.put(`/api/fathers/updatePassword/${father_id}`, post) .then(response => { setSubmit(false); setNotice(response.data.notice); switch(response.data.status_code){ case 200:{ history.push({ pathname: '/p-account/profile', state: response.data.success_messages }); break; } case 400: set400Error(response.data.error_messages); break; case 422: set422Errors(response.data.error_messages); break; } }) } return (