"use client"; import { FC } from "react"; import { observer } from "mobx-react"; // components import { NotificationItem } from "@/components/workspace-notifications"; // constants import { ENotificationLoader, ENotificationQueryParamType } from "@/constants/notification"; // hooks import { useWorkspaceNotifications } from "@/hooks/store"; type TNotificationCardListRoot = { workspaceSlug: string; workspaceId: string; }; export const NotificationCardListRoot: FC = observer((props) => { const { workspaceSlug, workspaceId } = props; // hooks const { loader, paginationInfo, getNotifications, notificationIdsByWorkspaceId } = useWorkspaceNotifications(); const notificationIds = notificationIdsByWorkspaceId(workspaceId); const getNextNotifications = async () => { try { await getNotifications(workspaceSlug, ENotificationLoader.PAGINATION_LOADER, ENotificationQueryParamType.NEXT); } catch (error) { console.error(error); } }; if (!workspaceSlug || !workspaceId || !notificationIds) return <>; return (
{notificationIds.map((notificationId: string) => ( ))} {/* fetch next page notifications */} {paginationInfo && paginationInfo?.next_page_results && ( <> {loader === ENotificationLoader.PAGINATION_LOADER ? (
Loading...
) : (
Load more
)} )}
); });