upd: notifikasi

Deskripsi:
- tambah jumlah notifikasi dg variable global

No Issues
This commit is contained in:
amel
2024-10-09 16:07:02 +08:00
parent 7a110a9c0c
commit 8f46be4bf8
4 changed files with 22 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ import { useEffect, useState } from "react";
import { useWibuRealtime } from "wibu-realtime";
import NotificationCustome from "./notification_custome";
import { useRouter } from "next/navigation";
import { globalParamJumlahNotif } from "@/module/home";
export default function WrapLayout({ children, role, theme, user }: { children: React.ReactNode, role: any, theme: any, user: any }) {
const router = useRouter()
@@ -13,6 +14,7 @@ export default function WrapLayout({ children, role, theme, user }: { children:
const tema = useHookstate(TEMA)
const notifLoadPage = useHookstate(globalNotifPage)
const [tampilNotif, setTampilNotif] = useState(false)
const paramNotif = useHookstate(globalParamJumlahNotif)
const [data, setData] = useWibuRealtime({
WIBU_REALTIME_TOKEN: keyWibu,
project: "sdm"
@@ -27,6 +29,7 @@ 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);
@@ -40,7 +43,6 @@ export default function WrapLayout({ children, role, theme, user }: { children:
return (
<>
{/* {JSON.stringify(data)} */}
{
tampilNotif &&
<NotificationCustome
@@ -50,7 +52,6 @@ export default function WrapLayout({ children, role, theme, user }: { children:
onClose={() => { '' }}
/>
}
{children}
</>
);