Fix: Event
Deksripsi - Fix notifikasi - Fix load beranda - Fix reload button di admin
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import UIGlobal_LayoutHeaderTamplate from "../_global/ui/ui_header_tamplate";
|
||||
import UIGlobal_LayoutTamplate from "../_global/ui/ui_layout_tamplate";
|
||||
import { MODEL_JOB } from "../job/model/interface";
|
||||
@@ -7,6 +10,10 @@ import {
|
||||
} from "./component/button_header";
|
||||
import { Home_UiFooter, Home_UiView } from "./component/ui_home";
|
||||
import { MODEL_USER } from "./model/interface";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { gs_count_ntf, gs_user_ntf } from "@/app/lib/global_state";
|
||||
import { useAtom } from "jotai";
|
||||
import notifikasi_countUserNotifikasi from "../notifikasi/fun/count/fun_count_by_id";
|
||||
|
||||
export default function HomeView({
|
||||
dataUser,
|
||||
@@ -17,8 +24,29 @@ export default function HomeView({
|
||||
dataJob: MODEL_JOB[];
|
||||
countNotifikasi: number;
|
||||
}) {
|
||||
|
||||
const [countNtf, setCountNtf] = useState(countNotifikasi);
|
||||
const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
|
||||
const [countLoadNtf, setCountLoadNtf] = useAtom(gs_count_ntf);
|
||||
|
||||
useShallowEffect(() => {
|
||||
onLoadNotifikasi({
|
||||
onLoad(val) {
|
||||
setCountNtf(val);
|
||||
},
|
||||
});
|
||||
|
||||
setCountNtf(countLoadNtf as any);
|
||||
}, [countLoadNtf, setCountNtf]);
|
||||
|
||||
useShallowEffect(() => {
|
||||
setCountNtf(countNtf + newUserNtf);
|
||||
setNewUserNtf(0);
|
||||
}, [newUserNtf, setCountNtf]);
|
||||
|
||||
async function onLoadNotifikasi({ onLoad }: { onLoad: (val: any) => void }) {
|
||||
const loadNotif = await notifikasi_countUserNotifikasi();
|
||||
onLoad(loadNotif);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -32,7 +60,7 @@ export default function HomeView({
|
||||
customButtonRight={
|
||||
<ComponentHome_ButtonHeaderRight
|
||||
dataUser={dataUser}
|
||||
countNotifikasi={countNotifikasi}
|
||||
countNotifikasi={countNtf}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user