fix: investasi
deskripsi: - perbaikan metode penerimaan dan penolakan investor
This commit is contained in:
@@ -1,13 +1,15 @@
|
|||||||
"use client";
|
"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_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 { useState } from "react";
|
||||||
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
|
import {
|
||||||
|
adminInvestasi_funAcceptTransaksiById
|
||||||
|
} from "../../fun";
|
||||||
|
|
||||||
export function AdminInvestasi_ComponentButtonBandingTransaksi({
|
export function AdminInvestasi_ComponentButtonBandingTransaksi({
|
||||||
invoiceId,
|
invoiceId,
|
||||||
@@ -18,8 +20,9 @@ export function AdminInvestasi_ComponentButtonBandingTransaksi({
|
|||||||
invoiceId: string;
|
invoiceId: string;
|
||||||
investasiId: string;
|
investasiId: string;
|
||||||
lembarTerbeli: string;
|
lembarTerbeli: string;
|
||||||
onLoadData: (val: any) => void;
|
onLoadData?: (val: any) => void;
|
||||||
}) {
|
}) {
|
||||||
|
const router = useRouter();
|
||||||
const [isLoading, setLoading] = useState(false);
|
const [isLoading, setLoading] = useState(false);
|
||||||
async function onAccept() {
|
async function onAccept() {
|
||||||
const res = await adminInvestasi_funAcceptTransaksiById({
|
const res = await adminInvestasi_funAcceptTransaksiById({
|
||||||
@@ -28,22 +31,52 @@ export function AdminInvestasi_ComponentButtonBandingTransaksi({
|
|||||||
lembarTerbeli,
|
lembarTerbeli,
|
||||||
});
|
});
|
||||||
|
|
||||||
// if (res.status == 200) {
|
if (res.status == 200) {
|
||||||
// try {
|
const dataNotifikasi: IRealtimeData = {
|
||||||
// const dataTransaksi = await adminInvestasi_funGetAllTransaksiById({
|
appId: investasiId,
|
||||||
// investasiId,
|
status: res.data?.dataInvestasi?.MasterStatusInvestasi?.name as any,
|
||||||
// page: 1,
|
userId: res.data?.dataInvestasi.authorId as string,
|
||||||
// });
|
pesan: "Cek investasi anda, Anda memiliki investor baru",
|
||||||
// onLoadData(dataTransaksi);
|
kategoriApp: "INVESTASI",
|
||||||
// } catch (error) {
|
title: "Investor baru",
|
||||||
// console.log(error);
|
};
|
||||||
// } finally {
|
|
||||||
// ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
const notif = await notifikasiToUser_funCreate({
|
||||||
// setLoading(true);
|
data: dataNotifikasi as any,
|
||||||
// }
|
});
|
||||||
// } else {
|
|
||||||
// ComponentAdminGlobal_NotifikasiGagal(res.message);
|
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 (
|
return (
|
||||||
|
|||||||
@@ -2,21 +2,20 @@
|
|||||||
|
|
||||||
import { ComponentAdminGlobal_NotifikasiBerhasil } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_berhasil";
|
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 { 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 { IconBan, IconCircleCheck } from "@tabler/icons-react";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
import {
|
import {
|
||||||
adminInvestasi_funAcceptTransaksiById,
|
adminInvestasi_funAcceptTransaksiById,
|
||||||
adminInvestasi_funGetAllTransaksiById,
|
adminInvestasi_funRejectInvoiceById
|
||||||
adminInvestasi_funRejectInvoiceById,
|
|
||||||
} from "../../fun";
|
} 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({
|
export function AdminInvestasi_ComponentButtonKonfirmasiTransaksi({
|
||||||
invoiceId,
|
invoiceId,
|
||||||
@@ -27,8 +26,9 @@ export function AdminInvestasi_ComponentButtonKonfirmasiTransaksi({
|
|||||||
invoiceId: string;
|
invoiceId: string;
|
||||||
investasiId: string;
|
investasiId: string;
|
||||||
lembarTerbeli: string;
|
lembarTerbeli: string;
|
||||||
onLoadData: (val: any) => void;
|
onLoadData?: (val: any) => void;
|
||||||
}) {
|
}) {
|
||||||
|
const router = useRouter()
|
||||||
const [isLoadingAccpet, setLoadingAccept] = useState(false);
|
const [isLoadingAccpet, setLoadingAccept] = useState(false);
|
||||||
const [isLoadingReject, setLoadingReject] = useState(false);
|
const [isLoadingReject, setLoadingReject] = useState(false);
|
||||||
|
|
||||||
@@ -58,13 +58,9 @@ export function AdminInvestasi_ComponentButtonKonfirmasiTransaksi({
|
|||||||
dataMessage: notifikasiInvestor,
|
dataMessage: notifikasiInvestor,
|
||||||
});
|
});
|
||||||
|
|
||||||
const dataTransaksi = await adminInvestasi_funGetAllTransaksiById({
|
|
||||||
investasiId,
|
|
||||||
page: 1,
|
|
||||||
});
|
|
||||||
onLoadData(dataTransaksi);
|
|
||||||
|
|
||||||
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
router.back();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||||
@@ -128,12 +124,15 @@ export function AdminInvestasi_ComponentButtonKonfirmasiTransaksi({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const dataTransaksi = await adminInvestasi_funGetAllTransaksiById({
|
// const dataTransaksi = await adminInvestasi_funGetAllTransaksiById({
|
||||||
investasiId,
|
// investasiId,
|
||||||
page: 1,
|
// page: 1,
|
||||||
});
|
// });
|
||||||
onLoadData(dataTransaksi);
|
// onLoadData?.(dataTransaksi);
|
||||||
|
|
||||||
|
|
||||||
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
router.back();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
clientLogger.error("Error accept invoice", error);
|
clientLogger.error("Error accept invoice", error);
|
||||||
@@ -144,7 +143,7 @@ export function AdminInvestasi_ComponentButtonKonfirmasiTransaksi({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack>
|
<Group position="center">
|
||||||
<Button
|
<Button
|
||||||
loaderPosition="center"
|
loaderPosition="center"
|
||||||
loading={isLoadingAccpet}
|
loading={isLoadingAccpet}
|
||||||
@@ -167,7 +166,7 @@ export function AdminInvestasi_ComponentButtonKonfirmasiTransaksi({
|
|||||||
>
|
>
|
||||||
Tolak
|
Tolak
|
||||||
</Button>
|
</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 CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||||
import { MODEL_INVOICE_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
import { MODEL_INVOICE_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||||
import { clientLogger } from "@/util/clientLogger";
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
import {
|
import { Badge, Box, Grid, Group, Stack, Text } from "@mantine/core";
|
||||||
Badge,
|
|
||||||
Box,
|
|
||||||
Stack
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import { useParams } from "next/navigation";
|
import { useParams } from "next/navigation";
|
||||||
import { useState } from "react";
|
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 ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/_admin_global/header_tamplate";
|
||||||
import { Admin_V3_ComponentDetail } from "@/app_modules/admin/_components_v3/comp_detail_data";
|
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_ComponentCekBuktiTransfer } from "../../_component/new_button/button_cek_bukti_transfer";
|
||||||
|
import {
|
||||||
|
AdminInvestasi_ComponentButtonKonfirmasiTransaksi,
|
||||||
|
AdminInvestasi_ComponentButtonBandingTransaksi,
|
||||||
|
} from "../../_component";
|
||||||
|
|
||||||
function DetailTransaksi() {
|
function DetailTransaksi() {
|
||||||
const params = useParams<{ id: string }>();
|
const params = useParams<{ id: string }>();
|
||||||
@@ -121,6 +121,25 @@ function DetailTransaksi() {
|
|||||||
{listData.map((e, i) => (
|
{listData.map((e, i) => (
|
||||||
<Admin_V3_ComponentDetail key={i} item={e} />
|
<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>
|
</Stack>
|
||||||
</Admin_ComponentBoxStyle>
|
</Admin_ComponentBoxStyle>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user