Fix: Event
Deksripsi - Fix notifikasi - Fix load beranda - Fix reload button di admin
This commit is contained in:
@@ -15,7 +15,7 @@ import { useShallowEffect } from "@mantine/hooks";
|
||||
import { IconBell, IconUserSearch } from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { MODEL_USER } from "../model/interface";
|
||||
|
||||
export function ComponentHome_ButtonHeaderLeft({
|
||||
@@ -61,47 +61,27 @@ export function ComponentHome_ButtonHeaderRight({
|
||||
const [isLoadingBell, setIsLoadingBell] = useState(false);
|
||||
|
||||
// Notifikasi
|
||||
const [countNtf, setCountNtf] = useState(countNotifikasi);
|
||||
const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
|
||||
// const [countNtf, setCountNtf] = useState(countNotifikasi);
|
||||
// const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
|
||||
const [categoryPage, setCategoryPage] = useAtom(gs_notifikasi_kategori_app);
|
||||
|
||||
useShallowEffect(() => {
|
||||
// console.log(newUserNtf, "new notif");
|
||||
// console.log(countNtf, "count ntf");
|
||||
setCountNtf(countNtf + newUserNtf);
|
||||
setNewUserNtf(0);
|
||||
|
||||
onLoadNotifikasi({
|
||||
onLoad(val) {
|
||||
console.log(val, "total notif");
|
||||
setCountNtf(val);
|
||||
},
|
||||
});
|
||||
}, [newUserNtf, setCountNtf]);
|
||||
|
||||
// useShallowEffect(() => {
|
||||
// mqtt_client.subscribe("USER");
|
||||
|
||||
// mqtt_client.on("message", (topic: any, message: any) => {
|
||||
// // console.log(topic);
|
||||
// const data = JSON.parse(message.toString());
|
||||
|
||||
// if (data.userId === dataUser.id) {
|
||||
// setCountNtf(countNtf + data.count);
|
||||
// }
|
||||
// });
|
||||
|
||||
// useEffect(() => {
|
||||
// onLoadNotifikasi({
|
||||
// onLoad(val) {
|
||||
// setCountNtf(val);
|
||||
// },
|
||||
// });
|
||||
// }, [countNtf]);
|
||||
// }, [setCountNtf]);
|
||||
|
||||
async function onLoadNotifikasi({ onLoad }: { onLoad: (val: any) => void }) {
|
||||
const loadNotif = await notifikasi_countUserNotifikasi();
|
||||
onLoad(loadNotif);
|
||||
}
|
||||
// useShallowEffect(() => {
|
||||
// setCountNtf(countNtf + newUserNtf);
|
||||
// setNewUserNtf(0);
|
||||
// }, [newUserNtf, setCountNtf]);
|
||||
|
||||
// async function onLoadNotifikasi({ onLoad }: { onLoad: (val: any) => void }) {
|
||||
// const loadNotif = await notifikasi_countUserNotifikasi();
|
||||
// onLoad(loadNotif);
|
||||
// }
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -116,13 +96,12 @@ export function ComponentHome_ButtonHeaderRight({
|
||||
});
|
||||
setCategoryPage("Semua");
|
||||
setIsLoadingBell(true);
|
||||
// setActiveKategori("Semua");
|
||||
}
|
||||
}}
|
||||
>
|
||||
{isLoadingBell ? (
|
||||
<Loader color={AccentColor.yellow} size={20} />
|
||||
) : countNtf === 0 ? (
|
||||
) : countNotifikasi === 0 ? (
|
||||
<IconBell color="white" />
|
||||
) : (
|
||||
<Indicator
|
||||
@@ -130,7 +109,7 @@ export function ComponentHome_ButtonHeaderRight({
|
||||
color={MainColor.yellow}
|
||||
label={
|
||||
<Text fz={10} c={MainColor.darkblue}>
|
||||
{countNtf > 99 ? "99+" : countNtf}
|
||||
{countNotifikasi > 99 ? "99+" : countNotifikasi}
|
||||
</Text>
|
||||
}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user