upd: pengumuman

Deskripsi:
- update realtime tambah pengumuman pake yg refresh page

No Issues
This commit is contained in:
amel
2024-10-14 17:53:20 +08:00
parent 4bc043a8e1
commit 0215c92048
2 changed files with 72 additions and 25 deletions

View File

@@ -5,7 +5,7 @@ import { useShallowEffect } from "@mantine/hooks";
import { useEffect, useState } from "react";
import { useWibuRealtime } from "wibu-realtime";
import NotificationCustome from "./notification_custome";
import { useRouter } from "next/navigation";
import { usePathname, useRouter } from "next/navigation";
import { globalParamJumlahNotif } from "@/module/home";
import ReloadButtonTop from "./reload_button_top";
@@ -20,6 +20,8 @@ export default function WrapLayout({ children, role, theme, user }: { children:
WIBU_REALTIME_TOKEN: keyWibu,
project: "sdm"
})
const path = usePathname()
useEffect(() => {
roleLogin.set(role)
@@ -29,11 +31,18 @@ export default function WrapLayout({ children, role, theme, user }: { children:
useShallowEffect(() => {
if (data && data.some((i: any) => i.idUserTo == user)) {
setTampilNotif(true)
paramNotif.set(!paramNotif.get())
setTimeout(() => {
setTampilNotif(false);
}, 4000);
if (data.some((i: any) => i.category == path.substring(1))) {
notifLoadPage.set({
category: path.substring(1),
load: true
})
} else {
setTampilNotif(true)
paramNotif.set(!paramNotif.get())
setTimeout(() => {
setTampilNotif(false);
}, 4000);
}
}
}, [data])