- updated login page;

- updated registration page;
- created profile page;
- created company profile page;
This commit is contained in:
Vitalii Kiiko
2024-09-27 09:09:48 +02:00
parent 1bd00def4b
commit 478af11cb9
11 changed files with 406 additions and 41 deletions

View File

@@ -1,5 +1,5 @@
import React, { useRef, useEffect } from 'react';
import { __ } from '@wordpress/i18n';
import React, { useRef, useEffect, useState } from 'react';
import { __, sprintf } from '@wordpress/i18n';
import { classNames } from 'primereact/utils';
import { isEmpty } from 'ramda';
@@ -9,17 +9,50 @@ import { storeSet, useStore } from '../../store';
// components
import LogoIcon from '../../icons/LogoIcon';
import { Messages } from 'primereact/messages';
import { useParams } from 'react-router-dom';
import { useSearchParams } from 'react-router-dom';
import AuthenticationService from '../../service/authentication-service';
const API_BASE_URL = process.env.REACT_APP_API_EXECUTION_ADDRESS;
const Login = () => {
const token = useStore().main.token();
const errorMsgs = useRef(null);
let { temp_token } = useParams();
const [loading, setLoading] = useState(false);
let [searchParams] = useSearchParams();
const loginWithSpid = () => {
window.location.replace(`${API_BASE_URL}/saml2/authenticate/loginumbria`);
if (!loading) {
window.location.replace(`${API_BASE_URL}/saml2/authenticate/loginumbria`);
}
}
const validateCallback = (data) => {
if (data.status === 'SUCCESS') {
storeSet.main.setAuthData({
token: data.data.token,
userData: data.data.user
});
} else {
errorMsgs.current.show([
{
sticky: true, severity: 'error', summary: '',
detail: data.message,
closable: true
}
]);
}
setLoading(false);
}
const validateError = (err) => {
errorMsgs.current.show([
{
sticky: true, severity: 'error', summary: '',
detail: sprintf(__('%s', 'gepafin'), err.message),
closable: true
}
]);
setLoading(false);
}
useEffect(() => {
@@ -29,8 +62,12 @@ const Login = () => {
}, [token]);
useEffect(() => {
console.log('temp_token', temp_token)
}, [temp_token]);
const temp_token = searchParams.get('temp_token');
if (temp_token) {
errorMsgs.current.clear();
AuthenticationService.validateExistingUser(temp_token, validateCallback, validateError);
}
}, [searchParams]);
return (
<div className={classNames(['appPage', 'appPageLogin'])}>