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: window.scrollTo(0, 0); set422Errors(response.data.error_messages); break; } }) } return (

パスワード編集

setPassword(e.target.value)} autoFocus/> { _422errors.password && { _422errors.password } }
setConfirmPassword(e.target.value)}/> { _422errors.password_confirmation && { _422errors.password_confirmation } }
パスワードを更新
{ _400error && set400Error('')}>{_400error} } { _success && setSuccess('') }>{_success} }
) } export default ProfilePasswordEdit;