import React, { Fragment } from "react"; import { useRouter } from "next/router"; // hooks import useTheme from "hooks/use-theme"; import { Popover, Transition } from "@headlessui/react"; // hooks import useWorkspaceMembers from "hooks/use-workspace-members"; import useUserNotification from "hooks/use-user-notifications"; // components import { Icon, Loader, EmptyState, Tooltip } from "components/ui"; import { SnoozeNotificationModal, NotificationCard } 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"; // type import type { NotificationType } from "types"; export const NotificationPopover = () => { const { notifications, archived, readNotification, selectedNotificationForSnooze, selectedTab, setArchived, setReadNotification, setSelectedNotificationForSnooze, setSelectedTab, setSnoozed, snoozed, notificationsMutate, markNotificationArchivedStatus, markNotificationReadStatus, markSnoozeNotification, notificationCount, totalNotificationCount, } = useUserNotification(); const router = useRouter(); const { workspaceSlug } = router.query; const { isOwner, isMember } = useWorkspaceMembers(workspaceSlug?.toString() ?? ""); // theme context const { collapsed: sidebarCollapse } = useTheme(); const notificationTabs: Array<{ label: string; value: NotificationType; unreadCount?: number; }> = [ { label: "My Issues", value: "assigned", unreadCount: notificationCount?.my_issues, }, { label: "Created by me", value: "created", unreadCount: notificationCount?.created_issues, }, { label: "Subscribed", value: "watching", unreadCount: notificationCount?.watching_issues, }, ]; return ( <> setSelectedNotificationForSnooze(null)} onSubmit={markSnoozeNotification} notification={ notifications?.find( (notification) => notification.id === selectedNotificationForSnooze ) || null } onSuccess={() => { notificationsMutate(); setSelectedNotificationForSnooze(null); }} /> {({ open: isActive, close: closePopover }) => ( <> {sidebarCollapse ? null : Notifications} {totalNotificationCount && totalNotificationCount > 0 ? ( {getNumberCount(totalNotificationCount)} ) : null}

Notifications

{snoozed || archived || readNotification ? ( ) : ( )}
{notifications ? ( notifications.length > 0 ? (
{notifications.map((notification) => ( ))}
) : (
) ) : ( )}
)}
); };