Fix notifikasi
Deskripsi: - Fix notifikasi investasi
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
import { Admin_TablePublishInvestasi } from "@/app_modules/admin/investasi";
|
||||
import Admin_funGetAllInvestasi from "@/app_modules/admin/investasi/fun/get_all_investasi";
|
||||
|
||||
export default async function Page() {
|
||||
const listInvestasi = await Admin_funGetAllInvestasi();
|
||||
|
||||
return<>
|
||||
<Admin_TablePublishInvestasi dataInvestsi={listInvestasi as any}/>
|
||||
</>
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import { Admin_TableRejectInvestasi } from "@/app_modules/admin/investasi";
|
||||
import Admin_funGetAllInvestasi from "@/app_modules/admin/investasi/fun/get_all_investasi";
|
||||
|
||||
export default async function Page() {
|
||||
const dataInvestsi = await Admin_funGetAllInvestasi()
|
||||
return <>
|
||||
<Admin_TableRejectInvestasi dataInvestsi={dataInvestsi as any}/>
|
||||
|
||||
</>
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import { Admin_TableReviewInvestasi } from "@/app_modules/admin/investasi";
|
||||
import Admin_funGetAllInvestasi from "@/app_modules/admin/investasi/fun/get_all_investasi";
|
||||
|
||||
export default async function Page() {
|
||||
const dataInvestsi = await Admin_funGetAllInvestasi()
|
||||
return <>
|
||||
<Admin_TableReviewInvestasi dataInvestsi={dataInvestsi as any}/>
|
||||
</>
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { funGlobal_getAllBank } from "@/app_modules/_global/fun/get/fun_get_all_bank";
|
||||
import { Investasi_UiMetodePembayaran } from "@/app_modules/investasi/_ui";
|
||||
import getMaster_NamaBank from "@/app_modules/investasi/fun/master/get_nama_bank";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const investasiId = params.id;
|
||||
|
||||
@@ -13,12 +13,13 @@ export type ITypeStatusNotifikasi =
|
||||
| "Peserta Event"
|
||||
// VOTING
|
||||
| "Voting Masuk"
|
||||
// DONASI
|
||||
// DONASI & INVESTASI
|
||||
| "Berhasil"
|
||||
| "Proses"
|
||||
| "Menunggu"
|
||||
| "Gagal";
|
||||
|
||||
|
||||
/**
|
||||
* @param kategoriApp | "JOB", "VOTING", "EVENT", "DONASI", "INVESTASI", "COLLABORATION", "FORUM"
|
||||
* @type string
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { MainColor } from "@/app_modules/_global/color";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import Coba_TestLoading from "@/app_modules/zCoba";
|
||||
import {
|
||||
Avatar,
|
||||
Button,
|
||||
@@ -14,8 +12,6 @@ import {
|
||||
import { IconCamera } from "@tabler/icons-react";
|
||||
import { useState } from "react";
|
||||
import { DIRECTORY_ID } from "../lib";
|
||||
import { TokenStorage } from "../lib/token";
|
||||
import { envs } from "@/lib/envs";
|
||||
|
||||
export default function Page() {
|
||||
const [filePP, setFilePP] = useState<File | null>(null);
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
"use client";
|
||||
|
||||
import { ComponentAdminGlobal_NotifikasiBerhasil } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_berhasil";
|
||||
import { ComponentAdminGlobal_NotifikasiGagal } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_gagal";
|
||||
import { Button, Stack } from "@mantine/core";
|
||||
import { IconBan, IconCircleCheck } from "@tabler/icons-react";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
adminInvestasi_funAcceptTransaksiById,
|
||||
adminInvestasi_funGetAllTransaksiById,
|
||||
adminInvestasi_funRejectInvoiceById,
|
||||
} from "../../fun";
|
||||
import { ComponentAdminGlobal_NotifikasiBerhasil } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_berhasil";
|
||||
import { ComponentAdminGlobal_NotifikasiGagal } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_gagal";
|
||||
import { useState } from "react";
|
||||
import { IconCircleCheck } from "@tabler/icons-react";
|
||||
import { IconBan } from "@tabler/icons-react";
|
||||
import { MODEL_INVOICE_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { IRealtimeData } from "@/app/lib/global_state";
|
||||
import {
|
||||
notifikasiToAdmin_funCreate,
|
||||
notifikasiToUser_funCreate,
|
||||
} from "@/app_modules/notifikasi/fun";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
|
||||
export function AdminInvestasi_ComponentButtonKonfirmasiTransaksi({
|
||||
invoiceId,
|
||||
@@ -26,47 +33,112 @@ export function AdminInvestasi_ComponentButtonKonfirmasiTransaksi({
|
||||
const [isLoadingReject, setLoadingReject] = useState(false);
|
||||
|
||||
async function onReject() {
|
||||
const res = await adminInvestasi_funRejectInvoiceById({ invoiceId });
|
||||
if (res.status == 200) {
|
||||
try {
|
||||
const dataTransaksi = await adminInvestasi_funGetAllTransaksiById({
|
||||
investasiId,
|
||||
page: 1,
|
||||
try {
|
||||
setLoadingReject(true);
|
||||
|
||||
const res = await adminInvestasi_funRejectInvoiceById({ invoiceId });
|
||||
if (res.status == 200) {
|
||||
const notifikasiInvestor: IRealtimeData = {
|
||||
appId: invoiceId as string,
|
||||
userId: res.userId as string,
|
||||
status: res.statusName as any,
|
||||
pesan: "Transaksi anda gagal, coba hubungi admin",
|
||||
kategoriApp: "INVESTASI",
|
||||
title: "Transaksi Gagal",
|
||||
};
|
||||
|
||||
const notifToInvestor = await notifikasiToUser_funCreate({
|
||||
data: notifikasiInvestor as any,
|
||||
});
|
||||
onLoadData(dataTransaksi);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
||||
setLoadingReject(true);
|
||||
|
||||
if (notifToInvestor.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: notifikasiInvestor,
|
||||
});
|
||||
|
||||
const dataTransaksi = await adminInvestasi_funGetAllTransaksiById({
|
||||
investasiId,
|
||||
page: 1,
|
||||
});
|
||||
onLoadData(dataTransaksi);
|
||||
|
||||
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
||||
}
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||
} catch (error) {
|
||||
clientLogger.error("Error rejected investasi:", error);
|
||||
} finally {
|
||||
setLoadingReject(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function onAccept() {
|
||||
const res = await adminInvestasi_funAcceptTransaksiById({
|
||||
invoiceId,
|
||||
investasiId,
|
||||
lembarTerbeli,
|
||||
});
|
||||
try {
|
||||
setLoadingAccept(true);
|
||||
const res = await adminInvestasi_funAcceptTransaksiById({
|
||||
invoiceId,
|
||||
investasiId,
|
||||
lembarTerbeli,
|
||||
});
|
||||
|
||||
if (res.status == 200) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: investasiId,
|
||||
status: res.data?.dataInvestasi?.MasterStatusInvestasi?.name as any,
|
||||
userId: res.data?.dataInvestasi.authorId as string,
|
||||
pesan: "Cek investasi anda, Anda memiliki investor baru",
|
||||
kategoriApp: "INVESTASI",
|
||||
title: "Investor baru",
|
||||
};
|
||||
|
||||
const notif = await notifikasiToUser_funCreate({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
}
|
||||
|
||||
const notifikasiInvestor: IRealtimeData = {
|
||||
appId: res.data?.dataInvestor.id as string,
|
||||
status: "Berhasil",
|
||||
userId: res.data?.dataInvestor.authorId as string,
|
||||
pesan: "Selamat, anda telah menjadi investor baru",
|
||||
kategoriApp: "INVESTASI",
|
||||
title: "Investasi berhasil",
|
||||
};
|
||||
|
||||
const notifToInvestor = await notifikasiToUser_funCreate({
|
||||
data: notifikasiInvestor as any,
|
||||
});
|
||||
|
||||
if (notifToInvestor.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: notifikasiInvestor,
|
||||
});
|
||||
}
|
||||
|
||||
if (res.status == 200) {
|
||||
try {
|
||||
const dataTransaksi = await adminInvestasi_funGetAllTransaksiById({
|
||||
investasiId,
|
||||
page: 1,
|
||||
});
|
||||
onLoadData(dataTransaksi);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
||||
setLoadingAccept(true);
|
||||
}
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||
} catch (error) {
|
||||
clientLogger.error("Error accept invoice", error);
|
||||
} finally {
|
||||
setLoadingAccept(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,6 @@ export function AdminInvestasi_DetailPublish({
|
||||
investasiId={investasiId}
|
||||
/>
|
||||
) : null}
|
||||
{/* {selectPage == "3" ? <AdminInvestasi_ViewDaftarInvestor /> : null} */}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -60,15 +60,26 @@ export async function adminInvestasi_funAcceptTransaksiById({
|
||||
lembarTerbeli: resultLembarTerbeli.toString(),
|
||||
progress: resultProgres,
|
||||
},
|
||||
include: {
|
||||
MasterStatusInvestasi: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!updateInvestasi)
|
||||
return { status: 400, message: "Gagal Update Data Investasi" };
|
||||
|
||||
const newData = updateInvestasi;
|
||||
|
||||
const allData = {
|
||||
dataInvestasi: updateInvestasi,
|
||||
dataInvestor: updt,
|
||||
};
|
||||
|
||||
revalidatePath(RouterAdminInvestasi.detail_publish);
|
||||
return {
|
||||
status: 200,
|
||||
message: "Update Berhasil",
|
||||
data: allData,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,6 @@ export async function adminInvestasi_funRejectInvoiceById({
|
||||
}: {
|
||||
invoiceId: string;
|
||||
}) {
|
||||
|
||||
|
||||
|
||||
const updt = await prisma.investasi_Invoice.update({
|
||||
where: {
|
||||
id: invoiceId,
|
||||
@@ -19,12 +16,19 @@ export async function adminInvestasi_funRejectInvoiceById({
|
||||
data: {
|
||||
statusInvoiceId: "4",
|
||||
},
|
||||
select: {
|
||||
StatusInvoice: true,
|
||||
authorId: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!updt) return { status: 400, message: "Gagal Update" };
|
||||
if (!updt)
|
||||
return { status: 400, message: "Gagal Melakukan Reject", statusName: "" , userId: ""};
|
||||
revalidatePath(RouterAdminInvestasi.detail_publish);
|
||||
return {
|
||||
status: 200,
|
||||
message: "Update Berhasil",
|
||||
message: "Reject Berhasil",
|
||||
statusName: updt.StatusInvoice?.name,
|
||||
userId: updt.authorId,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -62,12 +62,7 @@ function TableView({ listData }: { listData: any }) {
|
||||
useShallowEffect(() => {
|
||||
if (isAdminInvestasi_TriggerReview) {
|
||||
setIsShowReload(false);
|
||||
}
|
||||
}, [isAdminInvestasi_TriggerReview]);
|
||||
|
||||
useShallowEffect(() => {
|
||||
if (isAdminInvestasi_TriggerReview) {
|
||||
setIsShowReload(true);
|
||||
setIsAdminInvestasi_TriggerReview(false)
|
||||
}
|
||||
}, [isAdminInvestasi_TriggerReview]);
|
||||
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
import { RouterAdminDonasi } from "@/app/lib/router_admin/router_admin_donasi";
|
||||
import { RouterAdminDonasi_OLD } from "@/app/lib/router_hipmi/router_admin";
|
||||
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
||||
import { data } from "autoprefixer";
|
||||
import _ from "lodash";
|
||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||
import { IAdmin_ActivePage, IAdmin_ActiveChildId } from "./type_of_select_page";
|
||||
import { admin_funDonasiCheckStatus } from "../fun/get/fun_donasi_check_status";
|
||||
import adminNotifikasi_funUpdateIsReadById from "../fun/update/fun_update_is_read_by_id";
|
||||
import adminNotifikasi_countNotifikasi from "../fun/count/count_is_read";
|
||||
import adminNotifikasi_getByUserId from "../fun/get/get_notifikasi_by_user_id";
|
||||
import { ComponentAdminGlobal_NotifikasiPeringatan } from "../../_admin_global/admin_notifikasi/notifikasi_peringatan";
|
||||
import { ITypeStatusNotifikasi } from "@/app/lib/global_state";
|
||||
import { RouterAdminDonasi_OLD } from "@/app/lib/router_hipmi/router_admin";
|
||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||
import { ComponentAdminGlobal_NotifikasiPeringatan } from "../../_admin_global/admin_notifikasi/notifikasi_peringatan";
|
||||
import adminNotifikasi_countNotifikasi from "../fun/count/count_is_read";
|
||||
import { admin_funDonasiCheckStatus } from "../fun/get/fun_donasi_check_status";
|
||||
import adminNotifikasi_getByUserId from "../fun/get/get_notifikasi_by_user_id";
|
||||
import adminNotifikasi_funUpdateIsReadById from "../fun/update/fun_update_is_read_by_id";
|
||||
import { IAdmin_ActiveChildId, IAdmin_ActivePage } from "./type_of_select_page";
|
||||
|
||||
export default async function adminNotifikasi_findRouterDonasi({
|
||||
appId,
|
||||
@@ -38,13 +34,29 @@ export default async function adminNotifikasi_findRouterDonasi({
|
||||
status == "Proses" ||
|
||||
status == "Gagal"
|
||||
) {
|
||||
const path = RouterAdminDonasi_OLD.detail_publish + appId;
|
||||
router.push(path, { scroll: false });
|
||||
onChangeNavbar({
|
||||
id: "Donasi",
|
||||
childId: "Donasi_2",
|
||||
const udpateReadNotifikasi = await adminNotifikasi_funUpdateIsReadById({
|
||||
notifId: notifikasiId,
|
||||
});
|
||||
|
||||
if (udpateReadNotifikasi.status == 200) {
|
||||
const loadCountNotif = await adminNotifikasi_countNotifikasi();
|
||||
onLoadCountNotif(loadCountNotif);
|
||||
|
||||
const loadListNotifikasi = await adminNotifikasi_getByUserId({
|
||||
page: 1,
|
||||
});
|
||||
onLoadDataNotifikasi(loadListNotifikasi);
|
||||
const path = RouterAdminDonasi_OLD.detail_publish + appId;
|
||||
router.push(path, { scroll: false });
|
||||
onChangeNavbar({
|
||||
id: "Donasi",
|
||||
childId: "Donasi_2",
|
||||
});
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
const check = await admin_funDonasiCheckStatus({ id: appId });
|
||||
|
||||
@@ -6,6 +6,7 @@ import { admin_funInvestasiCheckStatus } from "../fun/get/fun_investasi_check_st
|
||||
import adminNotifikasi_getByUserId from "../fun/get/get_notifikasi_by_user_id";
|
||||
import adminNotifikasi_funUpdateIsReadById from "../fun/update/fun_update_is_read_by_id";
|
||||
import { IAdmin_ActiveChildId, IAdmin_ActivePage } from "./type_of_select_page";
|
||||
import { RouterAdminInvestasi } from "@/app/lib/router_admin/router_admin_investasi";
|
||||
|
||||
export default async function adminNotifikasi_findRouterInvestasi({
|
||||
appId,
|
||||
@@ -27,13 +28,15 @@ export default async function adminNotifikasi_findRouterInvestasi({
|
||||
childId: IAdmin_ActiveChildId;
|
||||
}) => void;
|
||||
}) {
|
||||
const check = await admin_funInvestasiCheckStatus({ id: appId });
|
||||
|
||||
if (check.status == 200) {
|
||||
if (
|
||||
status == "Menunggu" ||
|
||||
status == "Berhasil" ||
|
||||
status == "Proses" ||
|
||||
status == "Gagal"
|
||||
) {
|
||||
const udpateReadNotifikasi = await adminNotifikasi_funUpdateIsReadById({
|
||||
notifId: notifikasiId,
|
||||
});
|
||||
|
||||
if (udpateReadNotifikasi.status == 200) {
|
||||
const loadCountNotif = await adminNotifikasi_countNotifikasi();
|
||||
onLoadCountNotif(loadCountNotif);
|
||||
@@ -42,59 +45,72 @@ export default async function adminNotifikasi_findRouterInvestasi({
|
||||
page: 1,
|
||||
});
|
||||
onLoadDataNotifikasi(loadListNotifikasi);
|
||||
const path = RouterAdminInvestasi.detail_publish + appId;
|
||||
router.push(path, { scroll: false });
|
||||
|
||||
const path = `/dev/admin/investasi/sub-menu/${check.statusName}`;
|
||||
|
||||
if (check.statusName == "draft") {
|
||||
ComponentAdminGlobal_NotifikasiPeringatan(
|
||||
"Status telah dirubah oleh user"
|
||||
);
|
||||
} else {
|
||||
if (check.statusName == "publish") {
|
||||
onChangeNavbar({
|
||||
id: "Investasi",
|
||||
childId: "Investasi_2",
|
||||
});
|
||||
}
|
||||
|
||||
if (check.statusName == "review") {
|
||||
onChangeNavbar({
|
||||
id: "Investasi",
|
||||
childId: "Investasi_3",
|
||||
});
|
||||
}
|
||||
|
||||
if (check.statusName == "reject") {
|
||||
onChangeNavbar({
|
||||
id: "Investasi",
|
||||
childId: "Investasi_4",
|
||||
});
|
||||
}
|
||||
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
onChangeNavbar({
|
||||
id: "Investasi",
|
||||
childId: "Investasi_2",
|
||||
});
|
||||
|
||||
return true;
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||
return false;
|
||||
const check = await admin_funInvestasiCheckStatus({ id: appId });
|
||||
|
||||
if (check.status == 200) {
|
||||
const udpateReadNotifikasi = await adminNotifikasi_funUpdateIsReadById({
|
||||
notifId: notifikasiId,
|
||||
});
|
||||
|
||||
if (udpateReadNotifikasi.status == 200) {
|
||||
const loadCountNotif = await adminNotifikasi_countNotifikasi();
|
||||
onLoadCountNotif(loadCountNotif);
|
||||
|
||||
const loadListNotifikasi = await adminNotifikasi_getByUserId({
|
||||
page: 1,
|
||||
});
|
||||
onLoadDataNotifikasi(loadListNotifikasi);
|
||||
|
||||
const path = `/dev/admin/investasi/sub-menu/${check.statusName}`;
|
||||
|
||||
if (check.statusName == "draft") {
|
||||
ComponentAdminGlobal_NotifikasiPeringatan(
|
||||
"Status telah dirubah oleh user"
|
||||
);
|
||||
} else {
|
||||
if (check.statusName == "publish") {
|
||||
onChangeNavbar({
|
||||
id: "Investasi",
|
||||
childId: "Investasi_2",
|
||||
});
|
||||
}
|
||||
|
||||
if (check.statusName == "review") {
|
||||
onChangeNavbar({
|
||||
id: "Investasi",
|
||||
childId: "Investasi_3",
|
||||
});
|
||||
}
|
||||
|
||||
if (check.statusName == "reject") {
|
||||
onChangeNavbar({
|
||||
id: "Investasi",
|
||||
childId: "Investasi_4",
|
||||
});
|
||||
}
|
||||
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// if (
|
||||
// status == "Menunggu" ||
|
||||
// status == "Berhasil" ||
|
||||
// status == "Proses" ||
|
||||
// status == "Gagal"
|
||||
// ) {
|
||||
// const path = RouterAdminDonasi_OLD.detail_publish + appId;
|
||||
// router.push(path, { scroll: false });
|
||||
// onChangeNavbar({
|
||||
// id: "Donasi",
|
||||
// childId: "Donasi_2",
|
||||
// });
|
||||
|
||||
// return true;
|
||||
// } else {
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -13,18 +13,16 @@ import { IconCheck, IconChecks } from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { ComponentAdminGlobal_NotifikasiPeringatan } from "../_admin_global/admin_notifikasi/notifikasi_peringatan";
|
||||
import adminNotifikasi_countNotifikasi from "./fun/count/count_is_read";
|
||||
import adminNotifikasi_getByUserId from "./fun/get/get_notifikasi_by_user_id";
|
||||
import adminNotifikasi_findRouterDonasi from "./route_setting/donasi";
|
||||
import { adminNotifikasi_findRouterEvent } from "./route_setting/event";
|
||||
import adminNotifikasi_findRouterInvestasi from "./route_setting/investasi";
|
||||
import { adminNotifikasi_findRouterJob } from "./route_setting/job";
|
||||
import {
|
||||
IAdmin_ActiveChildId,
|
||||
IAdmin_ActivePage,
|
||||
} from "./route_setting/type_of_select_page";
|
||||
import { adminNotifikasi_findRouterVoting } from "./route_setting/voting";
|
||||
import adminNotifikasi_findRouterDonasi from "./route_setting/donasi";
|
||||
import adminNotifikasi_findRouterInvestasi from "./route_setting/investasi";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
|
||||
export default function AdminNotifikasi_ViewCardDrawer({
|
||||
data,
|
||||
@@ -64,199 +62,200 @@ export default function AdminNotifikasi_ViewCardDrawer({
|
||||
|
||||
async function onRead() {
|
||||
// ========================== JOB ========================== //
|
||||
if (data?.kategoriApp === "JOB") {
|
||||
try {
|
||||
setVisible(true);
|
||||
setDataId(data.id);
|
||||
|
||||
const checkJob = await adminNotifikasi_findRouterJob({
|
||||
appId: data.appId,
|
||||
notifikasiId: data.id,
|
||||
router: router,
|
||||
activePage: activePage,
|
||||
onLoadCountNotif(val) {
|
||||
onLoadCountNotif(val);
|
||||
},
|
||||
onLoadDataNotifikasi(val) {
|
||||
onLoadDataNotifikasi(val);
|
||||
},
|
||||
onChangeNavbar(val) {
|
||||
onChangeNavbar({
|
||||
id: val.id,
|
||||
childId: val.childId,
|
||||
});
|
||||
},
|
||||
});
|
||||
if (data?.kategoriApp === "JOB") {
|
||||
setDataId(data.id);
|
||||
|
||||
if (checkJob) {
|
||||
setIsAdminJob_TriggerReview(false);
|
||||
setVisible(false);
|
||||
setDataId("");
|
||||
onToggleNavbar(false);
|
||||
const checkJob = await adminNotifikasi_findRouterJob({
|
||||
appId: data.appId,
|
||||
notifikasiId: data.id,
|
||||
router: router,
|
||||
activePage: activePage,
|
||||
onLoadCountNotif(val) {
|
||||
onLoadCountNotif(val);
|
||||
},
|
||||
onLoadDataNotifikasi(val) {
|
||||
onLoadDataNotifikasi(val);
|
||||
},
|
||||
onChangeNavbar(val) {
|
||||
onChangeNavbar({
|
||||
id: val.id,
|
||||
childId: val.childId,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
if (checkJob) {
|
||||
setIsAdminJob_TriggerReview(false);
|
||||
setVisible(false);
|
||||
setDataId("");
|
||||
onToggleNavbar(false);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
// ========================== JOB ========================== //
|
||||
// ========================== JOB ========================== //
|
||||
|
||||
// ========================== EVENT ========================== //
|
||||
// ========================== EVENT ========================== //
|
||||
|
||||
if (data.kategoriApp == "EVENT") {
|
||||
setVisible(true);
|
||||
setDataId(data.id);
|
||||
if (data.kategoriApp == "EVENT") {
|
||||
setDataId(data.id);
|
||||
|
||||
const checkEvent = await adminNotifikasi_findRouterEvent({
|
||||
appId: data.appId,
|
||||
notifikasiId: data.id,
|
||||
router: router,
|
||||
activePage: activePage,
|
||||
onLoadCountNotif(val) {
|
||||
onLoadCountNotif(val);
|
||||
},
|
||||
onLoadDataNotifikasi(val) {
|
||||
onLoadDataNotifikasi(val);
|
||||
},
|
||||
onChangeNavbar(val) {
|
||||
onChangeNavbar({
|
||||
id: val.id,
|
||||
childId: val.childId,
|
||||
});
|
||||
},
|
||||
});
|
||||
const checkEvent = await adminNotifikasi_findRouterEvent({
|
||||
appId: data.appId,
|
||||
notifikasiId: data.id,
|
||||
router: router,
|
||||
activePage: activePage,
|
||||
onLoadCountNotif(val) {
|
||||
onLoadCountNotif(val);
|
||||
},
|
||||
onLoadDataNotifikasi(val) {
|
||||
onLoadDataNotifikasi(val);
|
||||
},
|
||||
onChangeNavbar(val) {
|
||||
onChangeNavbar({
|
||||
id: val.id,
|
||||
childId: val.childId,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
if (checkEvent) {
|
||||
setIsAdminEvent_TriggerReview(false);
|
||||
setVisible(false);
|
||||
setDataId("");
|
||||
onToggleNavbar(false);
|
||||
if (checkEvent) {
|
||||
setIsAdminEvent_TriggerReview(false);
|
||||
setVisible(false);
|
||||
setDataId("");
|
||||
onToggleNavbar(false);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
// ========================== EVENT ========================== //
|
||||
// ========================== EVENT ========================== //
|
||||
|
||||
// ========================== VOTING ========================== //
|
||||
// ========================== VOTING ========================== //
|
||||
|
||||
if (data.kategoriApp == "VOTING") {
|
||||
setVisible(true);
|
||||
setDataId(data.id);
|
||||
if (data.kategoriApp == "VOTING") {
|
||||
setDataId(data.id);
|
||||
|
||||
const checkVoting = await adminNotifikasi_findRouterVoting({
|
||||
router: router,
|
||||
appId: data.appId,
|
||||
notifikasiId: data.id,
|
||||
activePage: activePage,
|
||||
onLoadCountNotif(val) {
|
||||
onLoadCountNotif(val);
|
||||
},
|
||||
onLoadDataNotifikasi(val) {
|
||||
onLoadDataNotifikasi(val);
|
||||
},
|
||||
onChangeNavbar(val) {
|
||||
onChangeNavbar({
|
||||
id: val.id,
|
||||
childId: val.childId,
|
||||
});
|
||||
},
|
||||
});
|
||||
const checkVoting = await adminNotifikasi_findRouterVoting({
|
||||
router: router,
|
||||
appId: data.appId,
|
||||
notifikasiId: data.id,
|
||||
activePage: activePage,
|
||||
onLoadCountNotif(val) {
|
||||
onLoadCountNotif(val);
|
||||
},
|
||||
onLoadDataNotifikasi(val) {
|
||||
onLoadDataNotifikasi(val);
|
||||
},
|
||||
onChangeNavbar(val) {
|
||||
onChangeNavbar({
|
||||
id: val.id,
|
||||
childId: val.childId,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
if (checkVoting) {
|
||||
setIsAdminVoting_TriggerReview(false);
|
||||
setVisible(false);
|
||||
setDataId("");
|
||||
onToggleNavbar(false);
|
||||
if (checkVoting) {
|
||||
setIsAdminVoting_TriggerReview(false);
|
||||
setVisible(false);
|
||||
setDataId("");
|
||||
onToggleNavbar(false);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
// ========================== VOTING ========================== //
|
||||
// ========================== VOTING ========================== //
|
||||
|
||||
// ========================== DONASI ========================== //
|
||||
// ========================== DONASI ========================== //
|
||||
|
||||
if (data.kategoriApp == "DONASI") {
|
||||
setVisible(true);
|
||||
setDataId(data.id);
|
||||
if (data.kategoriApp == "DONASI") {
|
||||
setDataId(data.id);
|
||||
|
||||
const checkDonasi = await adminNotifikasi_findRouterDonasi({
|
||||
appId: data.appId,
|
||||
notifikasiId: data.id,
|
||||
router: router,
|
||||
status: data.status as ITypeStatusNotifikasi,
|
||||
onLoadCountNotif(val) {
|
||||
onLoadCountNotif(val);
|
||||
},
|
||||
onLoadDataNotifikasi(val) {
|
||||
onLoadDataNotifikasi(val);
|
||||
},
|
||||
onChangeNavbar(val) {
|
||||
onChangeNavbar({
|
||||
id: val.id,
|
||||
childId: val.childId,
|
||||
});
|
||||
},
|
||||
});
|
||||
const checkDonasi = await adminNotifikasi_findRouterDonasi({
|
||||
appId: data.appId,
|
||||
notifikasiId: data.id,
|
||||
router: router,
|
||||
status: data.status as ITypeStatusNotifikasi,
|
||||
onLoadCountNotif(val) {
|
||||
onLoadCountNotif(val);
|
||||
},
|
||||
onLoadDataNotifikasi(val) {
|
||||
onLoadDataNotifikasi(val);
|
||||
},
|
||||
onChangeNavbar(val) {
|
||||
onChangeNavbar({
|
||||
id: val.id,
|
||||
childId: val.childId,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
if (checkDonasi) {
|
||||
setIsAdminDonasi_TriggerReview(false);
|
||||
setVisible(false);
|
||||
setDataId("");
|
||||
onToggleNavbar(false);
|
||||
if (checkDonasi) {
|
||||
setIsAdminDonasi_TriggerReview(false);
|
||||
setVisible(false);
|
||||
setDataId("");
|
||||
onToggleNavbar(false);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// ========================== DONASI ========================== //
|
||||
// ========================== DONASI ========================== //
|
||||
|
||||
// ========================== INVESTASI ========================== //
|
||||
// ========================== INVESTASI ========================== //
|
||||
|
||||
if (data.kategoriApp == "INVESTASI") {
|
||||
setVisible(true);
|
||||
setDataId(data.id);
|
||||
if (data.kategoriApp == "INVESTASI") {
|
||||
setDataId(data.id);
|
||||
|
||||
const checkInvestasi = await adminNotifikasi_findRouterInvestasi({
|
||||
appId: data.appId,
|
||||
notifikasiId: data.id,
|
||||
status: data.status as ITypeStatusNotifikasi,
|
||||
router: router,
|
||||
onLoadCountNotif(val) {
|
||||
onLoadCountNotif(val);
|
||||
},
|
||||
onLoadDataNotifikasi(val) {
|
||||
onLoadDataNotifikasi(val);
|
||||
},
|
||||
onChangeNavbar(val) {
|
||||
onChangeNavbar({
|
||||
id: val.id,
|
||||
childId: val.childId,
|
||||
});
|
||||
},
|
||||
});
|
||||
const checkInvestasi = await adminNotifikasi_findRouterInvestasi({
|
||||
appId: data.appId,
|
||||
notifikasiId: data.id,
|
||||
status: data.status as ITypeStatusNotifikasi,
|
||||
router: router,
|
||||
onLoadCountNotif(val) {
|
||||
onLoadCountNotif(val);
|
||||
},
|
||||
onLoadDataNotifikasi(val) {
|
||||
onLoadDataNotifikasi(val);
|
||||
},
|
||||
onChangeNavbar(val) {
|
||||
onChangeNavbar({
|
||||
id: val.id,
|
||||
childId: val.childId,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
if (checkInvestasi) {
|
||||
setIsAdminDonasi_TriggerReview(false);
|
||||
setVisible(false);
|
||||
setDataId("");
|
||||
onToggleNavbar(false);
|
||||
if (checkInvestasi) {
|
||||
setIsAdminDonasi_TriggerReview(false);
|
||||
setVisible(false);
|
||||
setDataId("");
|
||||
onToggleNavbar(false);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// // FORUM
|
||||
// e?.kategoriApp === "FORUM" &&
|
||||
// adminNotifikasi_findRouterForum({
|
||||
// data: e,
|
||||
// router: router,
|
||||
// onChangeNavbar(val) {
|
||||
// onChangeNavbar(val);
|
||||
// },
|
||||
// onToggleNavbar(val) {
|
||||
// onToggleNavbar(val);
|
||||
// },
|
||||
// });
|
||||
|
||||
} catch (error) {
|
||||
clientLogger.error("Error notifikasi function", error);
|
||||
} finally {
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
// // FORUM
|
||||
// e?.kategoriApp === "FORUM" &&
|
||||
// adminNotifikasi_findRouterForum({
|
||||
// data: e,
|
||||
// router: router,
|
||||
// onChangeNavbar(val) {
|
||||
// onChangeNavbar(val);
|
||||
// },
|
||||
// onToggleNavbar(val) {
|
||||
// onToggleNavbar(val);
|
||||
// },
|
||||
// });
|
||||
|
||||
// // VOTE
|
||||
// e?.kategoriApp === "VOTING" &&
|
||||
// adminNotifikasi_findRouterVoting({
|
||||
// data: e,
|
||||
// router: router,
|
||||
// onChangeNavbar(val) {
|
||||
// onChangeNavbar(val);
|
||||
// },
|
||||
// onToggleNavbar(val) {
|
||||
// onToggleNavbar(val);
|
||||
// },
|
||||
// });
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
"use client";
|
||||
|
||||
import { RouterAdminInvestasi } from "@/app/lib/router_admin/router_admin_investasi";
|
||||
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { ComponentGlobal_LoadImage, ComponentGlobal_TampilanRupiah } from "@/app_modules/_global/component";
|
||||
import {
|
||||
ComponentGlobal_LoadImage,
|
||||
ComponentGlobal_TampilanRupiah,
|
||||
} from "@/app_modules/_global/component";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Collapse,
|
||||
Grid,
|
||||
Group,
|
||||
Image,
|
||||
Paper,
|
||||
Stack,
|
||||
Text,
|
||||
Title
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { IconBrandCashapp } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
@@ -157,12 +158,7 @@ export function Investasi_ViewTransaksiBerhasil({
|
||||
transitionDuration={500}
|
||||
transitionTimingFunction="linear"
|
||||
>
|
||||
|
||||
<ComponentGlobal_LoadImage fileId={data.imageId}/>
|
||||
{/* <Image
|
||||
alt="foto"
|
||||
src={RouterAdminInvestasi.api_bukti_transfer + data?.imagesId}
|
||||
/> */}
|
||||
<ComponentGlobal_LoadImage fileId={data.imageId} />
|
||||
</Collapse>
|
||||
</Stack>
|
||||
</Paper>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { RouterAdminInvestasi } from "@/app/lib/router_admin/router_admin_investasi";
|
||||
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { ComponentGlobal_TampilanRupiah } from "@/app_modules/_global/component";
|
||||
import { ComponentGlobal_LoadImage, ComponentGlobal_TampilanRupiah } from "@/app_modules/_global/component";
|
||||
import {
|
||||
ActionIcon,
|
||||
Box,
|
||||
@@ -170,10 +170,7 @@ export function Investasi_ViewTransaksiGagal({
|
||||
transitionDuration={500}
|
||||
transitionTimingFunction="linear"
|
||||
>
|
||||
<Image
|
||||
alt="foto"
|
||||
src={RouterAdminInvestasi.api_bukti_transfer + data?.imagesId}
|
||||
/>
|
||||
<ComponentGlobal_LoadImage fileId={data.imageId} />
|
||||
</Collapse>
|
||||
</Stack>
|
||||
</Paper>
|
||||
|
||||
@@ -28,6 +28,10 @@ import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_glo
|
||||
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
||||
import { DIRECTORY_ID } from "@/app/lib";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
import { IRealtimeData } from "@/app/lib/global_state";
|
||||
import { notifikasiToAdmin_funCreate } from "@/app_modules/notifikasi/fun";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
|
||||
export function Investasi_ViewInvoice({
|
||||
dataInvoice,
|
||||
@@ -40,25 +44,59 @@ export function Investasi_ViewInvoice({
|
||||
const [file, setFile] = useState<File | null>(null);
|
||||
|
||||
async function onUpload() {
|
||||
const uploadFileToStorage = await funGlobal_UploadToStorage({
|
||||
file: file as any,
|
||||
dirId: DIRECTORY_ID.investasi_bukti_transfer,
|
||||
});
|
||||
try {
|
||||
setLoading(true);
|
||||
const uploadFileToStorage = await funGlobal_UploadToStorage({
|
||||
file: file as any,
|
||||
dirId: DIRECTORY_ID.investasi_bukti_transfer,
|
||||
});
|
||||
|
||||
if (!uploadFileToStorage.success)
|
||||
return ComponentGlobal_NotifikasiPeringatan("Gagal upload bukti transfer")
|
||||
if (!uploadFileToStorage.success) {
|
||||
ComponentGlobal_NotifikasiPeringatan("Gagal upload bukti transfer");
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await investasi_funUploadBuktiTransferById({
|
||||
invoiceId: data.id,
|
||||
fileId: uploadFileToStorage.data.id,
|
||||
});
|
||||
const res = await investasi_funUploadBuktiTransferById({
|
||||
invoiceId: data.id,
|
||||
fileId: uploadFileToStorage.data.id,
|
||||
});
|
||||
|
||||
if (res.status !== 200) return ComponentGlobal_NotifikasiGagal(res.message);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setLoading(true);
|
||||
router.push(NEW_RouterInvestasi.proses_transaksi + data.id, {
|
||||
scroll: false,
|
||||
});
|
||||
if (res.status != 200) {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
return;
|
||||
}
|
||||
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: dataInvoice.Investasi.id,
|
||||
status: "Proses",
|
||||
userId: dataInvoice.authorId as string,
|
||||
pesan: "Bukti transfer telah diupload",
|
||||
kategoriApp: "INVESTASI",
|
||||
title: "Invoice baru",
|
||||
};
|
||||
|
||||
const notif = await notifikasiToAdmin_funCreate({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "ADMIN",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
|
||||
router.push(NEW_RouterInvestasi.proses_transaksi + data.id, {
|
||||
scroll: false,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error(" Error upload invoice", error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
import { IRealtimeData } from "@/app/lib/global_state";
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import {
|
||||
AccentColor,
|
||||
MainColor,
|
||||
} from "@/app_modules/_global/color/color_pallet";
|
||||
import { Button, Paper, Radio, Stack, Text, Title } from "@mantine/core";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||
import { notifikasiToAdmin_funCreate } from "@/app_modules/notifikasi/fun";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { Button, Paper, Radio, Stack, Title } from "@mantine/core";
|
||||
import { useLocalStorage } from "@mantine/hooks";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { MODEL_MASTER_BANK } from "../../_lib/interface";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
import { investasi_funCreateInvoice } from "../../_fun/create/fun_create_invoice";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { data } from "autoprefixer";
|
||||
import { MODEL_MASTER_BANK } from "../../_lib/interface";
|
||||
|
||||
export function Investasi_ViewMetodePembayaran({
|
||||
listBank,
|
||||
@@ -34,20 +37,50 @@ export function Investasi_ViewMetodePembayaran({
|
||||
});
|
||||
|
||||
async function onProses() {
|
||||
const res = await investasi_funCreateInvoice({
|
||||
data: {
|
||||
total: total,
|
||||
pilihBank: pilihBank,
|
||||
investasiId: investasiId,
|
||||
jumlah: jumlah,
|
||||
},
|
||||
});
|
||||
try {
|
||||
const res = await investasi_funCreateInvoice({
|
||||
data: {
|
||||
total: total,
|
||||
pilihBank: pilihBank,
|
||||
investasiId: investasiId,
|
||||
jumlah: jumlah,
|
||||
},
|
||||
});
|
||||
|
||||
if (res.status !== 201)
|
||||
return ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setLoading(true);
|
||||
router.push(NEW_RouterInvestasi.invoice + res.data?.id, { scroll: false });
|
||||
if (res.status != 201) {
|
||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||
return;
|
||||
}
|
||||
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: investasiId,
|
||||
status: "Menunggu",
|
||||
userId: res.data?.authorId as string,
|
||||
pesan: "Menunggu transfer",
|
||||
kategoriApp: "INVESTASI",
|
||||
title: "Transaksi baru",
|
||||
};
|
||||
|
||||
const notif = await notifikasiToAdmin_funCreate({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "ADMIN",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setLoading(true);
|
||||
router.push(NEW_RouterInvestasi.invoice + res.data?.id, {
|
||||
scroll: false,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error create invoice:", error);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ export async function notifikasi_funInvestasiCheckStatus({
|
||||
message: "Investasi tidak ditemukan",
|
||||
statusName: "",
|
||||
};
|
||||
|
||||
return {
|
||||
status: 200,
|
||||
message: "Berhasil di cek",
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import _ from "lodash";
|
||||
|
||||
export async function notifikasi_funInvestasiChecInvestaorStatus({
|
||||
id,
|
||||
}: {
|
||||
id: string;
|
||||
}) {
|
||||
const data = await prisma.investasi_Invoice.findUnique({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
select: {
|
||||
StatusInvoice: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!data)
|
||||
return {
|
||||
status: 400,
|
||||
message: "Investasi tidak ditemukan",
|
||||
statusName: "",
|
||||
};
|
||||
|
||||
return {
|
||||
status: 200,
|
||||
message: "Berhasil di cek",
|
||||
statusName: _.lowerCase(data.StatusInvoice?.name),
|
||||
};
|
||||
}
|
||||
@@ -2,23 +2,29 @@
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { MODEL_NOTIFIKASI } from "../../model/interface";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
|
||||
export default async function notifikasiToUser_funCreate({
|
||||
data,
|
||||
}: {
|
||||
data: MODEL_NOTIFIKASI;
|
||||
}) {
|
||||
const created = await prisma.notifikasi.create({
|
||||
data: {
|
||||
userId: data.userId,
|
||||
appId: data.appId,
|
||||
status: data.status,
|
||||
title: data.title,
|
||||
pesan: data.pesan,
|
||||
kategoriApp: data.kategoriApp,
|
||||
userRoleId: "1",
|
||||
},
|
||||
});
|
||||
if (!created) return { status: 400, message: "Gagal mengirim notifikasi" };
|
||||
return { status: 201, message: "Berhasil mengirim notifikasi" };
|
||||
try {
|
||||
const created = await prisma.notifikasi.create({
|
||||
data: {
|
||||
userId: data.userId,
|
||||
appId: data.appId,
|
||||
status: data.status,
|
||||
title: data.title,
|
||||
pesan: data.pesan,
|
||||
kategoriApp: data.kategoriApp,
|
||||
userRoleId: "1",
|
||||
},
|
||||
});
|
||||
if (!created) return { status: 400, message: "Gagal mengirim notifikasi" };
|
||||
return { status: 201, message: "Berhasil mengirim notifikasi" };
|
||||
} catch (error) {
|
||||
backendLogger.error("Gagal mengirim notifikasi", error);
|
||||
return { status: 401, message: "Error server" };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export default async function notifikasi_funGetStatusTransaksiById({
|
||||
notifId,
|
||||
}: {
|
||||
notifId: string;
|
||||
}) {
|
||||
const data = await prisma.notifikasi.findFirst({
|
||||
where: {
|
||||
id: notifId,
|
||||
},
|
||||
select: {
|
||||
status: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
if (!data) return { status: 400 };
|
||||
return { status: 200, data: data };
|
||||
}
|
||||
@@ -1,11 +1,15 @@
|
||||
import { notifikasi_funEventCheckStatus } from "./check/fun_check_event_status";
|
||||
import { notifikasi_funInvestasiChecInvestaorStatus } from "./check/fun_check_investor_status";
|
||||
import notifikasiToAdmin_funCreate from "./create/create_notif_to_admin";
|
||||
import notifikasiToUser_funCreate from "./create/create_notif_to_user";
|
||||
import { notifikasiToUser_CreateGroupCollaboration } from "./create/create_notif_to_user_collaboration";
|
||||
import { notifikasiToUser_CreateKabarDonasi } from "./create/create_notif_to_user_kabar_donasi";
|
||||
import notifikasi_funGetStatusTransaksiById from "./get/fun_get_status_transaksi";
|
||||
|
||||
export { notifikasiToAdmin_funCreate };
|
||||
export { notifikasiToUser_CreateGroupCollaboration };
|
||||
export { notifikasiToUser_CreateKabarDonasi };
|
||||
export { notifikasiToUser_funCreate };
|
||||
export { notifikasi_funEventCheckStatus };
|
||||
export { notifikasi_funGetStatusTransaksiById };
|
||||
export { notifikasi_funInvestasiChecInvestaorStatus };
|
||||
|
||||
Reference in New Issue
Block a user