From 1bd00def4be5623c4a874070458c03408204b217 Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Thu, 26 Sep 2024 09:58:08 +0200 Subject: [PATCH] - test of spid login; --- environments/prod/prod.env | 2 +- src/pages/Login/index.js | 10 ++++++- src/pages/Profile/index.js | 53 +++++++++++++++++++++++++++++++++ src/pages/Registration/index.js | 6 ++++ src/routes.js | 5 ++++ 5 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 src/pages/Profile/index.js diff --git a/environments/prod/prod.env b/environments/prod/prod.env index 8e6e6b7..b470092 100644 --- a/environments/prod/prod.env +++ b/environments/prod/prod.env @@ -1,3 +1,3 @@ REACT_APP_TAB_TITLE=Gepafin -REACT_APP_API_EXECUTION_ADDRESS=http://79.137.88.15/v1 +REACT_APP_API_EXECUTION_ADDRESS=http://bandi.gepafin.it/v1 REACT_APP_LOGO_FILENAME=logo.svg \ No newline at end of file diff --git a/src/pages/Login/index.js b/src/pages/Login/index.js index 05aa96b..c57ac60 100644 --- a/src/pages/Login/index.js +++ b/src/pages/Login/index.js @@ -9,13 +9,17 @@ import { storeSet, useStore } from '../../store'; // components import LogoIcon from '../../icons/LogoIcon'; import { Messages } from 'primereact/messages'; +import { useParams } from 'react-router-dom'; + +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 loginWithSpid = () => { - console.log('spid') + window.location.replace(`${API_BASE_URL}/saml2/authenticate/loginumbria`); } useEffect(() => { @@ -24,6 +28,10 @@ const Login = () => { } }, [token]); + useEffect(() => { + console.log('temp_token', temp_token) + }, [temp_token]); + return (
diff --git a/src/pages/Profile/index.js b/src/pages/Profile/index.js new file mode 100644 index 0000000..3cfa151 --- /dev/null +++ b/src/pages/Profile/index.js @@ -0,0 +1,53 @@ +import React, { useState, useEffect, useRef } from 'react'; +import { __, sprintf } from '@wordpress/i18n'; +import { useNavigate, useParams } from 'react-router-dom'; +import { is } from 'ramda'; + +// store +import { storeSet, useStore } from '../../store'; + +// components +import { Messages } from 'primereact/messages'; +import set404FromErrorResponse from '../../helpers/set404FromErrorResponse'; + +const Profile = () => { + const isAsyncRequest = useStore().main.isAsyncRequest(); + const { id } = useParams(); + const [data, setData] = useState({}); + const infoMsgs = useRef(null); + + const getCallback = (data) => { + if (data.status === 'SUCCESS') { + //setData(getFormattedBandiData(data.data)); + } + storeSet.main.unsetAsyncRequest(); + } + + const errGetCallback = (data) => { + set404FromErrorResponse(data); + storeSet.main.unsetAsyncRequest(); + } + + useEffect(() => { + //BandoService.getBando(bandoId, getCallback, errGetCallback); + }, [id]); + + return ( +
+
+

{data.name}

+

+ {__('Profilo utente', 'gepafin')} +

+
+ +
+ + + +
+ ) + +} + +export default Profile; \ No newline at end of file diff --git a/src/pages/Registration/index.js b/src/pages/Registration/index.js index db5968f..bee30c4 100644 --- a/src/pages/Registration/index.js +++ b/src/pages/Registration/index.js @@ -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 { useParams } from 'react-router-dom'; // api import AuthenticationService from '../../service/authentication-service'; @@ -23,6 +24,7 @@ const Registration = () => { const token = useStore().main.token(); const [loading, setLoading] = useState(false); const errorMsgs = useRef(null); + let { temp_token } = useParams(); const { control, handleSubmit, @@ -73,6 +75,10 @@ const Registration = () => { } }, [token]); + useEffect(() => { + console.log('temp_token', temp_token) + }, [temp_token]); + return (
diff --git a/src/routes.js b/src/routes.js index 583bbc4..4812fcf 100644 --- a/src/routes.js +++ b/src/routes.js @@ -20,6 +20,7 @@ import BandoApplication from './pages/BandoApplication'; import Registration from './pages/Registration'; import BandiBeneficiario from './pages/BandiBeneficiario'; import LoginAdmin from './pages/LoginAdmin'; +import Profile from './pages/Profile'; const routes = ({ role }) => { return ( @@ -69,6 +70,10 @@ const routes = ({ role }) => { {'ROLE_SUPER_ADMIN' === role ? : null} {'ROLE_BENEFICIARY' === role ? : null} }/> + + {'ROLE_SUPER_ADMIN' === role ? : null} + {'ROLE_BENEFICIARY' === role ? : null} + }/> }/> }/>