import React, { 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 ParentPasswordEdit = (props) => { const history = useHistory(); 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 request = { password: password, password_confirmation: password_confirmation } axios.put(`/api/admin/fathers/updatePassword/${props.match.params?.father_id}`, request) .then(response => { setSubmit(false); switch(response.data.status_code){ case 200: setSuccess(response.data.success_messages); break; case 400: set400Error(response.data.error_messages); break; case 422: set422Errors(response.data.error_messages); break; } }) } return (