fix: investasi
deskripsi: - perbaikan metode penerimaan dan penolakan investor
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
"use client";
|
||||
|
||||
import { Button } from "@mantine/core";
|
||||
import {
|
||||
adminInvestasi_funAcceptTransaksiById,
|
||||
adminInvestasi_funGetAllTransaksiById,
|
||||
} 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 { notifikasiToUser_funCreate } from "@/app_modules/notifikasi/fun";
|
||||
import { IRealtimeData } from "@/lib/global_state";
|
||||
import { Button } from "@mantine/core";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
import {
|
||||
adminInvestasi_funAcceptTransaksiById
|
||||
} from "../../fun";
|
||||
|
||||
export function AdminInvestasi_ComponentButtonBandingTransaksi({
|
||||
invoiceId,
|
||||
@@ -18,8 +20,9 @@ export function AdminInvestasi_ComponentButtonBandingTransaksi({
|
||||
invoiceId: string;
|
||||
investasiId: string;
|
||||
lembarTerbeli: string;
|
||||
onLoadData: (val: any) => void;
|
||||
onLoadData?: (val: any) => void;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
async function onAccept() {
|
||||
const res = await adminInvestasi_funAcceptTransaksiById({
|
||||
@@ -28,22 +31,52 @@ export function AdminInvestasi_ComponentButtonBandingTransaksi({
|
||||
lembarTerbeli,
|
||||
});
|
||||
|
||||
// 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);
|
||||
// setLoading(true);
|
||||
// }
|
||||
// } else {
|
||||
// ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||
// }
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
||||
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
||||
router.back();
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -2,21 +2,20 @@
|
||||
|
||||
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 {
|
||||
notifikasiToUser_funCreate
|
||||
} from "@/app_modules/notifikasi/fun";
|
||||
import { IRealtimeData } from "@/lib/global_state";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { Button, Group } from "@mantine/core";
|
||||
import { IconBan, IconCircleCheck } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
import {
|
||||
adminInvestasi_funAcceptTransaksiById,
|
||||
adminInvestasi_funGetAllTransaksiById,
|
||||
adminInvestasi_funRejectInvoiceById,
|
||||
adminInvestasi_funRejectInvoiceById
|
||||
} from "../../fun";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { IRealtimeData } from "@/lib/global_state";
|
||||
import {
|
||||
notifikasiToAdmin_funCreate,
|
||||
notifikasiToUser_funCreate,
|
||||
} from "@/app_modules/notifikasi/fun";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
|
||||
export function AdminInvestasi_ComponentButtonKonfirmasiTransaksi({
|
||||
invoiceId,
|
||||
@@ -27,8 +26,9 @@ export function AdminInvestasi_ComponentButtonKonfirmasiTransaksi({
|
||||
invoiceId: string;
|
||||
investasiId: string;
|
||||
lembarTerbeli: string;
|
||||
onLoadData: (val: any) => void;
|
||||
onLoadData?: (val: any) => void;
|
||||
}) {
|
||||
const router = useRouter()
|
||||
const [isLoadingAccpet, setLoadingAccept] = useState(false);
|
||||
const [isLoadingReject, setLoadingReject] = useState(false);
|
||||
|
||||
@@ -58,13 +58,9 @@ export function AdminInvestasi_ComponentButtonKonfirmasiTransaksi({
|
||||
dataMessage: notifikasiInvestor,
|
||||
});
|
||||
|
||||
const dataTransaksi = await adminInvestasi_funGetAllTransaksiById({
|
||||
investasiId,
|
||||
page: 1,
|
||||
});
|
||||
onLoadData(dataTransaksi);
|
||||
|
||||
|
||||
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
||||
router.back();
|
||||
}
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||
@@ -128,12 +124,15 @@ export function AdminInvestasi_ComponentButtonKonfirmasiTransaksi({
|
||||
});
|
||||
}
|
||||
|
||||
const dataTransaksi = await adminInvestasi_funGetAllTransaksiById({
|
||||
investasiId,
|
||||
page: 1,
|
||||
});
|
||||
onLoadData(dataTransaksi);
|
||||
// const dataTransaksi = await adminInvestasi_funGetAllTransaksiById({
|
||||
// investasiId,
|
||||
// page: 1,
|
||||
// });
|
||||
// onLoadData?.(dataTransaksi);
|
||||
|
||||
|
||||
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
||||
router.back();
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error accept invoice", error);
|
||||
@@ -144,7 +143,7 @@ export function AdminInvestasi_ComponentButtonKonfirmasiTransaksi({
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<Group position="center">
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoadingAccpet}
|
||||
@@ -167,7 +166,7 @@ export function AdminInvestasi_ComponentButtonKonfirmasiTransaksi({
|
||||
>
|
||||
Tolak
|
||||
</Button>
|
||||
</Stack>
|
||||
</Group>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,7 @@ import Admin_ComponentBackButton from "@/app_modules/admin/_admin_global/back_bu
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { MODEL_INVOICE_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Stack
|
||||
} from "@mantine/core";
|
||||
import { Badge, Box, Grid, Group, Stack, Text } from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { useParams } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
@@ -18,6 +14,10 @@ import { Admin_ComponentBoxStyle } from "@/app_modules/admin/_admin_global/_comp
|
||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/_admin_global/header_tamplate";
|
||||
import { Admin_V3_ComponentDetail } from "@/app_modules/admin/_components_v3/comp_detail_data";
|
||||
import { AdminInvestasi_ComponentCekBuktiTransfer } from "../../_component/new_button/button_cek_bukti_transfer";
|
||||
import {
|
||||
AdminInvestasi_ComponentButtonKonfirmasiTransaksi,
|
||||
AdminInvestasi_ComponentButtonBandingTransaksi,
|
||||
} from "../../_component";
|
||||
|
||||
function DetailTransaksi() {
|
||||
const params = useParams<{ id: string }>();
|
||||
@@ -121,6 +121,25 @@ function DetailTransaksi() {
|
||||
{listData.map((e, i) => (
|
||||
<Admin_V3_ComponentDetail key={i} item={e} />
|
||||
))}
|
||||
|
||||
<Group position="center" mt="xl">
|
||||
{data?.statusInvoiceId === "1" && "-"}
|
||||
{data?.statusInvoiceId === "2" && (
|
||||
<AdminInvestasi_ComponentButtonKonfirmasiTransaksi
|
||||
investasiId={data?.investasiId}
|
||||
invoiceId={data?.id}
|
||||
lembarTerbeli={data?.lembarTerbeli}
|
||||
/>
|
||||
)}
|
||||
{data?.statusInvoiceId === "3" && "-"}
|
||||
{data?.statusInvoiceId === "4" && (
|
||||
<AdminInvestasi_ComponentButtonBandingTransaksi
|
||||
invoiceId={data?.id}
|
||||
investasiId={data?.investasiId}
|
||||
lembarTerbeli={data?.lembarTerbeli}
|
||||
/>
|
||||
)}
|
||||
</Group>
|
||||
</Stack>
|
||||
</Admin_ComponentBoxStyle>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user