upd:realtime
Deskripsi; - upd realtime di halaman pengumuman No Issues
This commit is contained in:
@@ -13,6 +13,8 @@ export const DIR = {
|
||||
|
||||
}
|
||||
|
||||
export const keyWibu= 'padahariminggukuturutayahkekotanaikdelmanistimewakududukdimuka'
|
||||
|
||||
export const TEMA = hookstate<IGlobalTema>({
|
||||
utama: "#19345E",
|
||||
bgUtama: "#F4F9FD",
|
||||
|
||||
@@ -20,7 +20,7 @@ export default function NotificationCustome({ onClose, title, desc, onClick }: {
|
||||
useShallowEffect(() => {
|
||||
const timer = setTimeout(() => {
|
||||
setOpened(false)
|
||||
}, 2000);
|
||||
}, 3000);
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
'use client'
|
||||
import { useHookstate } from "@hookstate/core";
|
||||
import { globalNotifPage, globalRole, TEMA } from "../bin/val_global";
|
||||
import { globalNotifPage, globalRole, keyWibu, TEMA } from "../bin/val_global";
|
||||
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";
|
||||
|
||||
export default function WrapLayout({ children, role, theme, user }: { children: React.ReactNode, role: any, theme: any, user: any }) {
|
||||
const router = useRouter()
|
||||
const roleLogin = useHookstate(globalRole)
|
||||
const tema = useHookstate(TEMA)
|
||||
const notifLoadPage = useHookstate(globalNotifPage)
|
||||
const [tampilNotif, setTampilNotif] = useState(false)
|
||||
const [data, setData] = useWibuRealtime({
|
||||
WIBU_REALTIME_TOKEN: 'padahariminggukuturutayahkekotanaikdelmanistimewakududukdimuka',
|
||||
WIBU_REALTIME_TOKEN: keyWibu,
|
||||
project: "sdm"
|
||||
})
|
||||
|
||||
@@ -23,24 +25,28 @@ export default function WrapLayout({ children, role, theme, user }: { children:
|
||||
}, [role, theme])
|
||||
|
||||
useShallowEffect(() => {
|
||||
if (data) {
|
||||
if (data && data.some((i: any) => i.idUserTo == user)) {
|
||||
setTampilNotif(true)
|
||||
|
||||
setTimeout(() => {
|
||||
setTampilNotif(false);
|
||||
}, 3000);
|
||||
}, 4000);
|
||||
}
|
||||
}, [data])
|
||||
|
||||
|
||||
function onClickNotif(category: string, content: string) {
|
||||
router.push('/' + category + '/' + content)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* {JSON.stringify(data)} */}
|
||||
{
|
||||
tampilNotif &&
|
||||
<NotificationCustome
|
||||
title={data?.title}
|
||||
desc={data?.desc}
|
||||
onClick={() => { '' }}
|
||||
title={data.filter((i: any) => i.idUserTo == user)[0]?.title}
|
||||
desc={data.filter((i: any) => i.idUserTo == user)[0]?.desc}
|
||||
onClick={() => { onClickNotif(data.filter((i: any) => i.idUserTo == user)[0]?.category, data.filter((i: any) => i.idUserTo == user)[0]?.idContent) }}
|
||||
onClose={() => { '' }}
|
||||
/>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import prisma from "./bin/prisma";
|
||||
import { currentScroll, DIR, globalNotifPage, globalRole, pwd_key_config, TEMA } from "./bin/val_global";
|
||||
import { currentScroll, DIR, globalNotifPage, globalRole, keyWibu, pwd_key_config, TEMA } from "./bin/val_global";
|
||||
import SkeletonAvatar from "./components/skeleton_avatar";
|
||||
import SkeletonDetailDiscussionComment from "./components/skeleton_detail_discussion_comment";
|
||||
import SkeletonDetailDiscussionMember from "./components/skeleton_detail_discussion_member";
|
||||
@@ -58,3 +58,4 @@ export { ScrollProvider }
|
||||
export { currentScroll }
|
||||
export { SkeletonUser }
|
||||
export { SkeletonList }
|
||||
export { keyWibu }
|
||||
|
||||
Reference in New Issue
Block a user