import Module from "@Front/Config/Module"; import React, { useCallback, useEffect } from "react"; import HeaderLink from "../HeaderLink"; import classes from "./classes.module.scss"; import Rules, { RulesMode } from "@Front/Components/Elements/Rules"; import { AppRuleActions, AppRuleNames } from "@Front/Api/Entities/rule"; import { usePathname } from "next/navigation"; import Notifications from "@Front/Api/LeCoffreApi/Notary/Notifications/Notifications"; import Toasts from "@Front/Stores/Toasts"; import OfficeFolderAnchors from "@Front/Api/LeCoffreApi/Notary/OfficeFolderAnchors/OfficeFolderAnchors"; export default function Navigation() { const pathname = usePathname(); const getAnchoringStatus = useCallback(async () => { const anchors = await OfficeFolderAnchors.getInstance().get({ where: { status: { not: "VERIFIED_ON_CHAIN", }, }, include: { folder: true, }, }); try { for (const anchor of anchors) { await OfficeFolderAnchors.getInstance().getByUid(anchor.folder?.uid as string); } } catch (e) { console.error(e); } }, []); const getNotifications = useCallback(async () => { //await getAnchoringStatus(); const notifications = await Notifications.getInstance().get({ where: { read: false, }, include: { notification: true, }, orderBy: { notification: { created_at: "desc" }, }, }); notifications.forEach((notification) => { Toasts.getInstance().open({ title: notification.notification.message, uid: notification.uid, redirectUrl: notification.notification.redirection_url, }); }); }, []); useEffect(() => { getAnchoringStatus(); getNotifications(); }, [pathname, getNotifications, getAnchoringStatus]); return (
); }