diff --git a/.env b/.env index 8579a8f..9fc1609 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ REACT_APP_TAB_TITLE=Gepafin 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=logo.svg \ No newline at end of file +REACT_APP_LOGO_FILENAME=gepafin-logo.svg \ No newline at end of file diff --git a/environments/dev/dev.env b/environments/dev/dev.env index 8579a8f..9fc1609 100644 --- a/environments/dev/dev.env +++ b/environments/dev/dev.env @@ -1,4 +1,4 @@ REACT_APP_TAB_TITLE=Gepafin 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=logo.svg \ No newline at end of file +REACT_APP_LOGO_FILENAME=gepafin-logo.svg \ No newline at end of file diff --git a/environments/prod/prod.env b/environments/prod/prod.env index e7d2349..307b3b1 100644 --- a/environments/prod/prod.env +++ b/environments/prod/prod.env @@ -1,4 +1,4 @@ REACT_APP_TAB_TITLE=Gepafin REACT_APP_API_EXECUTION_ADDRESS=https://bandi-api.gepafin.it/v1 REACT_APP_API_ADDRESS=https://bandi-api.gepafin.it -REACT_APP_LOGO_FILENAME=logo.svg \ No newline at end of file +REACT_APP_LOGO_FILENAME=gepafin-logo.svg \ No newline at end of file diff --git a/public/index.html b/public/index.html index 0e46bc7..05b5a5f 100644 --- a/public/index.html +++ b/public/index.html @@ -2,11 +2,11 @@ - + - - + + %REACT_APP_TAB_TITLE% diff --git a/public/loaded-files/logo.svg b/public/loaded-files/gepafin-logo.svg similarity index 100% rename from public/loaded-files/logo.svg rename to public/loaded-files/gepafin-logo.svg diff --git a/public/loaded-files/sviluppumbria-logo.svg b/public/loaded-files/sviluppumbria-logo.svg new file mode 100644 index 0000000..392600b --- /dev/null +++ b/public/loaded-files/sviluppumbria-logo.svg @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/scss/components/appPage.scss b/src/assets/scss/components/appPage.scss index feb7d93..9bf6f18 100644 --- a/src/assets/scss/components/appPage.scss +++ b/src/assets/scss/components/appPage.scss @@ -157,6 +157,18 @@ flex: 0 0 auto; } } + + &.columns { + gap: 2em; + column-count: 2; + column-width: 4em; + display: block; + padding-bottom: 0; + + .appPageSection__pMeta { + margin-bottom: 1em; + } + } } @container section_with_border (max-width: 600px) { @@ -212,6 +224,10 @@ font-weight: 600; line-height: normal; } + + span:nth-of-type(2) { + font-weight: 400; + } } .appPageSection__table { diff --git a/src/pages/EvaluationEdit/index.js b/src/pages/EvaluationEdit/index.js new file mode 100644 index 0000000..a018885 --- /dev/null +++ b/src/pages/EvaluationEdit/index.js @@ -0,0 +1,135 @@ +import React, { useState, useEffect, useRef } from 'react'; +import { __ } from '@wordpress/i18n'; +import { useNavigate, useParams } from 'react-router-dom'; +import { is, isEmpty, isNil } from 'ramda'; + +// store +import { storeSet, useStore } from '../../store'; + +// tools +import getNumberWithCurrency from '../../helpers/getNumberWithCurrency'; +//import getDateFromISOstring from '../../helpers/getDateFromISOstring'; + +// components +import { Skeleton } from 'primereact/skeleton'; +import { Button } from 'primereact/button'; +import { Messages } from 'primereact/messages'; + +const EvaluationEdit = () => { + const isAsyncRequest = useStore().main.isAsyncRequest(); + const { id } = useParams(); + const navigate = useNavigate(); + const [data, setData] = useState({}); + const pageMsgs = useRef(null); + + const goToEvaluationsPage = () => { + navigate('/valutazioni'); + } + + /*const getCallback = (data) => { + if (data.status === 'SUCCESS') { + setData(getFormattedBandiData(data.data)); + } + storeSet.main.unsetAsyncRequest(); + } + + const errGetCallback = (data) => { + if (pageMsgs.current && data.message) { + pageMsgs.current.show([ + { + sticky: true, severity: 'error', summary: '', + detail: data.message, + closable: true + } + ]); + } + set404FromErrorResponse(data); + storeSet.main.unsetAsyncRequest(); + }*/ + + /*const getFormattedBandiData = (data) => { + data.dates = data.dates.map(v => is(String, v) ? new Date(v) : (v ? v : '')); + return data; + };*/ + + useEffect(() => { + const parsed = parseInt(id) + const entityId = !isNaN(parsed) ? parsed : 0; + + setData({ + id: 'DOM_2024_001', + callTitle: 'Innovazione 2024', + beneficiario: 'Azienda Alpha SRL', + createdAt: '2024-08-01', + scadenzaAt: '2024-08-05', + status: 'In Valutazione' + }) + //BandoService.getBando(entityId, getCallback, errGetCallback); + }, [id]); + + return ( +
+
+

