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