Newer
Older
import { useEffect, useState } from 'react';
import {getNotifications, Notification} from "src/utils/agentUtils";
import rootStore from "src/store/rootStore";
const useNotifications = (): Notification[] => {
const [notifications, setNotifications] = useState<Notification[]>([]);
const fetchNotifications = async () => {
const data = await getNotifications(rootStore.agentStore.agent);
setNotifications(data);
}
useEffect(() => {
const interval = setInterval(fetchNotifications, 2000);
return () => clearInterval(interval);
}, []);
return notifications;
};
export default useNotifications;