import useOpenable from "@Front/Hooks/useOpenable"; import Toasts, { IToast } from "@Front/Stores/Toasts"; import { BellIcon } from "@heroicons/react/24/outline"; import React, { useEffect, useState } from "react"; import IconButton from "../../IconButton"; import classes from "./classes.module.scss"; import NotificationModal from "./NotificationModal"; export default function Notifications() { const [_toastList, setToastList] = useState(Toasts.getInstance().toasts); const [hasNotifications, setHasNotifications] = useState(Toasts.getInstance().toasts.length > 0); const { isOpen, close, toggle } = useOpenable(); useEffect(() => { const handleToastChange = (newToastList: IToast[] | null) => { setToastList(newToastList); setHasNotifications(newToastList ? newToastList.length > 0 : false); }; const removeOnToastChange = Toasts.getInstance().onChange(handleToastChange); return () => { removeOnToastChange(); }; }, []); return (
{hasNotifications ? ( } onClick={toggle} /> ) : ( } onClick={toggle} /> )}
); } function BellNotifIcon() { return ( ); }