- saving progress;

This commit is contained in:
Vitalii Kiiko
2024-12-27 17:00:13 +01:00
parent e165b50371
commit 0fddd87190
2 changed files with 41 additions and 20 deletions

View File

@@ -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 (
<>

View 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);
};
}