- added page reset password;
This commit is contained in:
@@ -3,6 +3,7 @@ import { __, sprintf } from '@wordpress/i18n';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { classNames } from 'primereact/utils';
|
||||
import { isEmpty } from 'ramda';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
// tools
|
||||
import AuthenticationService from '../../service/authentication-service';
|
||||
@@ -17,6 +18,7 @@ import { Button } from 'primereact/button';
|
||||
import { Messages } from 'primereact/messages';
|
||||
|
||||
const LoginAdmin = () => {
|
||||
const navigate = useNavigate();
|
||||
const token = useStore().main.token();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const errorMsgs = useRef(null);
|
||||
@@ -38,7 +40,6 @@ const LoginAdmin = () => {
|
||||
};
|
||||
|
||||
const loginCallback = (data) => {
|
||||
//console.log('loginCallback', data);
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.setAuthData({
|
||||
token: data.data.token,
|
||||
@@ -57,17 +58,19 @@ const LoginAdmin = () => {
|
||||
const loginError = (err) => {
|
||||
errorMsgs.current.show([
|
||||
{ sticky: true, severity: 'error', summary: '',
|
||||
detail: sprintf(__('%s', 'gepafin'), err),
|
||||
detail: sprintf(__('%s', 'gepafin'), err.message),
|
||||
closable: true }
|
||||
]);
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
const gotToResetPassword = () => {
|
||||
navigate('/reset-password');
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
//console.log('login admin, updated token:', token);
|
||||
if (!isEmpty(token)) {
|
||||
setLoading(true);
|
||||
//console.log('login admin, do redirect to "/"');
|
||||
window.location.replace('/')
|
||||
}
|
||||
}, [token]);
|
||||
@@ -79,8 +82,6 @@ const LoginAdmin = () => {
|
||||
|
||||
<h1>{__('Accedi o Registrati', 'gepafin')}</h1>
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
<Messages ref={errorMsgs}/>
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
@@ -109,6 +110,10 @@ const LoginAdmin = () => {
|
||||
<Button
|
||||
label={__('Accedi', 'gepafin')}
|
||||
disabled={loading}/>
|
||||
|
||||
<Button
|
||||
label={__('Password dimenticata?', 'gepafin')}
|
||||
link onClick={gotToResetPassword}/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user