From 3dae98a19e14691b1491e04b63eb17dc3422a08d Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Mon, 21 Oct 2024 11:14:29 +0200 Subject: [PATCH] - re done login con uuid; - re done reset password con uuid; - re done user management con uuid; --- .env | 2 +- environments/dev/dev.env | 2 +- environments/prod/prod.env | 2 +- src/helpers/getBandoLabel.js | 3 + src/helpers/getBandoSeverity.js | 3 + .../components/AppSidebar/index.js | 3 +- src/pages/LoginAdmin/index.js | 11 +- src/pages/ResetPassword/index.js | 25 +++- .../Users/components/AllUsersTable/index.js | 108 +++++++++--------- src/pages/Users/index.js | 76 +++++++++--- src/service/user-service.js | 8 ++ 11 files changed, 163 insertions(+), 80 deletions(-) diff --git a/.env b/.env index 10d2a9b..0b1a428 100644 --- a/.env +++ b/.env @@ -3,4 +3,4 @@ REACT_APP_API_EXECUTION_ADDRESS=https://api-dev-gepafin.memento.credit/v1 REACT_APP_API_ADDRESS=https://api-dev-gepafin.memento.credit REACT_APP_LOGO_FILENAME=gepafin-logo.svg REACT_APP_FAVICON_FILENAME=gepafin-favicon.ico -REACT_APP_HUB_ID=1 \ No newline at end of file +REACT_APP_HUB_ID=p4lk3bcx1RStqTaIVVbXs \ No newline at end of file diff --git a/environments/dev/dev.env b/environments/dev/dev.env index 10d2a9b..0b1a428 100644 --- a/environments/dev/dev.env +++ b/environments/dev/dev.env @@ -3,4 +3,4 @@ REACT_APP_API_EXECUTION_ADDRESS=https://api-dev-gepafin.memento.credit/v1 REACT_APP_API_ADDRESS=https://api-dev-gepafin.memento.credit REACT_APP_LOGO_FILENAME=gepafin-logo.svg REACT_APP_FAVICON_FILENAME=gepafin-favicon.ico -REACT_APP_HUB_ID=1 \ No newline at end of file +REACT_APP_HUB_ID=p4lk3bcx1RStqTaIVVbXs \ No newline at end of file diff --git a/environments/prod/prod.env b/environments/prod/prod.env index 53e9db7..6e25d7d 100644 --- a/environments/prod/prod.env +++ b/environments/prod/prod.env @@ -3,4 +3,4 @@ REACT_APP_API_EXECUTION_ADDRESS=https://bandi-api.gepafin.it/v1 REACT_APP_API_ADDRESS=https://bandi-api.gepafin.it REACT_APP_LOGO_FILENAME=gepafin-logo.svg REACT_APP_FAVICON_FILENAME=gepafin-favicon.ico -REACT_APP_HUB_ID=1 \ No newline at end of file +REACT_APP_HUB_ID=p4lk3bcx1RStqTaIVVbXs \ No newline at end of file diff --git a/src/helpers/getBandoLabel.js b/src/helpers/getBandoLabel.js index 55c0c08..d0b76cd 100644 --- a/src/helpers/getBandoLabel.js +++ b/src/helpers/getBandoLabel.js @@ -5,6 +5,9 @@ const getBandoLabel = (status) => { case 'SUBMIT': return __('Inviato', 'gepafin'); + case 'ACTIVE': + return __('Attivo', 'gepafin'); + case 'PUBLISH': return __('Pubblicato', 'gepafin'); diff --git a/src/helpers/getBandoSeverity.js b/src/helpers/getBandoSeverity.js index 89263be..45340b3 100644 --- a/src/helpers/getBandoSeverity.js +++ b/src/helpers/getBandoSeverity.js @@ -5,6 +5,9 @@ const getBandoSeverity = (status) => { case 'SUBMIT': return 'success'; + case 'ACTIVE': + return 'success'; + case 'PUBLISH': return 'success'; diff --git a/src/layouts/DefaultLayout/components/AppSidebar/index.js b/src/layouts/DefaultLayout/components/AppSidebar/index.js index 61a4484..2f36be7 100644 --- a/src/layouts/DefaultLayout/components/AppSidebar/index.js +++ b/src/layouts/DefaultLayout/components/AppSidebar/index.js @@ -45,8 +45,7 @@ const AppSidebar = () => { icon: 'pi pi-users', href: '/utenti', id: 5, - enable: false - //enable: intersection(permissions, ['VIEW_USERS', 'MANAGE_USERS']).length + enable: intersection(permissions, ['VIEW_USERS', 'MANAGE_USERS']).length }, { label: __('Configurazione', 'gepafin'), diff --git a/src/pages/LoginAdmin/index.js b/src/pages/LoginAdmin/index.js index 8f76524..0fb1e3d 100644 --- a/src/pages/LoginAdmin/index.js +++ b/src/pages/LoginAdmin/index.js @@ -17,6 +17,8 @@ import LogoIcon from '../../icons/LogoIcon'; import { Button } from 'primereact/button'; import { Messages } from 'primereact/messages'; +const APP_HUB_ID = process.env.REACT_APP_HUB_ID; + const LoginAdmin = () => { const navigate = useNavigate(); const token = useStore().main.token(); @@ -28,11 +30,16 @@ const LoginAdmin = () => { formState: { errors }, } = useForm({ mode: 'onChange' }); + const gotToResetPassword = () => { + navigate('/reset-password'); + } + const onSubmit = (formData) => { errorMsgs.current.clear(); setLoading(true); const request = { ...formData, + hubUuid: APP_HUB_ID, rememberMe: true } @@ -64,10 +71,6 @@ const LoginAdmin = () => { setLoading(false); } - const gotToResetPassword = () => { - navigate('/reset-password'); - } - useEffect(() => { if (!isEmpty(token)) { setLoading(true); diff --git a/src/pages/ResetPassword/index.js b/src/pages/ResetPassword/index.js index def5e03..7052b41 100644 --- a/src/pages/ResetPassword/index.js +++ b/src/pages/ResetPassword/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 { useNavigate } from 'react-router-dom'; // tools import AuthenticationService from '../../service/authentication-service'; @@ -16,7 +17,10 @@ import LogoIcon from '../../icons/LogoIcon'; import { Button } from 'primereact/button'; import { Messages } from 'primereact/messages'; +const APP_HUB_ID = process.env.REACT_APP_HUB_ID; + const ResetPassword = () => { + const navigate = useNavigate(); const token = useStore().main.token(); const [loading, setLoading] = useState(false); const [resetPassToken, setResetPassToken] = useState(''); @@ -30,14 +34,23 @@ const ResetPassword = () => { setValue } = useForm({ mode: 'onChange' }); + const gotToLoginAdmin = () => { + navigate('/loginadmin'); + } + const onSubmit = (formData) => { errorMsgs.current.clear(); setLoading(true); const request = { - ...formData + ...formData, + hubUuid: APP_HUB_ID } - AuthenticationService.forgotPassword(request, getCallback, errCallback); + if (request.token && !isEmpty(request.token)) { + AuthenticationService.resetPassword(request, getCallback, errCallback); + } else { + AuthenticationService.forgotPassword(request, getCallback, errCallback); + } }; const getCallback = (data) => { @@ -59,7 +72,7 @@ const ResetPassword = () => { errorMsgs.current.show([ { sticky: true, severity: 'error', summary: '', - detail: sprintf(__('%s', 'gepafin'), err), + detail: sprintf(__('%s', 'gepafin'), err.message), closable: true } ]); @@ -104,7 +117,7 @@ const ResetPassword = () => { ? : null} @@ -144,6 +157,10 @@ const ResetPassword = () => {