- saving progress;
This commit is contained in:
@@ -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 (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user