- saving progress;
This commit is contained in:
@@ -1,6 +1,12 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { __ } from '@wordpress/i18n';
|
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
|
// components
|
||||||
import { Badge } from 'primereact/badge';
|
import { Badge } from 'primereact/badge';
|
||||||
@@ -10,6 +16,8 @@ import NotificationItem from './components/NotificationItem';
|
|||||||
import NotificationItemChosen from './components/NotificationItemChosen';
|
import NotificationItemChosen from './components/NotificationItemChosen';
|
||||||
|
|
||||||
const NotificationsSidebar = () => {
|
const NotificationsSidebar = () => {
|
||||||
|
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||||
|
const userData = useStore().main.userData();
|
||||||
const [activeIndex, setActiveIndex] = useState(0);
|
const [activeIndex, setActiveIndex] = useState(0);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [notificationsVisible, setNotificationsVisible] = useState(false);
|
const [notificationsVisible, setNotificationsVisible] = useState(false);
|
||||||
@@ -44,26 +52,29 @@ const NotificationsSidebar = () => {
|
|||||||
setChosenMsg({});
|
setChosenMsg({});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getNotifications = (resp) => {
|
||||||
|
console.log('resp', resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
const errGetNotifications = (resp) => {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setNotifications(() => {
|
const role = pathOr('', ['role', 'roleType'], userData);
|
||||||
const msg = {
|
|
||||||
'id': 35,
|
console.log('chosenCompanyId', chosenCompanyId, role)
|
||||||
'createdDate': '2024-12-23T14:55:27.278103',
|
if (userData.id && chosenCompanyId !== 0 && role === 'ROLE_BENEFICIARY') {
|
||||||
'updatedDate': '2024-12-23T14:55:27.278103',
|
NotificationService.getNotifications(userData.id, getNotifications, errGetNotifications, [
|
||||||
'userId': 30,
|
['status', 'UNREAD'],
|
||||||
'title': 'Il Risultato della Valutazione per la Richiesta È Disponibile',
|
['companyId', chosenCompanyId]
|
||||||
'message': 'Il risultato della valutazione per la richiesta ai sensi del protocollo n. 10000015 è ora disponibile.',
|
]);
|
||||||
'status': 'UNREAD',
|
} else if (userData.id && role !== 'ROLE_BENEFICIARY') {
|
||||||
'companyId': 103,
|
NotificationService.getNotifications(userData.id, getNotifications, errGetNotifications, [
|
||||||
'redirectUrl': 'EVALUATION_RESULT',
|
['status', 'UNREAD']
|
||||||
'notificationType': 'EVALUATION_RESULT'
|
]);
|
||||||
};
|
}
|
||||||
return Array.from({ length: 33 }, (_, index) => ({
|
}, [chosenCompanyId, userData.id]);
|
||||||
...msg,
|
|
||||||
id: msg.id + index
|
|
||||||
}));
|
|
||||||
})
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
10
src/service/notification-service.js
Normal file
10
src/service/notification-service.js
Normal file
@@ -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);
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user