Fix notifikasi

Deskripsi:
- Fix notifikasi investasi
This commit is contained in:
2024-12-24 16:48:09 +08:00
parent 4a62205d8b
commit 0ca12c5318
24 changed files with 618 additions and 394 deletions

View File

@@ -8,6 +8,10 @@ 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_funInvestasiCheckStatus } from "../../fun/check/fun_check_investasi_status";
import {
notifikasi_funGetStatusTransaksiById,
notifikasi_funInvestasiChecInvestaorStatus,
} from "../../fun";
export async function redirectInvestasiPage({
appId,
@@ -29,25 +33,22 @@ export async function redirectInvestasiPage({
onLoadCountNtf(val: number): void;
}) {
const check = await notifikasi_funInvestasiCheckStatus({ id: appId });
const checkInvestor = await notifikasi_funInvestasiChecInvestaorStatus({
id: appId,
});
console.log("check", check);
console.log("check investor:", checkInvestor);
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 (updateReadNotifikasi.status == 200) {
onSetVisible(true);
onSetMenuId(1);
if (check.statusName == "publish") {
router.push(`/dev/investasi/detail/${appId}`, { scroll: false });
} else {
@@ -55,6 +56,25 @@ export async function redirectInvestasiPage({
router.push(path, { scroll: false });
}
}
} else if (checkInvestor.status == 200) {
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
notifId: dataId,
});
if (updateReadNotifikasi.status == 200) {
onSetVisible(true);
onSetMenuId(1);
if (checkInvestor.statusName == "berhasil") {
const path = `/dev/investasi/detail/saham/${appId}`;
router.push(path, { scroll: false });
}
if (checkInvestor.statusName == "gagal") {
const path = `/dev/investasi/status-transaksi/gagal/${appId}`;
router.push(path, { scroll: false });
}
}
} else {
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
}