"use client"; import { FC, useCallback } from "react"; import { observer } from "mobx-react"; import { useParams } from "next/navigation"; // components import { Header, Row, ERowVariant, EHeaderVariant, ContentWrapper } from "@plane/ui"; import { CountChip } from "@/components/common"; import { NotificationsLoader, NotificationEmptyState, NotificationSidebarHeader, AppliedFilters, NotificationCardListRoot, } from "@/components/workspace-notifications"; // constants import { NOTIFICATION_TABS, TNotificationTab } from "@/constants/notification"; // helpers import { cn } from "@/helpers/common.helper"; import { getNumberCount } from "@/helpers/string.helper"; // hooks import { useWorkspace, useWorkspaceNotifications } from "@/hooks/store"; export const NotificationsSidebarRoot: FC = observer(() => { const { workspaceSlug } = useParams(); // hooks const { getWorkspaceBySlug } = useWorkspace(); const { currentSelectedNotificationId, unreadNotificationsCount, loader, notificationIdsByWorkspaceId, currentNotificationTab, setCurrentNotificationTab, } = useWorkspaceNotifications(); // derived values const workspace = workspaceSlug ? getWorkspaceBySlug(workspaceSlug.toString()) : undefined; const notificationIds = workspace ? notificationIdsByWorkspaceId(workspace.id) : undefined; const handleTabClick = useCallback( (tabValue: TNotificationTab) => { if (currentNotificationTab !== tabValue) { setCurrentNotificationTab(tabValue); } }, [currentNotificationTab, setCurrentNotificationTab] ); if (!workspaceSlug || !workspace) return <>; return (
{NOTIFICATION_TABS.map((tab) => (
handleTabClick(tab.value)} >
{tab.label}
{tab.count(unreadNotificationsCount) > 0 && ( )}
{currentNotificationTab === tab.value && (
)}
))}
{/* applied filters */} {/* rendering notifications */} {loader === "init-loader" ? (
) : ( <> {notificationIds && notificationIds.length > 0 ? ( ) : (
)} )}
); });