import React, { useEffect, useState } from 'react'; import Notification from '../../component/notification'; import ModalAlert from '../../component/modal_alert'; const ProfilePasswordEdit = () => { const [newPassword, setNewPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const fatherId = document.getElementById('father_id').value; const [showAlert, setShowAlert] = useState(false); const [messageAlert, setMessageAlert] = useState(null); const [textColor, setTextColor] = useState(null); const [errors, setErrors] = useState({ confirmPassword:'', newPassword:'', }) async function handleClick() { setErrors({ confirmPassword: confirmPassword ? '' : 'error', newPassword: newPassword ? '' : 'error', }); if(confirmPassword && newPassword) { try { const formdata = new FormData(); formdata.append('father_id', fatherId); formdata.append('password', newPassword); formdata.append('password_confirmation', confirmPassword); axios.put(`/api/fathers/updatePassword/${fatherId}`, formdata) .then(response => { if(response.data.status_code == 200){ setMessageAlert(response.data.success_messages); setTextColor("black"); } else { setMessageAlert(response.data.success_messages); } setShowAlert(true); }); } catch (error) { console.log('error', error); } } } async function handleCloseAlert() { setShowAlert(false); }; return (