make website run
This commit is contained in:
@@ -4,10 +4,6 @@ import React, { useState, useEffect, useRef } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import Link from 'next/link';
|
||||
import { useEffectiveDriverId } from '@/lib/currentDriver';
|
||||
import {
|
||||
getNotificationRepository,
|
||||
getMarkNotificationReadUseCase,
|
||||
} from '@/lib/di-container';
|
||||
import type { Notification } from '@core/notifications/application';
|
||||
import {
|
||||
Bell,
|
||||
@@ -52,23 +48,24 @@ export default function NotificationCenter() {
|
||||
const currentDriverId = useEffectiveDriverId();
|
||||
|
||||
// Polling for new notifications
|
||||
useEffect(() => {
|
||||
const loadNotifications = async () => {
|
||||
try {
|
||||
const repo = getNotificationRepository();
|
||||
const allNotifications = await repo.findByRecipientId(currentDriverId);
|
||||
setNotifications(allNotifications);
|
||||
} catch (error) {
|
||||
console.error('Failed to load notifications:', error);
|
||||
}
|
||||
};
|
||||
// TODO
|
||||
// useEffect(() => {
|
||||
// const loadNotifications = async () => {
|
||||
// try {
|
||||
// const repo = getNotificationRepository();
|
||||
// const allNotifications = await repo.findByRecipientId(currentDriverId);
|
||||
// setNotifications(allNotifications);
|
||||
// } catch (error) {
|
||||
// console.error('Failed to load notifications:', error);
|
||||
// }
|
||||
// };
|
||||
|
||||
loadNotifications();
|
||||
// loadNotifications();
|
||||
|
||||
// Poll every 5 seconds
|
||||
const interval = setInterval(loadNotifications, 5000);
|
||||
return () => clearInterval(interval);
|
||||
}, [currentDriverId]);
|
||||
// // Poll every 5 seconds
|
||||
// const interval = setInterval(loadNotifications, 5000);
|
||||
// return () => clearInterval(interval);
|
||||
// }, [currentDriverId]);
|
||||
|
||||
// Close panel when clicking outside
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user