fix notifikasi
deskripsi: - fix load data notifikasi: semua, event, job, donasi, investasi
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import { gs_count_ntf } from "@/lib/global_state";
|
||||
import {
|
||||
AccentColor,
|
||||
MainColor,
|
||||
@@ -11,6 +10,8 @@ import { gs_event_hotMenu } from "@/app_modules/event/global_state";
|
||||
import { gs_investas_menu } from "@/app_modules/investasi/g_state";
|
||||
import { gs_job_hot_menu } from "@/app_modules/job/global_state";
|
||||
import { gs_vote_hotMenu } from "@/app_modules/vote/global_state";
|
||||
import { gs_count_ntf } from "@/lib/global_state";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { Badge, Card, Divider, Group, Stack, Text } from "@mantine/core";
|
||||
import { IconCheck, IconChecks } from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
@@ -24,18 +25,12 @@ import { notifikasi_eventCheckStatus } from "./path/event";
|
||||
import { redirectInvestasiPage } from "./path/investasi";
|
||||
import { notifikasi_jobCheckStatus } from "./path/job";
|
||||
import { notifikasi_votingCheckStatus } from "./path/voting";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { redirectDetailForumPage } from "./path/forum";
|
||||
|
||||
export function ComponentNotifiaksi_CardView({
|
||||
data,
|
||||
onLoadData,
|
||||
categoryPage,
|
||||
userLoginId,
|
||||
}: {
|
||||
data: MODEL_NOTIFIKASI;
|
||||
onLoadData: (val: any) => void;
|
||||
categoryPage: string;
|
||||
userLoginId?: string
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [visible, setVisible] = useState(false);
|
||||
@@ -65,25 +60,19 @@ export function ComponentNotifiaksi_CardView({
|
||||
try {
|
||||
setVisible(true);
|
||||
|
||||
console.log("data", data);
|
||||
// JOB
|
||||
if (data?.kategoriApp === "JOB") {
|
||||
await notifikasi_jobCheckStatus({
|
||||
appId: data.appId,
|
||||
dataId: data.id,
|
||||
categoryPage: categoryPage,
|
||||
router: router,
|
||||
onLoadDataJob(val) {
|
||||
onLoadData(val);
|
||||
},
|
||||
onSetJobMenuId(val) {
|
||||
setJobMenuId(val);
|
||||
},
|
||||
onSetVisible(val) {
|
||||
setVisible(val);
|
||||
},
|
||||
onLoadCountNtf(val) {
|
||||
setLoadCountNtf(val);
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
@@ -94,20 +83,13 @@ export function ComponentNotifiaksi_CardView({
|
||||
await notifikasi_eventCheckStatus({
|
||||
appId: data.appId,
|
||||
dataId: data.id,
|
||||
categoryPage: categoryPage,
|
||||
router: router,
|
||||
onLoadDataEvent(val) {
|
||||
onLoadData(val);
|
||||
},
|
||||
onSetVisible(val) {
|
||||
setVisible(val);
|
||||
},
|
||||
onSetEventMenuId(val) {
|
||||
setEventMenuId(val);
|
||||
},
|
||||
onLoadCountNtf(val) {
|
||||
setLoadCountNtf(val);
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
@@ -118,20 +100,13 @@ export function ComponentNotifiaksi_CardView({
|
||||
await notifikasi_votingCheckStatus({
|
||||
appId: data.appId,
|
||||
dataId: data.id,
|
||||
categoryPage: categoryPage,
|
||||
router: router,
|
||||
onLoadDataEvent(val) {
|
||||
onLoadData(val);
|
||||
},
|
||||
onSetVisible(val) {
|
||||
setVisible(val);
|
||||
},
|
||||
onSetMenuId(val) {
|
||||
setVotingMenu(val);
|
||||
},
|
||||
onLoadCountNtf(val) {
|
||||
setLoadCountNtf(val);
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
@@ -143,21 +118,13 @@ export function ComponentNotifiaksi_CardView({
|
||||
appId: data.appId,
|
||||
dataId: data.id,
|
||||
userId: data.userId,
|
||||
userLoginId: userLoginId as any,
|
||||
categoryPage: categoryPage,
|
||||
router: router,
|
||||
onLoadDataEvent(val) {
|
||||
onLoadData(val);
|
||||
},
|
||||
onSetVisible(val) {
|
||||
setVisible(val);
|
||||
},
|
||||
onSetMenuId(val) {
|
||||
setDonasiMenu(val);
|
||||
},
|
||||
onLoadCountNtf(val) {
|
||||
setLoadCountNtf(val);
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
@@ -168,30 +135,29 @@ export function ComponentNotifiaksi_CardView({
|
||||
redirectInvestasiPage({
|
||||
appId: data.appId,
|
||||
dataId: data.id,
|
||||
categoryPage: categoryPage,
|
||||
router: router,
|
||||
onLoadDataEvent(val) {
|
||||
onLoadData(val);
|
||||
},
|
||||
onSetVisible(val) {
|
||||
setVisible(val);
|
||||
},
|
||||
onSetMenuId(val) {
|
||||
setInvestasiMenu(val);
|
||||
},
|
||||
onLoadCountNtf(val) {
|
||||
setLoadCountNtf(val);
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// data?.kategoriApp === "FORUM" &&
|
||||
// redirectDetailForumPage({
|
||||
// data: data,
|
||||
// router: router,
|
||||
// });
|
||||
if (data?.kategoriApp === "FORUM") {
|
||||
redirectDetailForumPage({
|
||||
data: data,
|
||||
router: router,
|
||||
onSetVisible(val) {
|
||||
setVisible(val);
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// data?.kategoriApp === "COLLABORATION" &&
|
||||
// redirectDetailCollaborationPage({
|
||||
|
||||
@@ -8,63 +8,66 @@ import notifikasi_countUserNotifikasi from "../../fun/count/fun_count_by_id";
|
||||
import notifikasi_funUpdateIsReadById from "../../fun/update/fun_update_is_read_by_user_id";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
import { notifikasi_checkAuthorDonasiById } from "../../fun/check/fun_check_author_donasi_by_id";
|
||||
import { apiNotifikasiDonasiCheckTransaksiById } from "../../lib/api_fetch_ntf_donasi";
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
export async function redirectDonasiPage({
|
||||
appId,
|
||||
dataId,
|
||||
categoryPage,
|
||||
userId,
|
||||
userLoginId,
|
||||
router,
|
||||
onLoadDataEvent,
|
||||
onSetMenuId,
|
||||
onSetVisible,
|
||||
onLoadCountNtf,
|
||||
}: {
|
||||
appId: string;
|
||||
dataId: string;
|
||||
categoryPage: string;
|
||||
userId: string;
|
||||
userLoginId: string;
|
||||
router: AppRouterInstance;
|
||||
onLoadDataEvent: (val: any) => void;
|
||||
onSetMenuId(val: number): void;
|
||||
onSetVisible(val: boolean): void;
|
||||
onLoadCountNtf(val: number): void;
|
||||
}) {
|
||||
const check = await notifikasi_funDonasiCheckStatus({ id: appId });
|
||||
const checkAuthor = await notifikasi_checkAuthorDonasiById({
|
||||
donasiId: appId,
|
||||
userId: userId,
|
||||
});
|
||||
|
||||
if (check.status == 200) {
|
||||
// const loadListNotifikasi = await notifikasi_getByUserId({
|
||||
// page: 1,
|
||||
// kategoriApp: categoryPage as any,
|
||||
// });
|
||||
// onLoadDataEvent(loadListNotifikasi);
|
||||
|
||||
// const loadCountNotifikasi = await notifikasi_countUserNotifikasi();
|
||||
// onLoadCountNtf(loadCountNotifikasi);
|
||||
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: dataId,
|
||||
if (check.statusName == "") {
|
||||
const checkTransaksi = await apiNotifikasiDonasiCheckTransaksiById({
|
||||
id: appId,
|
||||
});
|
||||
|
||||
if (updateReadNotifikasi.status == 200) {
|
||||
const pathToCreator = `/dev/donasi/detail/${check.statusName}/${appId}`;
|
||||
const pathToAllUser = `/dev/donasi/detail/main/${appId}`;
|
||||
if (checkTransaksi.success) {
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: dataId,
|
||||
});
|
||||
|
||||
if (checkAuthor) {
|
||||
router.push(pathToCreator, { scroll: false });
|
||||
} else {
|
||||
router.push(pathToAllUser, { scroll: false });
|
||||
onSetMenuId(1);
|
||||
if (updateReadNotifikasi.status == 200) {
|
||||
router.push(RouterDonasi.main_donasi_saya, { scroll: false });
|
||||
onSetMenuId(2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
onSetVisible(false);
|
||||
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||
const checkAuthor = await notifikasi_checkAuthorDonasiById({
|
||||
donasiId: appId,
|
||||
userId: userId,
|
||||
});
|
||||
|
||||
if (check.status == 200) {
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: dataId,
|
||||
});
|
||||
|
||||
if (updateReadNotifikasi.status == 200) {
|
||||
const pathToCreator = `/dev/donasi/detail/${check.statusName}/${appId}`;
|
||||
const pathToAllUser = `/dev/donasi/detail/main/${appId}`;
|
||||
|
||||
if (checkAuthor) {
|
||||
router.push(pathToCreator, { scroll: false });
|
||||
} else {
|
||||
router.push(pathToAllUser, { scroll: false });
|
||||
onSetMenuId(1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
onSetVisible(false);
|
||||
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,33 +8,19 @@ import notifikasi_countUserNotifikasi from "../../fun/count/fun_count_by_id";
|
||||
export async function notifikasi_eventCheckStatus({
|
||||
appId,
|
||||
dataId,
|
||||
categoryPage,
|
||||
router,
|
||||
onLoadDataEvent,
|
||||
onSetEventMenuId,
|
||||
onSetVisible,
|
||||
onLoadCountNtf,
|
||||
}: {
|
||||
appId: string;
|
||||
dataId: string;
|
||||
categoryPage: string
|
||||
router: AppRouterInstance;
|
||||
onLoadDataEvent: (val: any) => void;
|
||||
onSetEventMenuId(val: number): void;
|
||||
onSetVisible(val: boolean): void;
|
||||
onLoadCountNtf(val: number): void;
|
||||
}) {
|
||||
const check = await notifikasi_funEventCheckStatus({ id: appId });
|
||||
|
||||
if (check.status == 200) {
|
||||
const loadListNotifikasi = await notifikasi_getByUserId({
|
||||
page: 1,
|
||||
kategoriApp: categoryPage as any,
|
||||
});
|
||||
onLoadDataEvent(loadListNotifikasi);
|
||||
|
||||
const loadCountNotifikasi = await notifikasi_countUserNotifikasi();
|
||||
onLoadCountNtf(loadCountNotifikasi);
|
||||
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: dataId,
|
||||
|
||||
@@ -1,26 +1,46 @@
|
||||
import { RouterForum } from "@/lib/router_hipmi/router_forum";
|
||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||
import { MODEL_NOTIFIKASI } from "../../model/interface";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
import notifikasi_funUpdateIsReadById from "../../fun/update/fun_update_is_read_by_user_id";
|
||||
|
||||
export function redirectDetailForumPage({
|
||||
export async function redirectDetailForumPage({
|
||||
data,
|
||||
router,
|
||||
onSetVisible,
|
||||
}: {
|
||||
data: MODEL_NOTIFIKASI;
|
||||
router: AppRouterInstance;
|
||||
onSetVisible(val: boolean): void;
|
||||
}) {
|
||||
if (data.status === null) {
|
||||
const path = RouterForum.main_detail + data.appId;
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
try {
|
||||
if (data.status === null) {
|
||||
const path = RouterForum.main_detail + data.appId;
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
|
||||
if (data.status === "Report Komentar") {
|
||||
const path = RouterForum.detail_report_komentar + data.appId;
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
if (data.status === "Report Komentar") {
|
||||
const path = RouterForum.detail_report_komentar + data.appId;
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
|
||||
if (data.status === "Report Posting") {
|
||||
const path = RouterForum.detail_report_posting + data.appId;
|
||||
router.push(path, { scroll: false });
|
||||
if (data.status === "Report Posting") {
|
||||
const path = RouterForum.detail_report_posting + data.appId;
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: data.id,
|
||||
});
|
||||
|
||||
if (updateReadNotifikasi.status == 200) {
|
||||
onSetVisible(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error get all forum :", error);
|
||||
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,21 +16,15 @@ import {
|
||||
export async function redirectInvestasiPage({
|
||||
appId,
|
||||
dataId,
|
||||
categoryPage,
|
||||
router,
|
||||
onLoadDataEvent,
|
||||
onSetMenuId,
|
||||
onSetVisible,
|
||||
onLoadCountNtf,
|
||||
}: {
|
||||
appId: string;
|
||||
dataId: string;
|
||||
categoryPage: string;
|
||||
router: AppRouterInstance;
|
||||
onLoadDataEvent: (val: any) => void;
|
||||
onSetMenuId(val: number): void;
|
||||
onSetVisible(val: boolean): void;
|
||||
onLoadCountNtf(val: number): void;
|
||||
}) {
|
||||
const check = await notifikasi_funInvestasiCheckStatus({ id: appId });
|
||||
const checkInvestor = await notifikasi_funInvestasiChecInvestaorStatus({
|
||||
|
||||
@@ -8,35 +8,20 @@ import notifikasi_countUserNotifikasi from "../../fun/count/fun_count_by_id";
|
||||
export async function notifikasi_jobCheckStatus({
|
||||
appId,
|
||||
dataId,
|
||||
categoryPage,
|
||||
router,
|
||||
onLoadDataJob,
|
||||
onSetJobMenuId,
|
||||
onSetVisible,
|
||||
onLoadCountNtf,
|
||||
}: {
|
||||
appId: string;
|
||||
dataId: string;
|
||||
categoryPage:string
|
||||
router: AppRouterInstance;
|
||||
onLoadDataJob: (val: any) => void;
|
||||
onSetJobMenuId(val: number): void;
|
||||
onSetVisible(val: boolean): void;
|
||||
onLoadCountNtf(val: number): void;
|
||||
}) {
|
||||
const check = await notifikasi_funJobCheckStatus({
|
||||
id: appId,
|
||||
});
|
||||
|
||||
const loadListNotifikasi = await notifikasi_getByUserId({
|
||||
page: 1,
|
||||
kategoriApp: categoryPage as any,
|
||||
});
|
||||
onLoadDataJob(loadListNotifikasi);
|
||||
|
||||
const loadCountNotifikasi = await notifikasi_countUserNotifikasi();
|
||||
onLoadCountNtf(loadCountNotifikasi);
|
||||
|
||||
if (check.status == 200) {
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: dataId,
|
||||
|
||||
@@ -10,34 +10,19 @@ import notifikasi_funUpdateIsReadById from "../../fun/update/fun_update_is_read_
|
||||
export async function notifikasi_votingCheckStatus({
|
||||
appId,
|
||||
dataId,
|
||||
categoryPage,
|
||||
router,
|
||||
onLoadDataEvent,
|
||||
onSetMenuId,
|
||||
onSetVisible,
|
||||
onLoadCountNtf,
|
||||
}: {
|
||||
appId: string;
|
||||
dataId: string;
|
||||
categoryPage: string;
|
||||
router: AppRouterInstance;
|
||||
onLoadDataEvent: (val: any) => void;
|
||||
onSetMenuId(val: number): void;
|
||||
onSetVisible(val: boolean): void;
|
||||
onLoadCountNtf(val: number): void;
|
||||
}) {
|
||||
const check = await notifikasi_funVotingCheckStatus({ id: appId });
|
||||
|
||||
if (check.status == 200) {
|
||||
const loadListNotifikasi = await notifikasi_getByUserId({
|
||||
page: 1,
|
||||
kategoriApp: categoryPage as any,
|
||||
});
|
||||
onLoadDataEvent(loadListNotifikasi);
|
||||
|
||||
const loadCountNotifikasi = await notifikasi_countUserNotifikasi();
|
||||
onLoadCountNtf(loadCountNotifikasi);
|
||||
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: dataId,
|
||||
});
|
||||
@@ -52,6 +37,4 @@ export async function notifikasi_votingCheckStatus({
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user