From 73b319ea9cd471277cf0c5100e557042d70be2f0 Mon Sep 17 00:00:00 2001
From: Vitalii Kiiko
Date: Mon, 23 Dec 2024 09:44:42 +0100
Subject: [PATCH 1/7] - save progress;
---
.../components/AppTopbar/index.js | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/layouts/DefaultLayout/components/AppTopbar/index.js b/src/layouts/DefaultLayout/components/AppTopbar/index.js
index af1e9a8..27c3a6b 100644
--- a/src/layouts/DefaultLayout/components/AppTopbar/index.js
+++ b/src/layouts/DefaultLayout/components/AppTopbar/index.js
@@ -1,4 +1,4 @@
-import React, { useRef } from 'react';
+import React, { useRef, useState } from 'react';
import { __ } from '@wordpress/i18n';
// components
@@ -11,9 +11,11 @@ import { InputText } from 'primereact/inputtext';
import { Badge } from 'primereact/badge';
import { Button } from 'primereact/button';
import TopBarProfileMenu from '../../../../components/TopBarProfileMenu';
+import { Sidebar } from 'primereact/sidebar';
const AppTopbar = () => {
const menuLeft = useRef(null);
+ const [notificationsVisible, setNotificationsVisible] = useState(false);
const startContent =
@@ -42,8 +44,19 @@ const AppTopbar = () => {
return (
-
+ <>
+
+ setNotificationsVisible(false)} fullScreen>
+ Sidebar
+
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore
+ et dolore magna aliqua.
+ Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
+ consequat.
+
+
+ >
)
}
-export default AppTopbar;
\ No newline at end of file
+export default AppTopbar;
From bb983feb1248bc1c5ff6d380ef77c7e38b6da9aa Mon Sep 17 00:00:00 2001
From: Vitalii Kiiko
Date: Tue, 24 Dec 2024 14:50:20 +0100
Subject: [PATCH 2/7] - added sidebar container for notifications; - styles and
interactions for notifications;
---
.../scss/components/notificationsSidebar.scss | 55 ++++++++
src/assets/scss/theme.scss | 3 +-
.../components/NotificationItem/index.js | 19 +++
.../NotificationItemChosen/index.js | 22 ++++
src/components/NotificationsSidebar/index.js | 121 ++++++++++++++++++
.../components/AppTopbar/index.js | 24 +---
6 files changed, 224 insertions(+), 20 deletions(-)
create mode 100644 src/assets/scss/components/notificationsSidebar.scss
create mode 100644 src/components/NotificationsSidebar/components/NotificationItem/index.js
create mode 100644 src/components/NotificationsSidebar/components/NotificationItemChosen/index.js
create mode 100644 src/components/NotificationsSidebar/index.js
diff --git a/src/assets/scss/components/notificationsSidebar.scss b/src/assets/scss/components/notificationsSidebar.scss
new file mode 100644
index 0000000..2bc2eb8
--- /dev/null
+++ b/src/assets/scss/components/notificationsSidebar.scss
@@ -0,0 +1,55 @@
+.notificationsIcon {
+ &:hover {
+ cursor: pointer;
+ }
+}
+
+.notificationsSidebar {
+ max-width: 360px;
+ width: 100%;
+}
+
+.notificationsSidebar__loading {
+ padding: 30px 0;
+ display: flex;
+ justify-content: center;
+ flex-direction: column;
+ align-items: center;
+ gap: 10px;
+}
+
+.notificationsSidebar__list {
+ display: flex;
+ flex-direction: column;
+ gap: 5px;
+ list-style: none;
+ padding: 0;
+}
+
+.notificationsSidebar__listItem {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ gap: 5px;
+ padding: 15px 0;
+ border-bottom: 1px solid #e7e7e7;
+
+ &:hover {
+ cursor: pointer;
+ color: var(--primary-text);
+ }
+}
+
+.notificationsSidebar__listItemContent {
+ display: flex;
+ flex-direction: column;
+ gap: 5px;
+ font-size: 14px;
+}
+
+.notificationsSidebar__listItemChosen {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 5px;
+}
diff --git a/src/assets/scss/theme.scss b/src/assets/scss/theme.scss
index 4ad1ef5..2b48f72 100644
--- a/src/assets/scss/theme.scss
+++ b/src/assets/scss/theme.scss
@@ -44,4 +44,5 @@
@import "./components/error404.scss";
@import "./components/myTable.scss";
@import "./components/evaluation.scss";
-@import "./components/fieldsRepeater.scss";
\ No newline at end of file
+@import "./components/fieldsRepeater.scss";
+@import "./components/notificationsSidebar.scss";
diff --git a/src/components/NotificationsSidebar/components/NotificationItem/index.js b/src/components/NotificationsSidebar/components/NotificationItem/index.js
new file mode 100644
index 0000000..df13bc0
--- /dev/null
+++ b/src/components/NotificationsSidebar/components/NotificationItem/index.js
@@ -0,0 +1,19 @@
+import React from 'react';
+
+const NotificationItem = ({ item, clickFn }) => {
+ const handleClick = () => {
+ clickFn(item.id);
+ }
+
+ return (
+
+
+ {item.title}
+ {item.createdDate}
+
+
+
+ )
+}
+
+export default NotificationItem;
diff --git a/src/components/NotificationsSidebar/components/NotificationItemChosen/index.js b/src/components/NotificationsSidebar/components/NotificationItemChosen/index.js
new file mode 100644
index 0000000..4821df3
--- /dev/null
+++ b/src/components/NotificationsSidebar/components/NotificationItemChosen/index.js
@@ -0,0 +1,22 @@
+import React from 'react';
+import { __ } from '@wordpress/i18n';
+import { Button } from 'primereact/button';
+
+const NotificationItemChosen = ({ item, closeFn }) => {
+ return (
+
+
+ {item.title}
+ {item.createdDate}
+ {item.message}
+
+ )
+}
+
+export default NotificationItemChosen;
diff --git a/src/components/NotificationsSidebar/index.js b/src/components/NotificationsSidebar/index.js
new file mode 100644
index 0000000..55b08f5
--- /dev/null
+++ b/src/components/NotificationsSidebar/index.js
@@ -0,0 +1,121 @@
+import React, { useEffect, useState } from 'react';
+import { __ } from '@wordpress/i18n';
+import { head, isEmpty } from 'ramda';
+
+// components
+import { Badge } from 'primereact/badge';
+import { Sidebar } from 'primereact/sidebar';
+import { TabPanel, TabView } from 'primereact/tabview';
+import NotificationItem from './components/NotificationItem';
+import NotificationItemChosen from './components/NotificationItemChosen';
+
+const NotificationsSidebar = () => {
+ const [activeIndex, setActiveIndex] = useState(0);
+ const [loading, setLoading] = useState(false);
+ const [notificationsVisible, setNotificationsVisible] = useState(false);
+ const [notifications, setNotifications] = useState([]);
+ const [notificationsRead, setNotificationsRead] = useState([]);
+ const [chosenMsg, setChosenMsg] = useState({});
+
+ // Handle tab change
+ const handleTabChange = (e) => {
+ setActiveIndex(e.index);
+ fetchTabData(e.index);
+ };
+
+ const fetchTabData = (index) => {
+ setChosenMsg({});
+ console.log('fetchTabData', index);
+ setLoading(true);
+ setTimeout(() => {
+ setLoading(false);
+ }, 7000)
+ }
+
+ const chooseNotification = (id) => {
+ const properItems = activeIndex === 0 ? notifications : notificationsRead;
+ const chosen = head(properItems.filter(o => o.id === id));
+ if (chosen) {
+ setChosenMsg(chosen);
+ }
+ }
+
+ const closeChosenMsg = () => {
+ setChosenMsg({});
+ }
+
+ useEffect(() => {
+ setNotifications(() => {
+ const msg = {
+ 'id': 35,
+ 'createdDate': '2024-12-23T14:55:27.278103',
+ 'updatedDate': '2024-12-23T14:55:27.278103',
+ 'userId': 30,
+ 'title': 'Il Risultato della Valutazione per la Richiesta È Disponibile',
+ 'message': 'Il risultato della valutazione per la richiesta ai sensi del protocollo n. 10000015 è ora disponibile.',
+ 'status': 'UNREAD',
+ 'companyId': 103,
+ 'redirectUrl': 'EVALUATION_RESULT',
+ 'notificationType': 'EVALUATION_RESULT'
+ };
+ return Array.from({ length: 33 }, (_, index) => ({
+ ...msg,
+ id: msg.id + index
+ }));
+ })
+ }, []);
+
+ return (
+ <>
+ setNotificationsVisible(true)}>
+
+
+ setNotificationsVisible(false)}>
+
+
+ {loading
+ ?
+
+
+ : !isEmpty(chosenMsg)
+ ?
+ : (notifications.length > 0
+ ?
+ {notifications.map(o => )}
+
+ :
+
+ {__('Vuoto', 'gepafin')}
+
)}
+
+
+ {loading
+ ?
+
+
+ : !isEmpty(chosenMsg)
+ ?
+ : (notificationsRead.length > 0
+ ?
+ {notificationsRead.map(o => )}
+
+ :
+
+
+ {__('Vuoto', 'gepafin')}
+
)}
+
+
+
+ >
+ )
+}
+
+export default NotificationsSidebar;
diff --git a/src/layouts/DefaultLayout/components/AppTopbar/index.js b/src/layouts/DefaultLayout/components/AppTopbar/index.js
index 27c3a6b..8bb75b4 100644
--- a/src/layouts/DefaultLayout/components/AppTopbar/index.js
+++ b/src/layouts/DefaultLayout/components/AppTopbar/index.js
@@ -1,4 +1,4 @@
-import React, { useRef, useState } from 'react';
+import React, { useRef } from 'react';
import { __ } from '@wordpress/i18n';
// components
@@ -8,14 +8,12 @@ import LogoIcon from '../../../../icons/LogoIcon';
import { IconField } from 'primereact/iconfield';
import { InputIcon } from 'primereact/inputicon';
import { InputText } from 'primereact/inputtext';
-import { Badge } from 'primereact/badge';
import { Button } from 'primereact/button';
import TopBarProfileMenu from '../../../../components/TopBarProfileMenu';
-import { Sidebar } from 'primereact/sidebar';
+import NotificationsSidebar from '../../../../components/NotificationsSidebar';
const AppTopbar = () => {
const menuLeft = useRef(null);
- const [notificationsVisible, setNotificationsVisible] = useState(false);
const startContent =
@@ -26,14 +24,13 @@ const AppTopbar = () => {
-
-
-
+
{/*
*/}
menuLeft.current.toggle(event)} aria-controls="topBar_profileMenu" aria-haspopup>
@@ -44,18 +41,7 @@ const AppTopbar = () => {
return (
- <>
-
- setNotificationsVisible(false)} fullScreen>
- Sidebar
-
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore
- et dolore magna aliqua.
- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
- consequat.
-
-
- >
+
)
}
From 3ff69de35d7f42dc7ccbb519debf41bd9d7b0e22 Mon Sep 17 00:00:00 2001
From: Vitalii Kiiko
Date: Fri, 27 Dec 2024 14:38:06 +0100
Subject: [PATCH 3/7] - fixed access for evaluation page; - changed labels;
---
src/assets/scss/components/appPage.scss | 23 +-
.../DomandaEditInstructorManager/index.js | 961 ++++++++++++++++++
src/pages/DomandaEditPreInstructor/index.js | 6 +-
.../components/AllDomandeTable/index.js | 14 +-
.../BeneficiarioDomandeTable/index.js | 4 +-
src/pages/SoccorsoAddPreInstructor/index.js | 4 +-
src/pages/SoccorsoEditBeneficiario/index.js | 8 +-
src/pages/SoccorsoEditPreInstructor/index.js | 2 +-
.../PreInstructorSoccorsiTable/index.js | 6 +-
src/routes.js | 7 +
10 files changed, 1002 insertions(+), 33 deletions(-)
create mode 100644 src/pages/DomandaEditInstructorManager/index.js
diff --git a/src/assets/scss/components/appPage.scss b/src/assets/scss/components/appPage.scss
index 9d3de37..7d782b3 100644
--- a/src/assets/scss/components/appPage.scss
+++ b/src/assets/scss/components/appPage.scss
@@ -11,7 +11,7 @@
font-weight: 600;
line-height: normal;
}
-
+
.appPageLogin__wrapper {
h1 {
text-align: center;
@@ -89,6 +89,7 @@
}
.appPageSection {
+ position: relative;
display: flex;
flex-direction: column;
align-items: flex-start;
@@ -99,7 +100,7 @@
gap: 1rem;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
width: 100%;
-
+
/*> div {
max-width: 50%;
}*/
@@ -130,7 +131,7 @@
padding: 5px 0;
width: 100%;
}
-
+
.col {
display: flex;
flex-direction: column;
@@ -188,7 +189,7 @@
ul, ol {
padding-left: 1rem;
-
+
li {
color: var(--global-textColor);
}
@@ -217,7 +218,7 @@
.appPageSection__pMeta {
margin-bottom: 1em;
-
+
span:nth-of-type(1) {
max-width: 30%;
}
@@ -263,7 +264,7 @@
display: flex;
flex-direction: column;
gap: 1.2rem;
-
+
div {
display: flex;
gap: 0.5rem;
@@ -294,11 +295,11 @@
color: var(--message-info-color);
border-color: var(--message-info-color);
}
-
+
.summary {
font-weight: bold;
}
-
+
a {
color: inherit;
}
@@ -401,7 +402,7 @@
gap: 10px;
align-items: center;
flex-wrap: wrap;
-
+
&.lessGap {
gap: 12px;
}
@@ -418,7 +419,7 @@
background-color: transparent;
color: var(--global-textColor);
padding: 0;
-
+
&:hover {
cursor: pointer;
color: var(--message-info-color);
@@ -440,4 +441,4 @@
grid-template-columns: 1fr;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/pages/DomandaEditInstructorManager/index.js b/src/pages/DomandaEditInstructorManager/index.js
new file mode 100644
index 0000000..589dab1
--- /dev/null
+++ b/src/pages/DomandaEditInstructorManager/index.js
@@ -0,0 +1,961 @@
+import React, { useState, useEffect, useRef, useCallback } from 'react';
+import { __, sprintf } from '@wordpress/i18n';
+import { useNavigate, useParams } from 'react-router-dom';
+import { is, isEmpty, isNil, sum, pathOr, head } from 'ramda';
+import { klona } from 'klona';
+import { wrap } from 'object-path-immutable';
+
+// store
+import { storeGet, storeSet, useStore } from '../../store';
+
+// api
+import ApplicationEvaluationService from '../../service/application-evaluation-service';
+import AmendmentsService from '../../service/amendments-service';
+import AppointmentService from '../../service/appointment-service';
+
+// tools
+import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
+import getBandoLabel from '../../helpers/getBandoLabel';
+import getDateFromISOstring from '../../helpers/getDateFromISOstring';
+
+// components
+import { Skeleton } from 'primereact/skeleton';
+import { Button } from 'primereact/button';
+import { Tag } from 'primereact/tag';
+import { Checkbox } from 'primereact/checkbox';
+import { Editor } from 'primereact/editor';
+import { InputNumber } from 'primereact/inputnumber';
+import { Toast } from 'primereact/toast';
+import { Dialog } from 'primereact/dialog';
+import HelpIcon from '../../icons/HelpIcon';
+import BlockingOverlay from '../../components/BlockingOverlay';
+import { classNames } from 'primereact/utils';
+import { InputTextarea } from 'primereact/inputtextarea';
+import { InputText } from 'primereact/inputtext';
+import DownloadApplicationArchive from '../DomandaEditPreInstructor/components/DownloadApplicationArchive';
+import DownloadCompanyDelegation from '../DomandaEditPreInstructor/components/DownloadCompanyDelegation';
+import DownloadSignedApplication from '../DomandaEditPreInstructor/components/DownloadSignedApplication';
+import ListOfFiles from '../DomandaEditPreInstructor/components/ListOfFiles';
+import RepeaterFields from '../DomandaEditPreInstructor/components/RepeaterFields';
+
+const APP_EVALUATION_FLOW_ID = process.env.REACT_APP_EVALUATION_FLOW_ID;
+
+const DomandaEditPreInstructor = () => {
+ const isAsyncRequest = useStore().main.isAsyncRequest();
+ const { id } = useParams();
+ const navigate = useNavigate();
+ const [data, setData] = useState({});
+ const [isVisibleCriterionData, setIsVisibleCriterionData] = useState(0);
+ const [criterionDataTitle, setCriterionDataTitle] = useState('');
+ const [criterionDataContent, setCriterionDataContent] = useState('');
+ const [isAdmissible, setIsAdmissible] = useState(false);
+ const [connectedSoccorsoId, setConnectedSoccorsoId] = useState(0);
+ const toast = useRef(null);
+ const [loading, setLoading] = useState(false);
+ const [isVisibleCompleteDialog, setIsVisibleCompleteDialog] = useState(false);
+ const [operationType, setOperationType] = useState('');
+ const [motivation, setMotivation] = useState('');
+ const [isVisibleAppointmentDialog, setIsVisibleAppointmentDialog] = useState(false);
+ const [allFilesRated, setAllFilesRated] = useState(false);
+ const [atLeastOneChecked, setAtLeastOneChecked] = useState(false);
+ const [allChecksChecked, setAllChecksChecked] = useState(false);
+ const [appointmentData, setAppointmentData] = useState({
+ title: '',
+ text: '',
+ duration: 0,
+ amount: 0
+ });
+
+ const goToEvaluationsPage = () => {
+ navigate('/domande');
+ }
+
+ const updateFlagsForSoccorso = (data) => {
+ let nonRatedFilesLength = 0;
+
+ if (data.files) {
+ const nonRatedFiles = data.files
+ .map(el => el.valid)
+ .filter(v => isNil(v));
+ nonRatedFilesLength = nonRatedFiles.length;
+ }
+
+ if (data.amendmentDetails) {
+ const nonRatedFiles = data.amendmentDetails
+ .map(el => el.valid)
+ .filter(v => isNil(v));
+ nonRatedFilesLength = nonRatedFiles.length;
+ }
+
+ setAllFilesRated(nonRatedFilesLength === 0);
+
+ if (data.checklist) {
+ const checkedChecklistItems = data.checklist
+ .map(el => el.valid)
+ .filter(v => v);
+ setAtLeastOneChecked(checkedChecklistItems.length > 0);
+ setAllChecksChecked(checkedChecklistItems.length === data.checklist.length)
+ }
+ }
+
+ const doNewSoccorso = () => {
+ if (connectedSoccorsoId !== 0) {
+ navigate(`/domande/${id}/soccorso/${connectedSoccorsoId}`);
+ } else {
+ doSaveDraft(`/domande/${id}/aggiungi-soccorso/`)
+ }
+ }
+
+ const getCallback = (data) => {
+ if (data.status === 'SUCCESS') {
+ setData(getFormattedData(data.data));
+ setMotivation(data.data.motivation);
+ updateFlagsForSoccorso(data.data);
+ }
+ storeSet.main.unsetAsyncRequest();
+ }
+
+ const errGetCallback = (data) => {
+ if (toast.current && data.message) {
+ toast.current.show({
+ severity: 'error',
+ summary: '',
+ detail: data.message
+ });
+ }
+ set404FromErrorResponse(data);
+ storeSet.main.unsetAsyncRequest();
+ }
+
+ const getFormattedData = (data) => {
+ data.submissionDate = is(String, data.submissionDate) ? new Date(data.submissionDate) : (data.submissionDate ? data.submissionDate : '');
+ data.evaluationDate = is(String, data.evaluationDate) ? new Date(data.evaluationDate) : (data.evaluationDate ? data.evaluationDate : '');
+ return data;
+ };
+
+ const renderHeader = () => {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+ };
+
+ const header = renderHeader();
+
+ const updateEvaluationValue = (value, path, maxValue = null) => {
+ let finalValue = value;
+
+ if (maxValue || maxValue === 0) {
+ finalValue = value > maxValue ? maxValue : value;
+ }
+
+ const newData = wrap(data).set(path, finalValue).value();
+ setData(newData);
+ updateFlagsForSoccorso(newData);
+ }
+
+ const doSaveDraft = useCallback((doRedirect = '') => {
+ const formData = {
+ criteria: klona(data.criteria),
+ checklist: klona(data.checklist),
+ files: klona(data.files),
+ evaluationDocument: klona(data.evaluationDocument.map(o => ({
+ ...o,
+ fileValue: o.fileValue[0] ? o.fileValue[0].id : ''
+ })
+ )),
+ amendmentDetails: klona(data.amendmentDetails),
+ note: data.note
+ }
+
+ ApplicationEvaluationService.updateEvaluation(
+ data.assignedApplicationId,
+ formData,
+ (data) => updateCallback(data, doRedirect),
+ errUpdateCallback
+ );
+ }, [data]);
+
+ const updateCallback = (data, doRedirect = '') => {
+ if (data.status === 'SUCCESS') {
+ setData(getFormattedData(data.data));
+ if (toast.current) {
+ toast.current.show({
+ severity: 'success',
+ summary: '',
+ detail: data.message
+ });
+ }
+ if (!isEmpty(doRedirect)) {
+ navigate(doRedirect);
+ }
+ }
+ storeSet.main.unsetAsyncRequest();
+ }
+
+ const errUpdateCallback = (data) => {
+ if (toast.current && data.message) {
+ toast.current.show({
+ severity: 'error',
+ summary: '',
+ detail: data.message
+ });
+ }
+ set404FromErrorResponse(data);
+ storeSet.main.unsetAsyncRequest();
+ }
+
+ const doApprove = () => {
+ const formData = {
+ applicationStatus: 'APPROVED',
+ criteria: klona(data.criteria),
+ checklist: klona(data.checklist),
+ files: klona(data.files),
+ note: data.note,
+ motivation
+ }
+
+ setIsVisibleCompleteDialog(false);
+ ApplicationEvaluationService.updateEvaluation(data.assignedApplicationId, formData, updateStatusCallback, errUpdateStatusCallback);
+ }
+
+ const doReject = () => {
+ const formData = {
+ applicationStatus: 'REJECTED',
+ criteria: klona(data.criteria),
+ checklist: klona(data.checklist),
+ files: klona(data.files),
+ note: data.note,
+ motivation
+ }
+
+ setIsVisibleCompleteDialog(false);
+ ApplicationEvaluationService.updateEvaluation(data.assignedApplicationId, formData, updateStatusCallback, errUpdateStatusCallback);
+ }
+
+ const updateStatusCallback = (data) => {
+ if (data.status === 'SUCCESS') {
+ setData(getFormattedData(data.data));
+ if (toast.current) {
+ toast.current.show({
+ severity: 'success',
+ summary: '',
+ detail: data.message
+ });
+ }
+ }
+ storeSet.main.unsetAsyncRequest();
+ }
+
+ const errUpdateStatusCallback = (data) => {
+ if (toast.current && data.message) {
+ toast.current.show({
+ severity: 'error',
+ summary: '',
+ detail: data.message
+ });
+ }
+ set404FromErrorResponse(data);
+ storeSet.main.unsetAsyncRequest();
+ }
+
+ const displayCriterionData = (id) => {
+ const criterion = head(data.criteria.filter(o => o.id === id));
+ setCriterionDataTitle(criterion.label);
+ const content =
+
{__('I campi correlati')}
+ {criterion.criteriaMappedFields ? criterion.criteriaMappedFields.map(o => criteriaDataItem(o)) : null}
+
;
+ setCriterionDataContent(content);
+ setIsVisibleCriterionData(id);
+ }
+
+ const criteriaDataItem = (item) => {
+ let content = '';
+
+ switch (item.fieldName) {
+ case 'fileupload' :
+ content =
+ {item.fieldValue
+ ? item.fieldValue.map(o =>
+ {o.filePath ? {o.name} : null}
+ )
+ : null}
+ ;
+ break;
+ case 'table' :
+ const th = Object.keys(item.fieldValue[0]);
+ content =
+
+
+ {th.map(v => {v} )}
+
+
+
+ {item.fieldValue
+ ? item.fieldValue.map((o, i) =>
+ {Object.values(o).map(v => {v} )}
+ )
+ : null}
+
+
;
+ break;
+ default :
+ content = item.fieldValue;
+ break;
+ }
+
+ return
+ {item.fieldLabel}
+ {content}
+
+ }
+
+ const hideCriterionData = () => {
+ setIsVisibleCriterionData(0);
+ setCriterionDataTitle('');
+ setCriterionDataContent('');
+ }
+
+ const getAmendmentsCallback = (data) => {
+ if (data.status === 'SUCCESS') {
+ if (data.data.length) {
+ setConnectedSoccorsoId(data.data[0].id);
+ }
+ }
+ }
+
+ const errGetAmendmentsCallback = () => {
+ if (toast.current && data.message) {
+ toast.current.show({
+ severity: 'error',
+ summary: '',
+ detail: data.message
+ });
+ }
+ set404FromErrorResponse(data);
+ }
+
+ const shouldDisableField = (fieldName) => {
+ return !['EVALUATION'].includes(data.applicationStatus)
+ || (['ADMISSIBLE'].includes(data.applicationStatus) && fieldName !== 'criteria')
+ }
+
+ const headerCompleteDialog = () => {
+ return 'approve' === operationType
+ ? {__('Confermare l\'approvazione', 'gepafin')}
+ : {__('Confermare il rifiuto', 'gepafin')} ;
+ }
+
+ const hideCompleteDialog = () => {
+ setIsVisibleCompleteDialog(false);
+ setOperationType('');
+ setMotivation('');
+ }
+
+ const footerCompleteDialog = () => {
+ return
+
+
+
+ }
+
+ const initiateApproving = () => {
+ setOperationType('approve');
+ setIsVisibleCompleteDialog(true);
+
+ }
+
+ const initiateRejecting = () => {
+ setOperationType('reject');
+ setIsVisibleCompleteDialog(true);
+ }
+
+ const doCheckNDG = () => {
+ storeSet.main.setAsyncRequest();
+ doSaveDraft();
+ setTimeout(() => {
+ AppointmentService.getNdg(id, getNdgCallback, errGetNdgCallback);
+ }, 100);
+ }
+
+ const getNdgCallback = (data) => {
+ if (data.status === 'SUCCESS') {
+ if (toast.current && data.message) {
+ toast.current.show({
+ severity: 'success',
+ summary: '',
+ detail: data.message
+ });
+ }
+ }
+ storeSet.main.unsetAsyncRequest();
+ }
+
+ const errGetNdgCallback = (data) => {
+ if (toast.current && data.message) {
+ toast.current.show({
+ severity: data.status === 'SUCCESS' ? 'info' : 'error',
+ summary: '',
+ detail: data.message
+ });
+ }
+ set404FromErrorResponse(data);
+ storeSet.main.unsetAsyncRequest();
+ }
+
+ const doCreateAppointment = () => {
+ setAppointmentData({
+ title: '',
+ text: '',
+ duration: 0,
+ amount: 0
+ });
+ setIsVisibleAppointmentDialog(true);
+ }
+
+ const setValue = (name, value) => {
+ const newData = wrap(appointmentData).set(name, value).value();
+ setAppointmentData(newData);
+ }
+
+ const headerAppointmentDialog = () => {
+ return {__('Crea appuntamento', 'gepafin')} ;
+ }
+
+ const hideAppointmentDialog = () => {
+ setIsVisibleAppointmentDialog(false);
+ setAppointmentData({});
+ }
+
+ const footerAppointmentDialog = () => {
+ return
+
+
+
+ }
+
+ const doCreateAppointmentRequest = () => {
+ if (
+ !isEmpty(appointmentData.title) && !isEmpty(appointmentData.text) && !isEmpty(appointmentData.amount)
+ && !isEmpty(appointmentData.duration) && appointmentData.duration !== 0 && appointmentData.amount !== 0
+ ) {
+ storeSet.main.setAsyncRequest();
+ const submitData = {
+ 'importoBreveTermine': appointmentData.amount,
+ 'durataMesiFinanziamento': appointmentData.duration,
+ 'nota': {
+ 'titolo': appointmentData.title,
+ 'testo': appointmentData.text
+ }
+ }
+
+ AppointmentService.createAppointment(id, submitData, getAppointemntCallback, errGetAppointemntCallback);
+ }
+ }
+
+ const getAppointemntCallback = (data) => {
+ if (data.status === 'SUCCESS') {
+ if (toast.current && data.message) {
+ toast.current.show({
+ severity: 'success',
+ summary: '',
+ detail: data.message
+ });
+ }
+ }
+ setIsVisibleAppointmentDialog(false);
+ storeSet.main.unsetAsyncRequest();
+ }
+
+ const errGetAppointemntCallback = (data) => {
+ if (toast.current && data.message) {
+ toast.current.show({
+ severity: data.status === 'SUCCESS' ? 'info' : 'error',
+ summary: '',
+ detail: data.message
+ });
+ }
+ setIsVisibleAppointmentDialog(false);
+ set404FromErrorResponse(data);
+ storeSet.main.unsetAsyncRequest();
+ }
+
+ const doMakeAdmisible = () => {
+ // TODO
+ }
+
+ const evaluationShouldBeBlocked = (data = {}) => {
+ const userData = storeGet.main.userData()
+ return isAsyncRequest || userData.id !== data.assignedUserId;
+ }
+
+ useEffect(() => {
+ const maxScore = pathOr(0, ['minScore'], data);
+ const criteria = pathOr([], ['criteria'], data);
+ const scoreSum = sum(criteria.map(o => o.score));
+
+ setIsAdmissible(scoreSum !== 0 && scoreSum >= maxScore);
+ }, [data]);
+
+ useEffect(() => {
+ const parsed = parseInt(id)
+ const entityId = !isNaN(parsed) ? parsed : 0;
+
+ storeSet.main.setAsyncRequest();
+ ApplicationEvaluationService.getEvaluationByApplId(getCallback, errGetCallback, [
+ ['applicationId', entityId]
+ ]);
+ AmendmentsService.getSoccorsoByApplId(entityId, getAmendmentsCallback, errGetAmendmentsCallback, [
+ ['statuses', 'AWAITING']
+ ]);
+ }, [id]);
+
+ return (
+
+
+
{__('Valuta domanda', 'gepafin')}
+
+
+
+
+
+
+
+
+
+
+
+ {!isAsyncRequest && !isEmpty(data)
+ ?
+
+
+ {__('ID domanda', 'gepafin')}
+ {data.applicationId}
+
+
+ {__('Protocollo', 'gepafin')}
+ {data.protocolNumber}
+
+
+ {__('NDG', 'gepafin')}
+ {data.ndg}
+
+
+ {__('Appuntamento', 'gepafin')}
+ {data.appointmentId}
+
+
+ {__('Bando', 'gepafin')}
+ {data.callName}
+
+
+ {__('Referente Aziendale', 'gepafin')}
+ {data.beneficiary}
+
+
+ {__('Azienda Beneficiaria', 'gepafin')}
+ {data.companyName}
+
+
+ {__('Data ricezione', 'gepafin')}
+ {getDateFromISOstring(data.submissionDate)}
+
+
+ {__('Data assegnazione', 'gepafin')}
+ {getDateFromISOstring(data.assignedAt)}
+
+
+ {__('Scadenza Valutazione', 'gepafin')}
+ {getDateFromISOstring(data.evaluationEndDate)}
+
+
+ {__('Stato', 'gepafin')}
+ {getBandoLabel(data.applicationStatus)}
+
+
+
+
+
{__('Scarica documenti della domanda', 'gepafin')}
+
+
+
+
+
+
+
+
+
{__('Documenti aggiuntivi', 'gepafin')}
+ updateEvaluationValue(
+ data,
+ ['evaluationDocument']
+ )}
+ shouldDisable={['APPROVED', 'REJECTED'].includes(data.applicationStatus) || evaluationShouldBeBlocked(data)}
+ sourceId={data.assignedApplicationId}
+ sourceName="evaluation"/>
+
+
+
+
{__('Checklist Valutazione', 'gepafin')}
+
+
+
{__('Lista', 'gepafin')}
+
+
+ {data.checklist.map((o, i) =>
+ updateEvaluationValue(
+ e.checked,
+ ['checklist', i, 'valid']
+ )}
+ checked={o.valid}>
+ {o.label}
+
)}
+
+
+
+
{__('Note', 'gepafin')}
+
+ updateEvaluationValue(
+ e.htmlValue,
+ ['note']
+ )}
+ style={{ height: 80 * 3, width: '100%' }}
+ />
+
+
+
+
{__('Documenti allegati', 'gepafin')}
+ shouldDisableField(name) || evaluationShouldBeBlocked(data)}
+ name="files"
+ ndg={data.ndg}
+ applicationId={id}/>
+
+
+
+
+ {!isEmpty(data.amendmentDetails)
+ ?
+
{__('Documenti di soccorso', 'gepafin')}
+ shouldDisableField(name) || evaluationShouldBeBlocked(data)}
+ name="amendmentDetails"
+ ndg={data.ndg}
+ applicationId={id}/>
+ : null}
+
+
+
{__('Punteggi di valutazione', 'gepafin')}
+ {data.criteria
+ ?
+
+
+ {__('Parametro', 'gepafin')}
+ {__('Punteggio', 'gepafin')}
+ {__('Stato', 'gepafin')}
+
+
+
+ {data.criteria.map((o, i) =>
+ {o.label}
+
+
+ updateEvaluationValue(
+ e.value,
+ ['criteria', i, 'score'],
+ o.criteria
+ )}/>
+
+ / {o.maxScore}
+
+
+
+
+
+ {!isEmpty(o.criteriaMappedFields)
+ ? displayCriterionData(o.id)}
+ aria-label={__('Mostra', 'gepafin')}/> : null}
+ updateEvaluationValue(
+ true,
+ ['criteria', i, 'valid']
+ )}
+ aria-label={__('Su', 'gepafin')}/>
+ updateEvaluationValue(
+ false,
+ ['criteria', i, 'valid']
+ )}
+ aria-label={__('Giu', 'gepafin')}/>
+
+
+ )}
+
+ {__('Punteggio:', 'gepafin')}
+ {sum(data.criteria.map(o => o.score))}
+
+ {isAdmissible
+ ? : null}
+ {!isAdmissible
+ ? : null}
+
+
+
+
+
+ {sprintf(__('Punteggio minimo per l\'ammissione: %d'), data.minScore)}
+
+
+
: null}
+
+
+
+
+
+ {__('Azioni rapide', 'gepafin')}
+
+
+
+
+ {['EVALUATION', 'SOCCORSO', 'CLOSE'].includes(data.applicationStatus)
+ ?
+ {data.applicationStatus === 'EVALUATION'
+ ? __('Richiedi Soccorso Istruttorio', 'gepafin')
+ : __('Apri Soccorso Istruttorio', 'gepafin')}
+
+
+
+ >}
+ /> : null}
+ {data.id
+ ? doSaveDraft()}
+ outlined
+ label={__('Salva bozza valutazione', 'gepafin')}
+ icon="pi pi-save" iconPos="right"/>
+ : doSaveDraft()}
+ label={__('Crea valutazione', 'gepafin')}
+ icon="pi pi-save" iconPos="right"/>}
+ {/*{APP_EVALUATION_FLOW_ID === '1' && ['EVALUATION'].includes(data.applicationStatus)
+ ? : null}*/}
+ {}}
+ label={__('Controlla NDG', 'gepafin')}
+ />
+ {/*{APP_EVALUATION_FLOW_ID === '1' && ['NDG'].includes(data.applicationStatus) && data.ndg
+ ? : null}*/}
+ {}}
+ label={__('Crea l\'appuntamento', 'gepafin')}
+ />
+ {/*{APP_EVALUATION_FLOW_ID === '1' && ['APPOINTMENT'].includes(data.applicationStatus)
+ ? : null}*/}
+ {}}
+ label={__('Ammissibile', 'gepafin')}
+ />
+ {data.id
+ ? : null}
+ {/*{data.id
+ ? : null}*/}
+ {data.id
+ ? : null}
+
+
+
+
+ {criterionDataContent}
+
+
+
+
+ {__('Motivazione', 'gepafin')}
+ setMotivation(e.htmlValue)}
+ style={{ height: 80 * 3, width: '100%' }}
+ />
+
+
+
+
+
+
+ {__('Importo', 'gepafin')}
+
+ setValue('amount', e.value)}/>
+
+
+
+ {__('Durata', 'gepafin')}
+
+ setValue('duration', e.value)}/>
+
+
+
+ {__('Titolo', 'gepafin')}
+
+ setValue('title', e.target.value)}/>
+
+
+
+ {__('Messaggio', 'gepafin')}
+
+ setValue('text', e.target.value)}
+ rows={3}
+ cols={30}/>
+
+
+
+
+ : <>
+
+
+
+
+
+
+
+
+ >}
+
+ )
+
+}
+
+export default DomandaEditPreInstructor;
diff --git a/src/pages/DomandaEditPreInstructor/index.js b/src/pages/DomandaEditPreInstructor/index.js
index df7742c..9c2c517 100644
--- a/src/pages/DomandaEditPreInstructor/index.js
+++ b/src/pages/DomandaEditPreInstructor/index.js
@@ -568,11 +568,11 @@ const DomandaEditPreInstructor = () => {
{data.callName}
- {__('Beneficiario', 'gepafin')}
+ {__('Referente Aziendale', 'gepafin')}
{data.beneficiary}
- {__('Azienda', 'gepafin')}
+ {__('Azienda Beneficiaria', 'gepafin')}
{data.companyName}
@@ -934,4 +934,4 @@ const DomandaEditPreInstructor = () => {
}
-export default DomandaEditPreInstructor;
\ No newline at end of file
+export default DomandaEditPreInstructor;
diff --git a/src/pages/Domande/components/AllDomandeTable/index.js b/src/pages/Domande/components/AllDomandeTable/index.js
index 8505ff8..6159a66 100644
--- a/src/pages/Domande/components/AllDomandeTable/index.js
+++ b/src/pages/Domande/components/AllDomandeTable/index.js
@@ -139,7 +139,7 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => {
?
: null}
-
+
@@ -165,7 +165,7 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => {
filter sortable
filterPlaceholder={__('Cerca', 'gepafin')}
style={{ minWidth: '10rem' }}/>
-
@@ -173,10 +173,10 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => {
filterField="submissionDate" dataType="date"
style={{ minWidth: '8rem' }}
body={dateAppliedBodyTemplate} filter filterElement={dateFilterTemplate}/>
- {/**/}
+
{
)
}
-export default AllDomandeTable;
\ No newline at end of file
+export default AllDomandeTable;
diff --git a/src/pages/DomandeBeneficiario/components/BeneficiarioDomandeTable/index.js b/src/pages/DomandeBeneficiario/components/BeneficiarioDomandeTable/index.js
index 1469191..23f988b 100644
--- a/src/pages/DomandeBeneficiario/components/BeneficiarioDomandeTable/index.js
+++ b/src/pages/DomandeBeneficiario/components/BeneficiarioDomandeTable/index.js
@@ -165,7 +165,7 @@ const BeneficiarioDomandeTable = () => {
filter sortable
filterPlaceholder={__('Cerca il nome', 'gepafin')}
style={{ minWidth: '8rem' }}/>
-
@@ -184,4 +184,4 @@ const BeneficiarioDomandeTable = () => {
)
}
-export default BeneficiarioDomandeTable;
\ No newline at end of file
+export default BeneficiarioDomandeTable;
diff --git a/src/pages/SoccorsoAddPreInstructor/index.js b/src/pages/SoccorsoAddPreInstructor/index.js
index bfb4745..dca2bfe 100644
--- a/src/pages/SoccorsoAddPreInstructor/index.js
+++ b/src/pages/SoccorsoAddPreInstructor/index.js
@@ -185,7 +185,7 @@ const SoccorsoAddPreInstructor = () => {
{data.callName}
- {__('Beneficiario', 'gepafin')}
+ {__('Referente Aziendale', 'gepafin')}
{data.beneficiaryName}
@@ -308,4 +308,4 @@ const SoccorsoAddPreInstructor = () => {
}
-export default SoccorsoAddPreInstructor;
\ No newline at end of file
+export default SoccorsoAddPreInstructor;
diff --git a/src/pages/SoccorsoEditBeneficiario/index.js b/src/pages/SoccorsoEditBeneficiario/index.js
index 21da492..ba7cc0a 100644
--- a/src/pages/SoccorsoEditBeneficiario/index.js
+++ b/src/pages/SoccorsoEditBeneficiario/index.js
@@ -275,11 +275,11 @@ const SoccorsoEditBeneficiario = () => {
{data.callName}
- {__('Beneficiario', 'gepafin')}
+ {__('Referente Aziendale', 'gepafin')}
{data.beneficiaryName}
- {__('Azienda', 'gepafin')}
+ {__('Azienda Beneficiaria', 'gepafin')}
@@ -306,7 +306,7 @@ const SoccorsoEditBeneficiario = () => {
{dataAppl.callTitle}
- {__('Azienda', 'gepafin')}
+ {__('Azienda Beneficiaria', 'gepafin')}
{dataAppl.companyName}
@@ -462,4 +462,4 @@ const SoccorsoEditBeneficiario = () => {
}
-export default SoccorsoEditBeneficiario;
\ No newline at end of file
+export default SoccorsoEditBeneficiario;
diff --git a/src/pages/SoccorsoEditPreInstructor/index.js b/src/pages/SoccorsoEditPreInstructor/index.js
index 54922dc..2201c20 100644
--- a/src/pages/SoccorsoEditPreInstructor/index.js
+++ b/src/pages/SoccorsoEditPreInstructor/index.js
@@ -392,7 +392,7 @@ const SoccorsoEditPreInstructor = () => {
{data.callName}
- {__('Beneficiario', 'gepafin')}
+ {__('Referente Aziendale', 'gepafin')}
{data.beneficiaryName}
diff --git a/src/pages/SoccorsoIstruttorioPreInstructor/components/PreInstructorSoccorsiTable/index.js b/src/pages/SoccorsoIstruttorioPreInstructor/components/PreInstructorSoccorsiTable/index.js
index e509e43..87cba6b 100644
--- a/src/pages/SoccorsoIstruttorioPreInstructor/components/PreInstructorSoccorsiTable/index.js
+++ b/src/pages/SoccorsoIstruttorioPreInstructor/components/PreInstructorSoccorsiTable/index.js
@@ -78,7 +78,7 @@ const PreInstructorSoccorsiTable = ({ openDialogFn }) => {
operator: FilterOperator.AND,
constraints: [{ value: null, matchMode: FilterMatchMode.STARTS_WITH }]
},
- beneficiaryName: {
+ companyName: {
operator: FilterOperator.AND,
constraints: [{ value: null, matchMode: FilterMatchMode.STARTS_WITH }]
},
@@ -149,7 +149,7 @@ const PreInstructorSoccorsiTable = ({ openDialogFn }) => {
-
{
)
}
-export default PreInstructorSoccorsiTable;
\ No newline at end of file
+export default PreInstructorSoccorsiTable;
diff --git a/src/routes.js b/src/routes.js
index 8b753fc..97be510 100644
--- a/src/routes.js
+++ b/src/routes.js
@@ -38,6 +38,7 @@ import SoccorsoEditBeneficiario from './pages/SoccorsoEditBeneficiario';
import BandoApplicationPreview from './pages/BandoApplicationPreview';
import BandiPreferredBeneficiario from './pages/BandiPreferredBeneficiario';
import DomandeInstructorManager from './pages/DomandeInstructorManager';
+import DomandaEditInstructorManager from './pages/DomandaEditInstructorManager';
const routes = ({ role, chosenCompanyId }) => {
@@ -114,6 +115,12 @@ const routes = ({ role, chosenCompanyId }) => {
{'ROLE_SUPER_ADMIN' === role ? : null}
{'ROLE_BENEFICIARY' === role ? : null}
{'ROLE_PRE_INSTRUCTOR' === role ? : null}
+ {'ROLE_INSTRUCTOR_MANAGER' === role ? : null}
+ }/>
+
+ {'ROLE_SUPER_ADMIN' === role ? : null}
+ {'ROLE_BENEFICIARY' === role ? : null}
+ {'ROLE_PRE_INSTRUCTOR' === role ? : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? : null}
}/>
From 0fddd871908944bd3253a268497cda8e3fc1ec2e Mon Sep 17 00:00:00 2001
From: Vitalii Kiiko
Date: Fri, 27 Dec 2024 17:00:13 +0100
Subject: [PATCH 4/7] - saving progress;
---
src/components/NotificationsSidebar/index.js | 51 ++++++++++++--------
src/service/notification-service.js | 10 ++++
2 files changed, 41 insertions(+), 20 deletions(-)
create mode 100644 src/service/notification-service.js
diff --git a/src/components/NotificationsSidebar/index.js b/src/components/NotificationsSidebar/index.js
index 55b08f5..1a690ee 100644
--- a/src/components/NotificationsSidebar/index.js
+++ b/src/components/NotificationsSidebar/index.js
@@ -1,6 +1,12 @@
import React, { useEffect, useState } from 'react';
import { __ } from '@wordpress/i18n';
-import { head, isEmpty } from 'ramda';
+import { head, isEmpty, pathOr } from 'ramda';
+
+// store
+import { storeGet, useStore } from '../../store';
+
+// api
+import NotificationService from '../../service/notification-service';
// components
import { Badge } from 'primereact/badge';
@@ -10,6 +16,8 @@ import NotificationItem from './components/NotificationItem';
import NotificationItemChosen from './components/NotificationItemChosen';
const NotificationsSidebar = () => {
+ const chosenCompanyId = useStore().main.chosenCompanyId();
+ const userData = useStore().main.userData();
const [activeIndex, setActiveIndex] = useState(0);
const [loading, setLoading] = useState(false);
const [notificationsVisible, setNotificationsVisible] = useState(false);
@@ -44,26 +52,29 @@ const NotificationsSidebar = () => {
setChosenMsg({});
}
+ const getNotifications = (resp) => {
+ console.log('resp', resp);
+ }
+
+ const errGetNotifications = (resp) => {
+
+ }
+
useEffect(() => {
- setNotifications(() => {
- const msg = {
- 'id': 35,
- 'createdDate': '2024-12-23T14:55:27.278103',
- 'updatedDate': '2024-12-23T14:55:27.278103',
- 'userId': 30,
- 'title': 'Il Risultato della Valutazione per la Richiesta È Disponibile',
- 'message': 'Il risultato della valutazione per la richiesta ai sensi del protocollo n. 10000015 è ora disponibile.',
- 'status': 'UNREAD',
- 'companyId': 103,
- 'redirectUrl': 'EVALUATION_RESULT',
- 'notificationType': 'EVALUATION_RESULT'
- };
- return Array.from({ length: 33 }, (_, index) => ({
- ...msg,
- id: msg.id + index
- }));
- })
- }, []);
+ const role = pathOr('', ['role', 'roleType'], userData);
+
+ console.log('chosenCompanyId', chosenCompanyId, role)
+ if (userData.id && chosenCompanyId !== 0 && role === 'ROLE_BENEFICIARY') {
+ NotificationService.getNotifications(userData.id, getNotifications, errGetNotifications, [
+ ['status', 'UNREAD'],
+ ['companyId', chosenCompanyId]
+ ]);
+ } else if (userData.id && role !== 'ROLE_BENEFICIARY') {
+ NotificationService.getNotifications(userData.id, getNotifications, errGetNotifications, [
+ ['status', 'UNREAD']
+ ]);
+ }
+ }, [chosenCompanyId, userData.id]);
return (
<>
diff --git a/src/service/notification-service.js b/src/service/notification-service.js
new file mode 100644
index 0000000..cd33e34
--- /dev/null
+++ b/src/service/notification-service.js
@@ -0,0 +1,10 @@
+import { NetworkService } from './network-service';
+
+const API_BASE_URL = process.env.REACT_APP_API_EXECUTION_ADDRESS;
+
+export default class NotificationService {
+
+ static getNotifications = (id, callback, errCallback, queryParams) => {
+ NetworkService.get(`${API_BASE_URL}/notification/user/${id}`, callback, errCallback, queryParams);
+ };
+}
From d15933f04325eafb8a9ec3bea22b27ec2e46ceeb Mon Sep 17 00:00:00 2001
From: Vitalii Kiiko
Date: Mon, 30 Dec 2024 15:03:32 +0100
Subject: [PATCH 5/7] - implemneted API for notifications; - added styles for
notifications; - added email template to amendment page;
---
src/assets/scss/components/appPage.scss | 9 ++
.../components/NotificationItem/index.js | 7 +-
.../NotificationItemChosen/index.js | 12 +-
src/components/NotificationsSidebar/index.js | 115 ++++++++++++++----
src/helpers/getStrippedHtmlBodyTags.js | 28 +++++
.../components/RepeaterFields/index.js | 2 +-
src/pages/SoccorsoEditBeneficiario/index.js | 6 +-
src/pages/SoccorsoEditPreInstructor/index.js | 35 +++---
src/service/notification-service.js | 12 ++
9 files changed, 171 insertions(+), 55 deletions(-)
create mode 100644 src/helpers/getStrippedHtmlBodyTags.js
diff --git a/src/assets/scss/components/appPage.scss b/src/assets/scss/components/appPage.scss
index 9d3de37..4f98387 100644
--- a/src/assets/scss/components/appPage.scss
+++ b/src/assets/scss/components/appPage.scss
@@ -434,6 +434,15 @@
}
}
+.appPageSection__emailTemplate {
+ > div {
+ max-width: 100%!important;
+ > div {
+ max-width: 100%!important;
+ }
+ }
+}
+
@media (max-width: 700px) {
.appPageSection {
&.columns {
diff --git a/src/components/NotificationsSidebar/components/NotificationItem/index.js b/src/components/NotificationsSidebar/components/NotificationItem/index.js
index df13bc0..3d2efc5 100644
--- a/src/components/NotificationsSidebar/components/NotificationItem/index.js
+++ b/src/components/NotificationsSidebar/components/NotificationItem/index.js
@@ -1,4 +1,5 @@
import React from 'react';
+import getDateFromISOstring from '../../../../helpers/getDateFromISOstring';
const NotificationItem = ({ item, clickFn }) => {
const handleClick = () => {
@@ -8,8 +9,10 @@ const NotificationItem = ({ item, clickFn }) => {
return (
-
{item.title}
-
{item.createdDate}
+ {item.status === 'READ'
+ ?
{item.title}
+ :
{item.title} }
+
{getDateFromISOstring(item.createdDate)}
diff --git a/src/components/NotificationsSidebar/components/NotificationItemChosen/index.js b/src/components/NotificationsSidebar/components/NotificationItemChosen/index.js
index 4821df3..4588de6 100644
--- a/src/components/NotificationsSidebar/components/NotificationItemChosen/index.js
+++ b/src/components/NotificationsSidebar/components/NotificationItemChosen/index.js
@@ -1,8 +1,9 @@
import React from 'react';
import { __ } from '@wordpress/i18n';
import { Button } from 'primereact/button';
+import getDateFromISOstring from '../../../../helpers/getDateFromISOstring';
-const NotificationItemChosen = ({ item, closeFn }) => {
+const NotificationItemChosen = ({ item, closeFn, markReadFn }) => {
return (
{
label={__('Indietro', 'gepafin')}
icon="pi pi-arrow-left" iconPos="left"/>
{item.title}
- {item.createdDate}
+ {getDateFromISOstring(item.createdDate)}
{item.message}
+
+ markReadFn(item.id)}
+ label={__('Letto', 'gepafin')}/>
)
}
diff --git a/src/components/NotificationsSidebar/index.js b/src/components/NotificationsSidebar/index.js
index 1a690ee..7e1d919 100644
--- a/src/components/NotificationsSidebar/index.js
+++ b/src/components/NotificationsSidebar/index.js
@@ -8,6 +8,9 @@ import { storeGet, useStore } from '../../store';
// api
import NotificationService from '../../service/notification-service';
+// tools
+import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
+
// components
import { Badge } from 'primereact/badge';
import { Sidebar } from 'primereact/sidebar';
@@ -33,11 +36,12 @@ const NotificationsSidebar = () => {
const fetchTabData = (index) => {
setChosenMsg({});
- console.log('fetchTabData', index);
- setLoading(true);
- setTimeout(() => {
- setLoading(false);
- }, 7000)
+
+ if (0 === index) {
+ fetchMessages();
+ } else {
+ fetchMessages('READ');
+ }
}
const chooseNotification = (id) => {
@@ -52,28 +56,79 @@ const NotificationsSidebar = () => {
setChosenMsg({});
}
+ const fetchMessages = (status = 'UNREAD') => {
+ const chosenCompanyId = storeGet.main.chosenCompanyId();
+ const userData = storeGet.main.userData();
+ const role = pathOr('', ['role', 'roleType'], userData);
+
+ if (userData.id && chosenCompanyId !== 0 && role === 'ROLE_BENEFICIARY') {
+ setLoading(true);
+ NotificationService.getNotifications(
+ userData.id,
+ status === 'UNREAD' ? getNotifications : getNotificationsRead,
+ errGetNotifications,
+ [
+ ['status', status],
+ ['companyId', chosenCompanyId]
+ ]
+ );
+ } else if (userData.id && role !== 'ROLE_BENEFICIARY') {
+ setLoading(true);
+ NotificationService.getNotifications(
+ userData.id,
+ status === 'UNREAD' ? getNotifications : getNotificationsRead,
+ errGetNotifications,
+ [
+ ['status', status]
+ ]
+ );
+ }
+ }
+
const getNotifications = (resp) => {
- console.log('resp', resp);
+ if (resp.status === 'SUCCESS') {
+ setNotifications(resp.data);
+ }
+ set404FromErrorResponse(resp);
+ setLoading(false);
+ }
+
+ const getNotificationsRead = (resp) => {
+ if (resp.status === 'SUCCESS') {
+ setNotificationsRead(resp.data);
+ }
+ set404FromErrorResponse(resp);
+ setLoading(false);
}
const errGetNotifications = (resp) => {
+ set404FromErrorResponse(resp);
+ setLoading(false);
+ }
+ const makeNotificationRead = (id) => {
+ NotificationService.notificationMakeRead(id, makeReadCallback, makeReadErrorCallback)
+ }
+
+ const makeReadCallback = (resp) => {
+ if (resp.status === 'SUCCESS') {
+ if (0 === activeIndex) {
+ const msgs = notifications.map(o => o.id === resp.data.id ? resp.data : o);
+ setNotifications(msgs);
+ } else {
+ const msgs = notificationsRead.map(o => o.id === resp.data.id ? resp.data : o);
+ setNotificationsRead(msgs);
+ }
+ }
+ set404FromErrorResponse(resp);
+ }
+
+ const makeReadErrorCallback = (resp) => {
+ set404FromErrorResponse(resp);
}
useEffect(() => {
- const role = pathOr('', ['role', 'roleType'], userData);
-
- console.log('chosenCompanyId', chosenCompanyId, role)
- if (userData.id && chosenCompanyId !== 0 && role === 'ROLE_BENEFICIARY') {
- NotificationService.getNotifications(userData.id, getNotifications, errGetNotifications, [
- ['status', 'UNREAD'],
- ['companyId', chosenCompanyId]
- ]);
- } else if (userData.id && role !== 'ROLE_BENEFICIARY') {
- NotificationService.getNotifications(userData.id, getNotifications, errGetNotifications, [
- ['status', 'UNREAD']
- ]);
- }
+ fetchMessages();
}, [chosenCompanyId, userData.id]);
return (
@@ -94,11 +149,16 @@ const NotificationsSidebar = () => {
: !isEmpty(chosenMsg)
- ?
+ ?
: (notifications.length > 0
?
- {notifications.map(o => )}
+ {notifications.map(o => )}
:
@@ -111,11 +171,16 @@ const NotificationsSidebar = () => {
: !isEmpty(chosenMsg)
- ?
+ ?
: (notificationsRead.length > 0
?
- {notificationsRead.map(o => )}
+ {notificationsRead.map(o => )}
:
diff --git a/src/helpers/getStrippedHtmlBodyTags.js b/src/helpers/getStrippedHtmlBodyTags.js
new file mode 100644
index 0000000..59c4315
--- /dev/null
+++ b/src/helpers/getStrippedHtmlBodyTags.js
@@ -0,0 +1,28 @@
+import parse from 'html-react-parser';
+import DOMPurify from 'dompurify';
+
+const getEmailTemplateForSoccorso = (content = '', fallback = '') => {
+ const config = {
+ FORBID_TAGS: ['html', 'body'],
+ WHOLE_DOCUMENT: false,
+ RETURN_DOM: false,
+ RETURN_DOM_FRAGMENT: false,
+ RETURN_DOM_IMPORT: false,
+ FORCE_BODY: false,
+ ADD_TAGS: ['*'],
+ ADD_ATTR: ['*']
+ };
+ try {
+ const wrappedHtml = `
${content}
`;
+ const cleaned = DOMPurify.sanitize(wrappedHtml, config);
+
+ const tempDiv = document.createElement('div');
+ tempDiv.innerHTML = cleaned;
+ return parse(tempDiv.innerHTML);
+ } catch (error) {
+ console.error('DOMPurify cleaning error:', error);
+ return fallback;
+ }
+}
+
+export default getEmailTemplateForSoccorso;
\ No newline at end of file
diff --git a/src/pages/DomandaEditPreInstructor/components/RepeaterFields/index.js b/src/pages/DomandaEditPreInstructor/components/RepeaterFields/index.js
index d6249d9..36564c5 100644
--- a/src/pages/DomandaEditPreInstructor/components/RepeaterFields/index.js
+++ b/src/pages/DomandaEditPreInstructor/components/RepeaterFields/index.js
@@ -138,7 +138,7 @@ const RepeaterFields = ({
className="fieldsRepeater__addNew"
outlined
type="button"
- disabled={watchFields && watchFields.filter(o => isEmpty(o.nameValue) || isEmpty(o.fileValue)).length > 0 || shouldDisable}
+ disabled={(watchFields && watchFields.filter(o => isEmpty(o.nameValue) || isEmpty(o.fileValue)).length > 0) || shouldDisable}
onClick={addNew}
label={__('Aggiungi nuovo file', 'gepafin')}
/>
diff --git a/src/pages/SoccorsoEditBeneficiario/index.js b/src/pages/SoccorsoEditBeneficiario/index.js
index 21da492..4a88264 100644
--- a/src/pages/SoccorsoEditBeneficiario/index.js
+++ b/src/pages/SoccorsoEditBeneficiario/index.js
@@ -27,6 +27,7 @@ import { Dialog } from 'primereact/dialog';
import FormField from '../../components/FormField';
import SoccorsoComunications from '../SoccorsoEditPreInstructor/components/SoccorsoComunications';
import { Editor } from 'primereact/editor';
+import getEmailTemplateForSoccorso from '../../helpers/getStrippedHtmlBodyTags';
const SoccorsoEditBeneficiario = () => {
const isAsyncRequest = useStore().main.isAsyncRequest();
@@ -327,10 +328,7 @@ const SoccorsoEditBeneficiario = () => {
?
{__('Dettagli Richiesta', 'gepafin')}
{__('Note e spiegazioni', 'gepafin')}
-
- {renderHtmlContent(data.note)}
-
+
{getEmailTemplateForSoccorso(data.emailTemplate, data.note)}
: null}
{data.id
diff --git a/src/pages/SoccorsoEditPreInstructor/index.js b/src/pages/SoccorsoEditPreInstructor/index.js
index 54922dc..f6aad62 100644
--- a/src/pages/SoccorsoEditPreInstructor/index.js
+++ b/src/pages/SoccorsoEditPreInstructor/index.js
@@ -16,7 +16,7 @@ import AmendmentsService from '../../service/amendments-service';
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
import getBandoLabel from '../../helpers/getBandoLabel';
import getDateFromISOstring from '../../helpers/getDateFromISOstring';
-import renderHtmlContent from '../../helpers/renderHtmlContent';
+import getEmailTemplateForSoccorso from '../../helpers/getStrippedHtmlBodyTags';
// components
import { Button } from 'primereact/button';
@@ -411,26 +411,19 @@ const SoccorsoEditPreInstructor = () => {
{__('Dettagli Richiesta', 'gepafin')}
-
-
-
{__('Documenti Richiesti', 'gepafin')}
-
- {data.formFields
- ? data.formFields.map((o, i) =>
- {o.label}
- ) : null}
-
-
-
-
{__('Note e spiegazioni', 'gepafin')}
-
- {renderHtmlContent(data.note)}
-
-
-
-
+
{__('Note e spiegazioni', 'gepafin')}
+
{getEmailTemplateForSoccorso(data.emailTemplate, data.note)}
+
+
+
{__('Documenti Richiesti', 'gepafin')}
+
+ {data.formFields
+ ? data.formFields.map((o, i) =>
+ {o.label}
+ ) : null}
+
diff --git a/src/service/notification-service.js b/src/service/notification-service.js
index cd33e34..c3457b2 100644
--- a/src/service/notification-service.js
+++ b/src/service/notification-service.js
@@ -7,4 +7,16 @@ export default class NotificationService {
static getNotifications = (id, callback, errCallback, queryParams) => {
NetworkService.get(`${API_BASE_URL}/notification/user/${id}`, callback, errCallback, queryParams);
};
+
+ static notificationMakeRead = (id, callback, errCallback) => {
+ NetworkService.put(`${API_BASE_URL}/notification/${id}`, {}, callback, errCallback, [
+ ['status', 'READ']
+ ]);
+ };
+
+ static notificationMakeUnread = (id, callback, errCallback) => {
+ NetworkService.put(`${API_BASE_URL}/notification/${id}`, {}, callback, errCallback, [
+ ['status', 'UNREAD']
+ ]);
+ };
}
From 4ac111d94a495e94ad286f79409d25c7dd6099ee Mon Sep 17 00:00:00 2001
From: Vitalii Kiiko
Date: Tue, 31 Dec 2024 12:12:35 +0100
Subject: [PATCH 6/7] - updates;
---
.env | 1 +
package.json | 2 +
src/components/NotificationsSidebar/index.js | 91 ++++++++++++++++++--
3 files changed, 89 insertions(+), 5 deletions(-)
diff --git a/.env b/.env
index fc25010..871e4c5 100644
--- a/.env
+++ b/.env
@@ -1,6 +1,7 @@
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_API_ADDRESS_WS=https://api-dev-gepafin.memento.credit/wss
REACT_APP_LOGO_FILENAME=gepafin-logo.svg
REACT_APP_FAVICON_FILENAME=gepafin-favicon.ico
REACT_APP_HUB_ID=p4lk3bcx1RStqTaIVVbXs
diff --git a/package.json b/package.json
index e58a0a4..0783782 100644
--- a/package.json
+++ b/package.json
@@ -10,6 +10,7 @@
"@emotion/styled": "11.13.0",
"@number-flow/react": "0.4.2",
"@sentry/browser": "^8.42.0",
+ "@stomp/stompjs": "^7.0.0",
"@tanstack/react-table": "^8.20.5",
"@wordpress/i18n": "5.8.0",
"@wordpress/react-i18n": "4.8.0",
@@ -36,6 +37,7 @@
"react-hook-form": "7.53.0",
"react-router-dom": "6.26.2",
"react-scripts": "5.0.1",
+ "sockjs-client": "^1.6.1",
"validate.js": "0.13.1",
"zustand": "4.5.4",
"zustand-x": "3.0.4"
diff --git a/src/components/NotificationsSidebar/index.js b/src/components/NotificationsSidebar/index.js
index 1a690ee..58c91ee 100644
--- a/src/components/NotificationsSidebar/index.js
+++ b/src/components/NotificationsSidebar/index.js
@@ -1,9 +1,11 @@
-import React, { useEffect, useState } from 'react';
+import React, { useEffect, useRef, useState } from 'react';
import { __ } from '@wordpress/i18n';
import { head, isEmpty, pathOr } from 'ramda';
+import SockJS from 'sockjs-client';
+import { Stomp } from '@stomp/stompjs';
// store
-import { storeGet, useStore } from '../../store';
+import { useStore } from '../../store';
// api
import NotificationService from '../../service/notification-service';
@@ -15,6 +17,8 @@ import { TabPanel, TabView } from 'primereact/tabview';
import NotificationItem from './components/NotificationItem';
import NotificationItemChosen from './components/NotificationItemChosen';
+const socketUrl = process.env.REACT_APP_API_ADDRESS_WS;
+
const NotificationsSidebar = () => {
const chosenCompanyId = useStore().main.chosenCompanyId();
const userData = useStore().main.userData();
@@ -24,6 +28,10 @@ const NotificationsSidebar = () => {
const [notifications, setNotifications] = useState([]);
const [notificationsRead, setNotificationsRead] = useState([]);
const [chosenMsg, setChosenMsg] = useState({});
+ const socket = useRef(null);
+ const stomp = useRef(null);
+ const [currentSubscription, setCurrentSubscription] = useState(null);
+ const [isConnected, setIsConnected] = useState(false);
// Handle tab change
const handleTabChange = (e) => {
@@ -60,21 +68,94 @@ const NotificationsSidebar = () => {
}
+ const connectWebSocket = () => {
+ socket.current = new SockJS(socketUrl);
+ stomp.current = Stomp.over(socket.current);
+
+ stomp.current.configure({
+ debug: function(str) {
+ //console.log(str);
+ },
+ reconnectDelay: 5000,
+ heartbeatIncoming: 20000,
+ heartbeatOutgoing: 20000
+ });
+
+ stomp.current.connect(
+ {},
+ () => {
+ // connected
+ console.log('Websocket connected');
+ setIsConnected(true);
+ },
+ (error) => {
+ console.error('WebSocket Connection Error:', error);
+ setIsConnected(false);
+ setTimeout(connectWebSocket, 5000);
+ }
+ );
+ };
+
+ const subscribeTo = (topic) => {
+ const subscription = stomp.current.subscribe(
+ topic,
+ (message) => {
+ try {
+ const notification = JSON.parse(message.body);
+ console.log('notification', notification)
+ //setNotifications(prev => [notification, ...prev]);
+ } catch (error) {
+ console.error('Error parsing notification:', error);
+ }
+ }
+ );
+
+ setCurrentSubscription(subscription);
+ }
+
useEffect(() => {
const role = pathOr('', ['role', 'roleType'], userData);
+ if (currentSubscription) {
+ currentSubscription.unsubscribe();
+ setCurrentSubscription(null);
+ }
+
console.log('chosenCompanyId', chosenCompanyId, role)
- if (userData.id && chosenCompanyId !== 0 && role === 'ROLE_BENEFICIARY') {
+ if (isConnected && userData.id && chosenCompanyId !== 0 && role === 'ROLE_BENEFICIARY') {
NotificationService.getNotifications(userData.id, getNotifications, errGetNotifications, [
['status', 'UNREAD'],
['companyId', chosenCompanyId]
]);
- } else if (userData.id && role !== 'ROLE_BENEFICIARY') {
+ if (socket.current) {
+ subscribeTo(`/topic/notifications_user_${userData.id}_company_${chosenCompanyId}`)
+ }
+ } else if (isConnected && userData.id && role !== 'ROLE_BENEFICIARY') {
NotificationService.getNotifications(userData.id, getNotifications, errGetNotifications, [
['status', 'UNREAD']
]);
+ if (socket.current) {
+ subscribeTo(`/topic/notifications_user_${userData.id}`)
+ }
}
- }, [chosenCompanyId, userData.id]);
+ }, [chosenCompanyId, userData.id, isConnected]);
+
+ useEffect(() => {
+ connectWebSocket();
+
+ return () => {
+ if (currentSubscription) {
+ currentSubscription.unsubscribe();
+ setCurrentSubscription(null);
+ }
+
+ if (stomp.current) {
+ stomp.current.disconnect(() => {
+ console.log('WebSocket Disconnected');
+ });
+ }
+ };
+ }, []);
return (
<>
From 8e2976f9b5546aecbddcaeda4d9a897e35c5259c Mon Sep 17 00:00:00 2001
From: Vitalii Kiiko
Date: Tue, 31 Dec 2024 12:42:39 +0100
Subject: [PATCH 7/7] :
---
src/pages/DomandaEditInstructorManager/index.js | 1 -
src/pages/SoccorsoEditBeneficiario/index.js | 1 -
2 files changed, 2 deletions(-)
diff --git a/src/pages/DomandaEditInstructorManager/index.js b/src/pages/DomandaEditInstructorManager/index.js
index 589dab1..99793aa 100644
--- a/src/pages/DomandaEditInstructorManager/index.js
+++ b/src/pages/DomandaEditInstructorManager/index.js
@@ -28,7 +28,6 @@ import { InputNumber } from 'primereact/inputnumber';
import { Toast } from 'primereact/toast';
import { Dialog } from 'primereact/dialog';
import HelpIcon from '../../icons/HelpIcon';
-import BlockingOverlay from '../../components/BlockingOverlay';
import { classNames } from 'primereact/utils';
import { InputTextarea } from 'primereact/inputtextarea';
import { InputText } from 'primereact/inputtext';
diff --git a/src/pages/SoccorsoEditBeneficiario/index.js b/src/pages/SoccorsoEditBeneficiario/index.js
index 6e4b9d7..df40a50 100644
--- a/src/pages/SoccorsoEditBeneficiario/index.js
+++ b/src/pages/SoccorsoEditBeneficiario/index.js
@@ -17,7 +17,6 @@ import ApplicationService from '../../service/application-service';
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
import getBandoLabel from '../../helpers/getBandoLabel';
import getDateFromISOstring from '../../helpers/getDateFromISOstring';
-import renderHtmlContent from '../../helpers/renderHtmlContent';
// components
import { Button } from 'primereact/button';