diff --git a/next.config.js b/next.config.js index b00f93a2..5c728631 100644 --- a/next.config.js +++ b/next.config.js @@ -1,6 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { - // reactStrictMode: false, + reactStrictMode: false, experimental: { serverActions: true }, diff --git a/src/app/dev/layout.tsx b/src/app/dev/layout.tsx index 1ac8606a..49f4a4c7 100644 --- a/src/app/dev/layout.tsx +++ b/src/app/dev/layout.tsx @@ -7,12 +7,9 @@ export default async function Layout({ }: { children: React.ReactNode; }) { - const userLoginId = await newFunGetUserId(); - return ( <> | null> { - try { - const enc = new TextEncoder().encode(encodedKey); - const { payload } = await jwtVerify(token, enc, { - algorithms: ["HS256"], - }); - return (payload.user as Record) || null; - } catch (error) { - console.error("Gagal verifikasi session", error); - return null; - } -} +} \ No newline at end of file diff --git a/src/app/lib/realtime_provider.tsx b/src/app/lib/realtime_provider.tsx index 42b32e7a..07919a7f 100644 --- a/src/app/lib/realtime_provider.tsx +++ b/src/app/lib/realtime_provider.tsx @@ -17,6 +17,8 @@ import { gs_votingTiggerBeranda, IRealtimeData, } from "./global_state"; +import { newFunGetUserId } from "./new_fun_user_id"; +import { useState } from "react"; // const WIBU_REALTIME_TOKEN: string | undefined = // process.env.NEXT_PUBLIC_WIBU_REALTIME_TOKEN; @@ -30,12 +32,11 @@ export type TypeNotification = { }; export default function RealtimeProvider({ - userLoginId, WIBU_REALTIME_TOKEN, }: { - userLoginId: string; WIBU_REALTIME_TOKEN: string; }) { + const [userLoginId, setUserLoginId] = useState(""); const [dataRealtime, setDataRealtime] = useAtom(gs_realtimeData); const [newAdminNtf, setNewAdminNtf] = useAtom(gs_admin_ntf); const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf); @@ -71,7 +72,14 @@ export default function RealtimeProvider({ gs_donasiTriggerBeranda ); + async function loadUserId() { + const userId = await newFunGetUserId(); + + setUserLoginId(userId as string); + } + useShallowEffect(() => { + loadUserId(); try { WibuRealtime.init({