Deskripsi:
- Realtime notifikasi
## No Issue
This commit is contained in:
2024-07-24 10:14:07 +08:00
parent 73c6d58eef
commit 6553f6163f
25 changed files with 510 additions and 289 deletions

View File

@@ -12,17 +12,18 @@ import {
MainColor,
} from "@/app_modules/_global/color/color_pallet";
import notifikasi_getByUserId from "../fun/get/get_notifiaksi_by_id";
import { redirectVotingPage } from "./path/voting";
export function ComponentNotifiaksi_CardView({
data,
onLoadData,
activePage,
onSetJob,
onSetMenu,
}: {
data: MODEL_NOTIFIKASI;
onLoadData: (val: any) => void;
activePage: number;
onSetJob: (val: any) => void;
onSetMenu: (val: any) => void;
}) {
const router = useRouter();
return (
@@ -45,7 +46,7 @@ export function ComponentNotifiaksi_CardView({
data: data,
router: router,
onSetPage(val) {
onSetJob(val);
onSetMenu(val);
},
});
@@ -55,6 +56,15 @@ export function ComponentNotifiaksi_CardView({
router: router,
});
data?.kategoriApp === "VOTING" &&
redirectVotingPage({
data: data,
router: router,
onSetPage(val) {
onSetMenu(val);
},
});
const updateIsRead = await notifikasi_funUpdateIsReadById({
notifId: data?.id,
});

View File

@@ -0,0 +1,36 @@
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
import { MODEL_NOTIFIKASI } from "../../model/interface";
export function redirectVotingPage({
data,
router,
onSetPage,
}: {
data: MODEL_NOTIFIKASI;
router: AppRouterInstance;
onSetPage: (val: any) => void;
}) {
const path = RouterVote.status;
if (data.status === "Publish") {
onSetPage({
menuId: 2,
status: data.status,
});
router.push(path, { scroll: false });
}
// console.log(data)
if (data.status === "Reject") {
onSetPage({
menuId: 2,
status: data.status,
});
router.push(path, { scroll: false });
}
if (data.status === "Voting Masuk") {
router.push(RouterVote.main_detail + data.appId, { scroll: false });
}
}

View File

@@ -12,6 +12,10 @@ import { useState } from "react";
import notifikasi_getByUserId from "../fun/get/get_notifiaksi_by_id";
import { MODEL_NOTIFIKASI } from "../model/interface";
import { ComponentNotifiaksi_CardView } from "./card_view";
import {
gs_vote_hotMenu,
gs_vote_status,
} from "@/app_modules/vote/global_state";
export function Notifikasi_UiView({
listNotifikasi,
@@ -24,19 +28,21 @@ export function Notifikasi_UiView({
// JOB
const [jobMenuId, setJobMenuId] = useAtom(gs_job_hot_menu);
const [jobStatus, setJobStatus] = useAtom(gs_job_status);
const [voteMenu, setVoteMenu] = useAtom(gs_vote_hotMenu);
const [voeStatus, setVoteStatus] = useAtom(gs_vote_status);
useShallowEffect(() => {
onLoadData({
onLoad(val) {
setData(val);
},
});
}, []);
useShallowEffect(() => {
onLoadData({
onLoad(val) {
setData(val);
},
});
}, []);
async function onLoadData({ onLoad }: { onLoad: (val: any) => void }) {
const loadData = await notifikasi_getByUserId({ page: 1 });
onLoad(loadData);
}
async function onLoadData({ onLoad }: { onLoad: (val: any) => void }) {
const loadData = await notifikasi_getByUserId({ page: 1 });
onLoad(loadData);
}
return (
<>
@@ -67,9 +73,15 @@ export function Notifikasi_UiView({
data={item}
onLoadData={(val) => setData(val)}
activePage={activePage}
onSetJob={(val) => {
setJobMenuId(val.menuId);
setJobStatus(val.status);
onSetMenu={(val) => {
if (item?.kategoriApp === "JOB") {
setJobMenuId(val.menuId);
setJobStatus(val.status);
}
if (item?.kategoriApp === "VOTING") {
setVoteMenu(val.menuId);
setVoteStatus(val.status);
}
}}
/>
)}