Fix notifikasi server action to API
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
|
||||
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
@@ -19,7 +20,6 @@ import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { apiGetDataHome } from "../fun/get/api_home";
|
||||
import { listMenuHomeBody, menuHomeJob } from "./list_menu_home";
|
||||
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
|
||||
|
||||
export default function BodyHome() {
|
||||
const router = useRouter();
|
||||
@@ -83,12 +83,19 @@ export default function BodyHome() {
|
||||
}}
|
||||
onClick={() => {
|
||||
if (
|
||||
dataUser.profile === undefined ||
|
||||
dataUser?.profile === null
|
||||
dataUser.profile == undefined ||
|
||||
dataUser?.profile == null ||
|
||||
dataJob.length == undefined ||
|
||||
dataJob.length == null
|
||||
) {
|
||||
return null;
|
||||
} else if (
|
||||
dataUser.profile == undefined ||
|
||||
dataUser?.profile == null
|
||||
) {
|
||||
router.push(RouterProfile.create, { scroll: false });
|
||||
} else {
|
||||
if (e.link === "") {
|
||||
if (e.link == "") {
|
||||
return ComponentGlobal_NotifikasiPeringatan(
|
||||
"Cooming Soon !!"
|
||||
);
|
||||
@@ -102,11 +109,11 @@ export default function BodyHome() {
|
||||
<ActionIcon
|
||||
size={50}
|
||||
variant="transparent"
|
||||
c={e.link === "" ? "gray.3" : "white"}
|
||||
c={e.link == "" ? "gray.3" : "white"}
|
||||
>
|
||||
{e.icon}
|
||||
</ActionIcon>
|
||||
<Text c={e.link === "" ? "gray.3" : "white"} fz={"xs"}>
|
||||
<Text c={e.link == "" ? "gray.3" : "white"} fz={"xs"}>
|
||||
{e.name}
|
||||
</Text>
|
||||
</Stack>
|
||||
@@ -127,12 +134,19 @@ export default function BodyHome() {
|
||||
<Stack
|
||||
onClick={() => {
|
||||
if (
|
||||
dataUser.profile === undefined ||
|
||||
dataUser?.profile === null
|
||||
dataUser.profile == undefined ||
|
||||
dataUser?.profile == null ||
|
||||
dataJob.length == undefined ||
|
||||
dataJob.length == null
|
||||
) {
|
||||
return null;
|
||||
} else if (
|
||||
dataUser.profile == undefined ||
|
||||
dataUser?.profile == null
|
||||
) {
|
||||
router.push(RouterProfile.create, { scroll: false });
|
||||
} else {
|
||||
if (menuHomeJob.link === "") {
|
||||
if (menuHomeJob.link == "") {
|
||||
return ComponentGlobal_NotifikasiPeringatan(
|
||||
"Cooming Soon !!"
|
||||
);
|
||||
@@ -146,11 +160,11 @@ export default function BodyHome() {
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
size={40}
|
||||
c={menuHomeJob.link === "" ? "gray.3" : "white"}
|
||||
c={menuHomeJob.link == "" ? "gray.3" : "white"}
|
||||
>
|
||||
{menuHomeJob.icon}
|
||||
</ActionIcon>
|
||||
<Text c={menuHomeJob.link === "" ? "gray.3" : "white"}>
|
||||
<Text c={menuHomeJob.link == "" ? "gray.3" : "white"}>
|
||||
{menuHomeJob.name}
|
||||
</Text>
|
||||
</Group>
|
||||
|
||||
@@ -56,6 +56,11 @@ export default function FooterHome() {
|
||||
if (
|
||||
dataUser.profile === undefined ||
|
||||
dataUser?.profile === null
|
||||
) {
|
||||
return null;
|
||||
} else if (
|
||||
dataUser.profile === undefined ||
|
||||
dataUser?.profile === null
|
||||
) {
|
||||
router.push(RouterProfile.create, { scroll: false });
|
||||
} else {
|
||||
|
||||
@@ -137,3 +137,137 @@ export default function HomeViewNew({
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// "use client";
|
||||
// import { API_RouteNotifikasi } from "@/app/lib/api_user_router/route_api_notifikasi";
|
||||
// import { gs_count_ntf, gs_user_ntf } from "@/app/lib/global_state";
|
||||
// import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
|
||||
// import { RouterNotifikasi } from "@/app/lib/router_hipmi/router_notifikasi";
|
||||
// import { RouterUserSearch } from "@/app/lib/router_hipmi/router_user_search";
|
||||
// import { ActionIcon, Indicator, Text } from "@mantine/core";
|
||||
// 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 { MainColor } from "../_global/color";
|
||||
// import UIGlobal_LayoutHeaderTamplate from "../_global/ui/ui_header_tamplate";
|
||||
// import UIGlobal_LayoutTamplate from "../_global/ui/ui_layout_tamplate";
|
||||
// import { gs_notifikasi_kategori_app } from "../notifikasi/lib";
|
||||
// import BodyHome from "./component/body_home";
|
||||
// import FooterHome from "./component/footer_home";
|
||||
// import { apiGetDataHome } from "./fun/get/api_home";
|
||||
|
||||
// export default function HomeViewNew() {
|
||||
// const [countNtf, setCountNtf] = useAtom(gs_count_ntf);
|
||||
// const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
|
||||
// const [dataUser, setDataUser] = useState<any>({});
|
||||
// const [categoryPage, setCategoryPage] = useAtom(gs_notifikasi_kategori_app);
|
||||
// const router = useRouter();
|
||||
|
||||
// useShallowEffect(() => {
|
||||
// onLoadNotifikasi();
|
||||
// }, []);
|
||||
|
||||
// useShallowEffect(() => {
|
||||
// if (countNtf != null) {
|
||||
// setCountNtf(countNtf + newUserNtf);
|
||||
// setNewUserNtf(0);
|
||||
// }
|
||||
// console.log("notif baru", newUserNtf);
|
||||
// console.log("notif baru", countNtf);
|
||||
// }, [newUserNtf, countNtf]);
|
||||
|
||||
// async function onLoadNotifikasi() {
|
||||
// const loadNotif = await fetch(API_RouteNotifikasi.get_count_by_id());
|
||||
// const data = await loadNotif.json().then((res) => res.data);
|
||||
// setCountNtf(data);
|
||||
// }
|
||||
|
||||
// useShallowEffect(() => {
|
||||
// cekUserLogin();
|
||||
// }, []);
|
||||
|
||||
// async function cekUserLogin() {
|
||||
// try {
|
||||
// const response = await apiGetDataHome("?cat=cek_profile");
|
||||
// if (response.success) {
|
||||
// setDataUser(response.data);
|
||||
// }
|
||||
// } catch (error) {
|
||||
// console.error(error);
|
||||
// }
|
||||
// }
|
||||
|
||||
// return (
|
||||
// <>
|
||||
// <UIGlobal_LayoutTamplate
|
||||
// header={
|
||||
// <UIGlobal_LayoutHeaderTamplate
|
||||
// title="HIPMI"
|
||||
// customButtonLeft={
|
||||
// <ActionIcon
|
||||
// radius={"xl"}
|
||||
// disabled={countNtf == null}
|
||||
// variant={"transparent"}
|
||||
// onClick={() => {
|
||||
// if (
|
||||
// dataUser.profile === undefined ||
|
||||
// dataUser?.profile === null
|
||||
// ) {
|
||||
// router.push(RouterProfile.create, { scroll: false });
|
||||
// } else {
|
||||
// router.push(RouterUserSearch.main, { scroll: false });
|
||||
// }
|
||||
// }}
|
||||
// >
|
||||
// <IconUserSearch color="white" />
|
||||
// </ActionIcon>
|
||||
// }
|
||||
// customButtonRight={
|
||||
// <ActionIcon
|
||||
// variant="transparent"
|
||||
// disabled={countNtf == null}
|
||||
// onClick={() => {
|
||||
// if (
|
||||
// dataUser.profile === undefined ||
|
||||
// dataUser?.profile === null
|
||||
// ) {
|
||||
// router.push(RouterProfile.create, { scroll: false });
|
||||
// } else {
|
||||
// setCategoryPage("Semua");
|
||||
// router.push(
|
||||
// RouterNotifikasi.categoryApp({ name: "semua" }),
|
||||
// {
|
||||
// scroll: false,
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
// }}
|
||||
// >
|
||||
// {countNtf != null && countNtf > 0 ? (
|
||||
// <Indicator
|
||||
// processing
|
||||
// color={MainColor.yellow}
|
||||
// label={
|
||||
// <Text fz={10} c={MainColor.darkblue}>
|
||||
// {countNtf > 99 ? "99+" : countNtf}
|
||||
// </Text>
|
||||
// }
|
||||
// >
|
||||
// <IconBell color="white" />
|
||||
// </Indicator>
|
||||
// ) : (
|
||||
// <IconBell color="white" />
|
||||
// )}
|
||||
// </ActionIcon>
|
||||
// }
|
||||
// />
|
||||
// }
|
||||
// footer={<FooterHome />}
|
||||
// >
|
||||
// <BodyHome />
|
||||
// </UIGlobal_LayoutTamplate>
|
||||
// </>
|
||||
// );
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user