* refactor: remove barrel exports from some compoennt modules * refactor: remove barrel exports from issue components * refactor: remove barrel exports from page components * chore: update type improts * refactor: remove barrel exports from cycle components * refactor: remove barrel exports from dropdown components * refactor: remove barrel exports from ce components * refactor: remove barrel exports from some more components * refactor: remove barrel exports from profile and sidebar components * chore: update type imports * refactor: remove barrel exports from store hooks * chore: dynamically load sticky editor * fix: lint * chore: revert sticky dynamic import * refactor: remove barrel exports from ce issue components * refactor: remove barrel exports from ce issue components * refactor: remove barrel exports from ce issue components --------- Co-authored-by: sriramveeraghanta <veeraghanta.sriram@gmail.com>
58 lines
2.1 KiB
TypeScript
58 lines
2.1 KiB
TypeScript
"use client";
|
|
|
|
import { FC } from "react";
|
|
import { observer } from "mobx-react";
|
|
// plane imports
|
|
import { ENotificationLoader, ENotificationQueryParamType } from "@plane/constants";
|
|
import { useTranslation } from "@plane/i18n";
|
|
// components
|
|
import { NotificationItem } from "@/components/workspace-notifications/sidebar/notification-card/item";
|
|
// hooks
|
|
import { useWorkspaceNotifications } from "@/hooks/store/notifications";
|
|
|
|
type TNotificationCardListRoot = {
|
|
workspaceSlug: string;
|
|
workspaceId: string;
|
|
};
|
|
|
|
export const NotificationCardListRoot: FC<TNotificationCardListRoot> = observer((props) => {
|
|
const { workspaceSlug, workspaceId } = props;
|
|
// hooks
|
|
const { loader, paginationInfo, getNotifications, notificationIdsByWorkspaceId } = useWorkspaceNotifications();
|
|
const notificationIds = notificationIdsByWorkspaceId(workspaceId);
|
|
const { t } = useTranslation();
|
|
|
|
const getNextNotifications = async () => {
|
|
try {
|
|
await getNotifications(workspaceSlug, ENotificationLoader.PAGINATION_LOADER, ENotificationQueryParamType.NEXT);
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
};
|
|
|
|
if (!workspaceSlug || !workspaceId || !notificationIds) return <></>;
|
|
return (
|
|
<div>
|
|
{notificationIds.map((notificationId: string) => (
|
|
<NotificationItem key={notificationId} workspaceSlug={workspaceSlug} notificationId={notificationId} />
|
|
))}
|
|
|
|
{/* fetch next page notifications */}
|
|
{paginationInfo && paginationInfo?.next_page_results && (
|
|
<>
|
|
{loader === ENotificationLoader.PAGINATION_LOADER ? (
|
|
<div className="py-4 flex justify-center items-center text-sm font-medium">
|
|
<div className="text-custom-primary-90">{t("loading")}...</div>
|
|
</div>
|
|
) : (
|
|
<div className="py-4 flex justify-center items-center text-sm font-medium" onClick={getNextNotifications}>
|
|
<div className="text-custom-primary-90 hover:text-custom-primary-100 transition-all cursor-pointer">
|
|
{t("load_more")}
|
|
</div>
|
|
</div>
|
|
)}
|
|
</>
|
|
)}
|
|
</div>
|
|
);
|
|
});
|