Fix notifikasi
Deskripsi: - Fix notifikasi investasi
This commit is contained in:
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user