## Deskripsi:
- Notifikasi admin to user
- Notifikasi user to user
### Issue: - Pada table admin harus di sediakan untuk triger update data saat ada notifikasi
This commit is contained in:
2024-07-25 15:06:14 +08:00
parent f336e8ad30
commit 01114e8405
20 changed files with 292 additions and 124 deletions

View File

@@ -13,6 +13,7 @@ import {
} from "@/app_modules/_global/color/color_pallet";
import notifikasi_getByUserId from "../fun/get/get_notifiaksi_by_id";
import { redirectVotingPage } from "./path/voting";
import { redirectEventPage } from "./path/event";
export function ComponentNotifiaksi_CardView({
data,
@@ -41,6 +42,18 @@ export function ComponentNotifiaksi_CardView({
}}
my={"xs"}
onClick={async () => {
await notifikasi_funUpdateIsReadById({
notifId: data?.id,
});
// if (updateIsRead.status === 200) {
// const loadData = await notifikasi_getByUserId({
// page: activePage + 1,
// });
// onLoadData(loadData);
// }
data?.kategoriApp === "JOB" &&
redirectJobPage({
data: data,
@@ -65,16 +78,14 @@ export function ComponentNotifiaksi_CardView({
},
});
const updateIsRead = await notifikasi_funUpdateIsReadById({
notifId: data?.id,
});
if (updateIsRead.status === 200) {
// console.log(updateIsRead.status);
// const loadData = await notifikasi_getByUserId({ page: activePage });
// onLoadData(loadData);
// console.log("berhasil load")
}
data?.kategoriApp === "EVENT" &&
redirectEventPage({
data: data,
router: router,
onSetPage(val) {
onSetMenu(val);
},
});
}}
>
{/* <pre>{JSON.stringify(e, null, 2)}</pre> */}

View File

@@ -0,0 +1,36 @@
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
import { MODEL_NOTIFIKASI } from "../../model/interface";
export function redirectEventPage({
data,
router,
onSetPage,
}: {
data: MODEL_NOTIFIKASI;
router: AppRouterInstance;
onSetPage: (val: any) => void;
}) {
const path = RouterEvent.status_page;
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 === "Peserta event") {
router.push(RouterEvent.detail_main + data.appId, { scroll: false });
}
}

View File

@@ -16,6 +16,10 @@ import {
gs_vote_hotMenu,
gs_vote_status,
} from "@/app_modules/vote/global_state";
import {
gs_event_hotMenu,
gs_event_status,
} from "@/app_modules/event/global_state";
export function Notifikasi_UiView({
listNotifikasi,
@@ -29,20 +33,22 @@ export function Notifikasi_UiView({
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);
const [voteStatus, setVoteStatus] = useAtom(gs_vote_status);
const [eventMenu, setEventMenu] = useAtom(gs_event_hotMenu);
const [eventStatus, setEventStatus] = useAtom(gs_event_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 (
<>
@@ -71,17 +77,23 @@ export function Notifikasi_UiView({
{(item) => (
<ComponentNotifiaksi_CardView
data={item}
onLoadData={(val) => setData(val)}
onLoadData={setData}
activePage={activePage}
onSetMenu={(val) => {
if (item?.kategoriApp === "JOB") {
setJobMenuId(val.menuId);
setJobStatus(val.status);
}
if (item?.kategoriApp === "VOTING") {
setVoteMenu(val.menuId);
setVoteStatus(val.status);
}
if (item?.kategoriApp === "EVENT") {
setEventMenu(val.menuId);
setEventStatus(val.status);
}
}}
/>
)}