{__('Valuta domanda', 'gepafin')}

+
+ +
+ + +
+
+ +
+ + {!isAsyncRequest && !isEmpty(data) + ?
+
+

+ {__('ID domanda', 'gepafin')} + {data.id} +

+

+ {__('Bando', 'gepafin')} + {data.callTitle} +

+

+ {__('Beneficiario', 'gepafin')} + {data.beneficiario} +

+

+ {__('Data ricezione', 'gepafin')} + {data.createdAt} +

+

+ {__('Scadenza Valutazione', 'gepafin')} + {data.scadenzaAt} +

+

+ {__('Stato', 'gepafin')} + {data.status} +

+
+ +
+ : <> + + + + + + + + + } +
+ ) + +} + +export default EvaluationEdit; \ No newline at end of file diff --git a/src/pages/Registration/index.js b/src/pages/Registration/index.js index eefc3d8..b3a2497 100644 --- a/src/pages/Registration/index.js +++ b/src/pages/Registration/index.js @@ -21,10 +21,12 @@ import { Button } from 'primereact/button'; import { Messages } from 'primereact/messages'; import { Panel } from 'primereact/panel'; import { Dialog } from 'primereact/dialog'; +import getDateFromISOstring from '../../helpers/getDateFromISOstring'; const Registration = () => { const token = useStore().main.token(); const [loading, setLoading] = useState(false); + const [originalDateOfBirth, setOriginalDateOfBirth] = useState('') const [visibleTerms, setVisibleTerms] = useState(false); const errorMsgs = useRef(null); let [searchParams] = useSearchParams(); @@ -43,8 +45,12 @@ const Registration = () => { errorMsgs.current.clear(); const temp_token = searchParams.get('temp_token'); setLoading(true); + const newFormData = { + ...formData, + dateOfBirth: originalDateOfBirth + } - AuthenticationService.registerUser(formData, regCallback, regError, [ + AuthenticationService.registerUser(newFormData, regCallback, regError, [ ['tempToken', temp_token] ]); }; @@ -59,7 +65,7 @@ const Registration = () => { errorMsgs.current.show([ { sticky: true, severity: 'error', summary: '', - detail: data.data.join(', '), + detail: data.data.message, closable: true } ]); @@ -81,11 +87,11 @@ const Registration = () => { const validateCallback = (data) => { if (data.status === 'SUCCESS') { const { codiceFiscale, firstName, lastName, dateOfBirth } = data.data; - const dateOfBirthObj = new Date(dateOfBirth); + setOriginalDateOfBirth(dateOfBirth); setValue('codiceFiscale', codiceFiscale); setValue('firstName', firstName); setValue('lastName', lastName); - setValue('dateOfBirth', dateOfBirthObj); + setValue('dateOfBirth', getDateFromISOstring(dateOfBirth)); } else { errorMsgs.current.show([ { @@ -102,7 +108,7 @@ const Registration = () => { errorMsgs.current.show([ { sticky: true, severity: 'error', summary: '', - detail: sprintf(__('%s', 'gepafin'), err), + detail: sprintf(__('%s', 'gepafin'), err.message), closable: true } ]); @@ -197,7 +203,7 @@ const Registration = () => { /> { errors={errors} config={{ required: __('È obbligatorio', 'gepafin'), - positive: v => parseInt(v) > 0 + pattern: /^[\d]{5,12}$/ }} placeholder="" /> diff --git a/src/pages/ResetPassword/index.js b/src/pages/ResetPassword/index.js index def5e03..a2dc5a2 100644 --- a/src/pages/ResetPassword/index.js +++ b/src/pages/ResetPassword/index.js @@ -130,7 +130,7 @@ const ResetPassword = () => { type="textinput" inputtype="password" fieldName="confirmPassword" - label={__('Conferma Password', 'gepafin')} + label={__('Conferma password', 'gepafin')} control={control} errors={errors} config={{ diff --git a/src/pages/Users/index.js b/src/pages/Users/index.js index 75b7fdd..9383e24 100644 --- a/src/pages/Users/index.js +++ b/src/pages/Users/index.js @@ -1,6 +1,17 @@ import React, { useState, useEffect } from 'react'; import { __ } from '@wordpress/i18n'; import { isEmpty, isNil } from 'ramda'; +import { klona } from 'klona'; + +// api +import UserService from '../../service/user-service'; + +// tools +import set404FromErrorResponse from '../../helpers/set404FromErrorResponse'; +import { isEmail } from '../../helpers/validators'; + +// store +import { storeSet } from '../../store'; // components import AllUsersTable from './components/AllUsersTable'; @@ -8,21 +19,19 @@ import { Button } from 'primereact/button'; import { InputText } from 'primereact/inputtext'; import { Dropdown } from 'primereact/dropdown'; import { Dialog } from 'primereact/dialog'; -import UserService from '../../service/user-service'; -import set404FromErrorResponse from '../../helpers/set404FromErrorResponse'; -import { storeSet } from '../../store'; -import { klona } from 'klona'; import { classNames } from 'primereact/utils'; -import { isEmail } from '../../helpers/validators'; const Users = () => { const [isVisibleEditDialog, setIsVisibleEditDialog] = useState(false); + const [isCreatingUserRequest, setIsCreatingUserRequest] = useState(false); const [newUserData, setNewUserData] = useState({ firstName: '', lastName: '', email: '', phoneNumber: '', - role: '' + password: '', + confPassword: '', + roleId: 0 }); const [roles, setRoles] = useState([]); @@ -41,14 +50,18 @@ const Users = () => { lastName: '', email: '', phoneNumber: '', - role: '' + password: '', + confPassword: '', + roleId: 0 }); } const saveEditDialog = () => { const emptyValues = Object.values(newUserData).filter(v => isEmpty(v)); - if (isEmpty(emptyValues)) { - console.log(newUserData) + console.log(isEmpty(emptyValues), newUserData.password === newUserData.confPassword, !isCreatingUserRequest) + if (isEmpty(emptyValues) && newUserData.password === newUserData.confPassword && !isCreatingUserRequest) { + setIsCreatingUserRequest(true); + UserService.createUser(newUserData, createUserCallback, errCreateUserCallback); } } @@ -70,7 +83,9 @@ const Users = () => { const getRolesCallback = (data) => { if (data.status === 'SUCCESS') { - const roles = data.data.map(o => ({ + const roles = data.data + .filter(o => ['ROLE_SUPER_ADMIN', 'ROLE_PRE_INSTRUCTOR'].includes(o.roleType)) + .map(o => ({ name: o.roleName, value: o.id })); @@ -84,6 +99,19 @@ const Users = () => { storeSet.main.unsetAsyncRequest(); } + const createUserCallback = (data) => { + if (data.status === 'SUCCESS') { + console.log('data.data', data.data) + } + setIsCreatingUserRequest(false); + } + + const errCreateUserCallback = (data) => { + setIsCreatingUserRequest(false); + } + + const isInvalidField = (data, key) => isEmpty(data[key]) || isNil(data[key]) + useEffect(() => { if (isVisibleEditDialog) { UserService.getRoles(getRolesCallback, errGetRolesCallback) @@ -117,39 +145,74 @@ const Users = () => {
- + onChangeEditItem(e.target.value, 'firstName')}/>
- + onChangeEditItem(e.target.value, 'lastName')}/>
- + onChangeEditItem(e.target.value, 'email')}/>
- + onChangeEditItem(e.target.value, 'phoneNumber')}/>
+
+
+ + onChangeEditItem(e.target.value, 'password')}/> +
+
+ + onChangeEditItem(e.target.value, 'confPassword')}/> +
+
- + onChangeEditItem(e.value, 'role')} + value={newUserData.roleId} + invalid={isEmpty(newUserData.roleId) || isNil(newUserData.roleId) || newUserData.roleId === 0} + onChange={(e) => onChangeEditItem(e.value, 'roleId')} options={roles} optionLabel="name" optionValue="value"/> diff --git a/src/routes.js b/src/routes.js index 8e36701..de8494f 100644 --- a/src/routes.js +++ b/src/routes.js @@ -28,6 +28,7 @@ import ResetPassword from './pages/ResetPassword'; import DashboardInstructor from './pages/DashboardInstructor'; import ProfileBeneficiario from './pages/ProfileBeneficiario'; import Evaluations from './pages/Evaluations'; +import EvaluationEdit from './pages/EvaluationEdit'; const routes = ({ role, chosenCompanyId }) => { @@ -94,6 +95,11 @@ const routes = ({ role, chosenCompanyId }) => { {'ROLE_BENEFICIARY' === role ? : null} {'ROLE_PRE_INSTRUCTOR' === role ? : null} }/> + + {'ROLE_SUPER_ADMIN' === role ? : null} + {'ROLE_BENEFICIARY' === role ? : null} + {'ROLE_PRE_INSTRUCTOR' === role ? : null} + }/> {'ROLE_SUPER_ADMIN' === role ? : null} {'ROLE_BENEFICIARY' === role ? : null} diff --git a/src/service/user-service.js b/src/service/user-service.js index c2c5f3b..e6ae3eb 100644 --- a/src/service/user-service.js +++ b/src/service/user-service.js @@ -8,6 +8,10 @@ export default class UserService { NetworkService.put(`${API_BASE_URL}/user/${id}`, body, callback, errCallback); }; + static createUser = (body, callback, errCallback) => { + NetworkService.post(`${API_BASE_URL}/user/`, body, callback, errCallback); + }; + static getRoles = (callback, errCallback) => { NetworkService.get(`${API_BASE_URL}/role`, callback, errCallback); };