import React, { Fragment } from "react"; // hooks import useTheme from "hooks/use-theme"; import { Popover, Transition } from "@headlessui/react"; // hooks import useUserNotification from "hooks/use-user-notifications"; // components import { Loader, EmptyState, Tooltip } from "components/ui"; import { SnoozeNotificationModal, NotificationCard, NotificationHeader, } from "components/notifications"; // icons import { NotificationsOutlined } from "@mui/icons-material"; // images import emptyNotification from "public/empty-state/notification.svg"; // helpers import { getNumberCount } from "helpers/string.helper"; // mobx store import { useMobxStore } from "lib/mobx/store-provider"; export const NotificationPopover = () => { const store: any = useMobxStore(); const { notifications, archived, readNotification, selectedNotificationForSnooze, selectedTab, setArchived, setReadNotification, setSelectedNotificationForSnooze, setSelectedTab, setSnoozed, snoozed, notificationMutate, markNotificationArchivedStatus, markNotificationReadStatus, markNotificationAsRead, markSnoozeNotification, notificationCount, totalNotificationCount, setSize, isLoadingMore, hasMore, isRefreshing, setFetchNotifications, } = useUserNotification(); // theme context const { collapsed: sidebarCollapse } = useTheme(); return ( <> setSelectedNotificationForSnooze(null)} onSubmit={markSnoozeNotification} notification={ notifications?.find( (notification) => notification.id === selectedNotificationForSnooze ) || null } onSuccess={() => { setSelectedNotificationForSnooze(null); }} /> {({ open: isActive, close: closePopover }) => { if (isActive) setFetchNotifications(true); return ( <> {store?.theme?.sidebarCollapsed ? null : Notifications} {totalNotificationCount && totalNotificationCount > 0 ? ( {getNumberCount(totalNotificationCount)} ) : null} {notifications ? ( notifications.length > 0 ? (
{notifications.map((notification) => ( ))}
{isLoadingMore && (
Loading...

Loading notifications

)} {hasMore && !isLoadingMore && ( )}
) : (
) ) : ( )}
); }}
); };