Fix detail publish, detail transaksi
This commit is contained in:
@@ -2,14 +2,13 @@ import prisma from "@/lib/prisma";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import { NextResponse } from "next/server";
|
||||
export async function GET(req: Request,
|
||||
{ params }: { params: { id: any } }) {
|
||||
{ params }: { params: { id: string } }) {
|
||||
try {
|
||||
let fixData;
|
||||
const { id } = params
|
||||
const data = await prisma.investasi_Invoice.findMany({
|
||||
const data = await prisma.investasi_Invoice.findUnique({
|
||||
where: {
|
||||
investasiId: id,
|
||||
isActive: true,
|
||||
id: id
|
||||
},
|
||||
include: {
|
||||
Author: true,
|
||||
@@ -18,6 +17,7 @@ export async function GET(req: Request,
|
||||
MasterBank: true,
|
||||
}
|
||||
})
|
||||
|
||||
fixData = {
|
||||
data: data,
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@ export async function GET(
|
||||
MasterBank: true,
|
||||
},
|
||||
});
|
||||
|
||||
const nCount = await prisma.investasi_Invoice.count({
|
||||
where: {
|
||||
investasiId: id,
|
||||
|
||||
@@ -107,7 +107,7 @@ function TablePublish() {
|
||||
return data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center w={100}>
|
||||
<Text c={AdminColor.white} lineClamp={1}>{e?.Author?.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
@@ -122,23 +122,6 @@ function TablePublish() {
|
||||
</Badge>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Box w={400}>
|
||||
<Spoiler
|
||||
// w={400}
|
||||
c={AdminColor.white}
|
||||
maxHeight={60}
|
||||
hideLabel="sembunyikan"
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: e?.diskusi,
|
||||
}}
|
||||
/>
|
||||
</Spoiler>
|
||||
</Box>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text c={AdminColor.white}>
|
||||
@@ -243,9 +226,6 @@ function TablePublish() {
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Status</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Text c={AdminColor.white}>Postingan</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Tanggal Publish</Center>
|
||||
</th>
|
||||
|
||||
@@ -28,22 +28,22 @@ 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) {
|
||||
// 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);
|
||||
// }
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
"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 { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export function AdminInvestasi_ComponentButtonBandingTransaksi({
|
||||
invoiceId,
|
||||
investasiId,
|
||||
lembarTerbeli,
|
||||
|
||||
}: {
|
||||
invoiceId: string;
|
||||
investasiId: string;
|
||||
lembarTerbeli: string;
|
||||
|
||||
}) {
|
||||
console.log("Ini invoiceid", invoiceId)
|
||||
console.log("Ini investasiid", investasiId)
|
||||
console.log("Ini lembar terbeli", lembarTerbeli)
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
const router = useRouter();
|
||||
async function onAccept() {
|
||||
try {
|
||||
setLoading(true);
|
||||
const res = await adminInvestasi_funAcceptTransaksiById({
|
||||
invoiceId,
|
||||
investasiId,
|
||||
lembarTerbeli,
|
||||
});
|
||||
if (res.status == 200) {
|
||||
router.back();
|
||||
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
||||
} else {
|
||||
console.error("reject error", res.message);
|
||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
color="orange"
|
||||
onClick={() => {
|
||||
onAccept();
|
||||
}}
|
||||
>
|
||||
Banding Diterima
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { RouterAdminGlobal } from "@/lib";
|
||||
import { Button } from "@mantine/core";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
export function AdminInvestasi_ComponentCekBuktiTransfer({
|
||||
imageId,
|
||||
}: {
|
||||
imageId: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoading}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setLoading(true);
|
||||
router.push(RouterAdminGlobal.preview_image({ id: imageId }));
|
||||
}}
|
||||
>
|
||||
Cek Transaksi
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
"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 { Box, Button, Flex, 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 { 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";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export function AdminInvestasi_ComponentButtonKonfirmasiTransaksi({
|
||||
invoiceId,
|
||||
investasiId,
|
||||
lembarTerbeli,
|
||||
|
||||
}: {
|
||||
invoiceId: string;
|
||||
investasiId: string;
|
||||
lembarTerbeli: string;
|
||||
|
||||
}) {
|
||||
const [isLoadingAccpet, setLoadingAccept] = useState(false);
|
||||
const [isLoadingReject, setLoadingReject] = useState(false);
|
||||
const router = useRouter();
|
||||
|
||||
async function onReject() {
|
||||
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,
|
||||
});
|
||||
|
||||
if (notifToInvestor.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: notifikasiInvestor,
|
||||
});
|
||||
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
||||
}
|
||||
router.back();
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error rejected investasi:", error);
|
||||
} finally {
|
||||
setLoadingReject(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function onAccept() {
|
||||
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,
|
||||
});
|
||||
}
|
||||
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
||||
router.back();
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error accept invoice", error);
|
||||
setLoadingAccept(false);
|
||||
} finally {
|
||||
setLoadingAccept(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Flex px={135} align={"center"} justify={"center"} gap={"md"} >
|
||||
<Box>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoadingAccpet}
|
||||
leftIcon={<IconCircleCheck />}
|
||||
radius={"xl"}
|
||||
color="green"
|
||||
onClick={() => {
|
||||
onAccept();
|
||||
}}
|
||||
>
|
||||
Terima
|
||||
</Button>
|
||||
</Box>
|
||||
<Box>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoadingReject}
|
||||
leftIcon={<IconBan />}
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
onClick={() => onReject()}
|
||||
>
|
||||
Tolak
|
||||
</Button>
|
||||
</Box>
|
||||
</Flex>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -74,7 +74,6 @@ const apiGetAdminDetailTransaksi = async ({ id }: { id: string }) => {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
console.log("Ini response",response.json())
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
@@ -115,7 +114,6 @@ const apiGetAdminAllTransaksiById = async ({
|
||||
|
||||
// Fetch data
|
||||
const isStatus = status ? `&status=${status}` : "";
|
||||
console.log("Ini status", isStatus);
|
||||
const isPage = page ? `?page=${page}` : "";
|
||||
const response = await fetch(
|
||||
`/api/admin/investasi/${id}/transaksi${isPage}${isStatus}`,
|
||||
|
||||
@@ -1,3 +1,348 @@
|
||||
// import { ComponentAdminGlobal_TampilanRupiah, ComponentAdminGlobal_TitlePage } from "@/app_modules/admin/_admin_global/_component";
|
||||
// import {
|
||||
// MODEL_INVOICE_INVESTASI,
|
||||
// MODEL_STATUS_INVOICE_INVESTASI,
|
||||
// } from "@/app_modules/investasi/_lib/interface";
|
||||
// import {
|
||||
// ActionIcon,
|
||||
// Badge,
|
||||
// Center,
|
||||
// Group,
|
||||
// Pagination,
|
||||
// Paper,
|
||||
// ScrollArea,
|
||||
// Select,
|
||||
// Stack,
|
||||
// Table,
|
||||
// Text,
|
||||
// Title,
|
||||
// } from "@mantine/core";
|
||||
// import { IconReload } from "@tabler/icons-react";
|
||||
// import { isEmpty } from "lodash";
|
||||
// import { useParams, useRouter } from "next/navigation";
|
||||
// import { useState } from "react";
|
||||
// import {
|
||||
// AdminInvestasi_ComponentButtonBandingTransaksi,
|
||||
// AdminInvestasi_ComponentButtonKonfirmasiTransaksi,
|
||||
// AdminInvestasi_ComponentCekBuktiTransfer,
|
||||
// } from "../../_component";
|
||||
// import { adminInvestasi_funGetAllTransaksiById } from "../../fun";
|
||||
// import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
// import { useShallowEffect } from "@mantine/hooks";
|
||||
// import { apiGetAdminAllTransaksiById, apiGetAdminStatusTransaksi } from "../../_lib/api_fetch_admin_investasi";
|
||||
// import { clientLogger } from "@/util/clientLogger";
|
||||
// import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
// import { apiGetMasterStatusTransaksi } from "@/app_modules/_global/lib/api_fetch_master";
|
||||
|
||||
// export function AdminInvestasi_ViewDaftarTransaksi() {
|
||||
// const params = useParams<{ id: string }>();
|
||||
// const investasiId = params.id;
|
||||
// const router = useRouter();
|
||||
// const [isLoading, setLoading] = useState(false);
|
||||
// const [idData, setIdData] = useState("");
|
||||
// const [listStatus, setListStatus] = useState<MODEL_STATUS_INVOICE_INVESTASI[] | null>(null);
|
||||
|
||||
// const [data, setData] = useState<MODEL_INVOICE_INVESTASI[] | null>(null);
|
||||
// const [isNPage, setNPage] = useState<number>(1);
|
||||
// const [isActivePage, setActivePage] = useState(1);
|
||||
// const [selectedStatus, setSelectedStatus] = useState("");
|
||||
|
||||
// useShallowEffect(() => {
|
||||
// loadInitialData();
|
||||
// }, [isActivePage, selectedStatus])
|
||||
|
||||
// useShallowEffect(() => {
|
||||
// loadStatus();
|
||||
// }, [])
|
||||
|
||||
// const loadInitialData = async () => {
|
||||
// try {
|
||||
// const response = await apiGetAdminAllTransaksiById({
|
||||
// id: investasiId,
|
||||
// page: `${isNPage}`,
|
||||
// status: selectedStatus,
|
||||
// })
|
||||
|
||||
// if (response?.success && response?.data?.data) {
|
||||
// setData(response.data.data);
|
||||
// setNPage(response.nPage || 1);
|
||||
// setListStatus(response.data.data);
|
||||
// } else {
|
||||
// console.error("Invalid data format received:", response);
|
||||
// setData([]);
|
||||
// }
|
||||
// } catch (error) {
|
||||
// clientLogger.error("Error get data daftar tramnsaksi", error);
|
||||
// setData([]);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// const loadStatus = async () => {
|
||||
// try {
|
||||
// const response = await apiGetMasterStatusTransaksi()
|
||||
|
||||
// if (response?.success && response?.data) {
|
||||
// setListStatus(response.data);
|
||||
// console.log("status", response.data)
|
||||
// } else {
|
||||
// console.error("Invalid data format received:", response);
|
||||
// setListStatus(null);
|
||||
// }
|
||||
// } catch (error) {
|
||||
// clientLogger.error("Error get status transaksi", error);
|
||||
// setListStatus(null);
|
||||
// }
|
||||
// }
|
||||
|
||||
// const onPageClick = async (page: number) => {
|
||||
// const loadData = await apiGetAdminAllTransaksiById({
|
||||
// id: investasiId,
|
||||
// page: `${isNPage}`
|
||||
// })
|
||||
// setActivePage(page);
|
||||
// setData(loadData.data as any);
|
||||
// setNPage(loadData.nPage);
|
||||
|
||||
// }
|
||||
|
||||
// async function onSelected(selectStatus: any) {
|
||||
// setSelectedStatus(selectStatus);
|
||||
// // const loadData = await apiGetAdminStatusTransaksi();
|
||||
// // setData(loadData.data as any);
|
||||
// // setNPage(loadData.nPage);
|
||||
// }
|
||||
|
||||
// async function onReload() {
|
||||
// const loadData = await apiGetAdminAllTransaksiById({
|
||||
// id: investasiId,
|
||||
// page: '1'
|
||||
// });
|
||||
// setData(loadData.data as any);
|
||||
// setNPage(loadData.nPage);
|
||||
// }
|
||||
|
||||
// const renderTableBody = () => {
|
||||
// if (!Array.isArray(data) || data.length === 0) {
|
||||
// return (
|
||||
// <tr>
|
||||
// <td colSpan={12}>
|
||||
// <Center>
|
||||
// <Text color="gray">Tidak ada data</Text>
|
||||
// </Center>
|
||||
// </td>
|
||||
// </tr>
|
||||
// );
|
||||
// }
|
||||
// return data?.map((e, i) => (
|
||||
// <tr key={i}>
|
||||
// <td>
|
||||
// <Center c={AdminColor.white}>{e?.Author?.username}</Center>
|
||||
// </td>
|
||||
// <td>
|
||||
// <Center c={AdminColor.white}>{e?.MasterBank?.namaBank}</Center>
|
||||
// </td>
|
||||
// <td>
|
||||
// <Center c={AdminColor.white}>
|
||||
// <ComponentAdminGlobal_TampilanRupiah nominal={+e?.nominal} />
|
||||
// </Center>
|
||||
// </td>
|
||||
// <td>
|
||||
// <Center c={AdminColor.white}>
|
||||
// {new Intl.NumberFormat("id-ID", { maximumFractionDigits: 10 }).format(
|
||||
// +e?.lembarTerbeli
|
||||
// )}
|
||||
// </Center>
|
||||
// </td>
|
||||
// <td>
|
||||
// <Center c={AdminColor.white}>
|
||||
// {new Intl.DateTimeFormat("id-ID", { dateStyle: "full" }).format(new Date(e?.createdAt))}
|
||||
// </Center>
|
||||
// </td>
|
||||
// <td>
|
||||
// <Center>
|
||||
// <Badge
|
||||
// w={150}
|
||||
// variant="light"
|
||||
// color={
|
||||
// e.statusInvoiceId === "1"
|
||||
// ? "green"
|
||||
// : e.statusInvoiceId === "4"
|
||||
// ? "red"
|
||||
// : "blue"
|
||||
// }
|
||||
// >
|
||||
// {e?.StatusInvoice?.name}
|
||||
// </Badge>
|
||||
// </Center>
|
||||
// </td>
|
||||
// <td>
|
||||
// <Center>
|
||||
// {e?.statusInvoiceId !== "3" ? (
|
||||
// <AdminInvestasi_ComponentCekBuktiTransfer imageId={e?.imageId} />
|
||||
// ) : (
|
||||
// "-"
|
||||
// )}
|
||||
// </Center>
|
||||
// </td>
|
||||
// <td>
|
||||
// <Center>
|
||||
// {e.statusInvoiceId === "1" && "-"}
|
||||
// {e.statusInvoiceId === "2" && (
|
||||
// <AdminInvestasi_ComponentButtonKonfirmasiTransaksi
|
||||
// invoiceId={e.id}
|
||||
// investasiId={investasiId}
|
||||
// lembarTerbeli={e.lembarTerbeli}
|
||||
// onLoadData={(val) => {
|
||||
// setData(val.data);
|
||||
// setNPage(val.nPage);
|
||||
// }}
|
||||
// />
|
||||
// )}
|
||||
// {e.statusInvoiceId === "3" && "-"}
|
||||
// {e.statusInvoiceId === "4" && (
|
||||
// <AdminInvestasi_ComponentButtonBandingTransaksi
|
||||
|
||||
// invoiceId={e.id}
|
||||
// investasiId={investasiId}
|
||||
// lembarTerbeli={e.lembarTerbeli}
|
||||
// onLoadData={(val) => {
|
||||
// setData(val.data);
|
||||
// setNPage(val.nPage);
|
||||
// }}
|
||||
// />
|
||||
// )}
|
||||
// </Center>
|
||||
// </td>
|
||||
// </tr>
|
||||
// ));
|
||||
// }
|
||||
|
||||
// return (
|
||||
// <>
|
||||
// <Stack spacing={"xs"} h={"100%"}>
|
||||
// <ComponentAdminGlobal_TitlePage
|
||||
// name="Transkasi"
|
||||
// color={AdminColor.softBlue}
|
||||
// component={<Group>
|
||||
// <ActionIcon
|
||||
// size={"lg"}
|
||||
// radius={"xl"}
|
||||
// variant="light"
|
||||
// onClick={() => {
|
||||
// onReload();
|
||||
// }}
|
||||
// >
|
||||
// <IconReload />
|
||||
// </ActionIcon>
|
||||
// <Select
|
||||
// placeholder="Pilih status"
|
||||
// value={selectedStatus}
|
||||
// data={listStatus?.map(status => ({
|
||||
// value: status.id,
|
||||
// label: status.name,
|
||||
|
||||
// })) || []}
|
||||
// onChange={(val: any) => {
|
||||
// console.log(val)
|
||||
// onSelected(val);
|
||||
// }}
|
||||
// />
|
||||
// </Group>}
|
||||
// />
|
||||
// {/* <Group
|
||||
// position="apart"
|
||||
// bg={"gray.4"}
|
||||
// p={"xs"}
|
||||
// style={{ borderRadius: "6px" }}
|
||||
// >
|
||||
// <Title order={4}>Transaksi</Title>
|
||||
// <Group>
|
||||
// <ActionIcon
|
||||
// size={"lg"}
|
||||
// radius={"xl"}
|
||||
// variant="light"
|
||||
// onClick={() => {
|
||||
// onReload();
|
||||
// }}
|
||||
// >
|
||||
// <IconReload />
|
||||
// </ActionIcon>
|
||||
// <Select
|
||||
// placeholder="Pilih status"
|
||||
// value={selectedStatus}
|
||||
// data={
|
||||
// isEmpty(listStatsus)
|
||||
// ? []
|
||||
// : listStatsus.map((e) => ({
|
||||
// value: e.id,
|
||||
// label: e.name,
|
||||
// }))
|
||||
// }
|
||||
// onChange={(val: any) => {
|
||||
// onSelected(val);
|
||||
// }}
|
||||
// />
|
||||
// </Group>
|
||||
// </Group> */}
|
||||
|
||||
// {!data ? (<CustomSkeleton height={"80vh"} width={"100%"} />) : (
|
||||
// <Paper bg={AdminColor.softBlue} p={"md"} shadow="lg" h={"80vh"}>
|
||||
// <ScrollArea w={"100%"} h={"90%"}>
|
||||
// <Table
|
||||
// verticalSpacing={"xl"}
|
||||
// horizontalSpacing={"md"}
|
||||
// p={"md"}
|
||||
// w={1500}
|
||||
// >
|
||||
// <thead>
|
||||
// <tr>
|
||||
// <th>
|
||||
// <Center c={AdminColor.white}>Nama Investor</Center>
|
||||
// </th>
|
||||
// <th>
|
||||
// <Center c={AdminColor.white}>Nama Bank</Center>
|
||||
// </th>
|
||||
// <th>
|
||||
// <Center c={AdminColor.white}>Jumlah Investasi</Center>
|
||||
// </th>
|
||||
// <th>
|
||||
// <Center c={AdminColor.white}>Lembar Terbeli</Center>
|
||||
// </th>
|
||||
// <th>
|
||||
// <Center c={AdminColor.white}>Tanggal</Center>
|
||||
// </th>
|
||||
// <th>
|
||||
// <Center c={AdminColor.white}>Status</Center>
|
||||
// </th>
|
||||
// <th>
|
||||
// <Center c={AdminColor.white}>Bukti Transfer</Center>
|
||||
// </th>
|
||||
// <th>
|
||||
// <Center c={AdminColor.white}>Aksi</Center>
|
||||
// </th>
|
||||
// </tr>
|
||||
// </thead>
|
||||
// <tbody>{renderTableBody()}</tbody>
|
||||
// </Table>
|
||||
// </ScrollArea>
|
||||
|
||||
// <Center mt={"xl"}>
|
||||
// <Pagination
|
||||
// value={isActivePage}
|
||||
// total={isNPage}
|
||||
// onChange={(val) => {
|
||||
// onPageClick(val);
|
||||
// }}
|
||||
// />
|
||||
// </Center>
|
||||
// </Paper>
|
||||
// )}
|
||||
// </Stack>
|
||||
// </>
|
||||
// );
|
||||
// }
|
||||
|
||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { apiGetMasterStatusTransaksi } from "@/app_modules/_global/lib/api_fetch_master";
|
||||
import { globalStatusTransaksi } from "@/app_modules/_global/lib/master_list_app";
|
||||
@@ -29,13 +374,9 @@ import { useShallowEffect } from "@mantine/hooks";
|
||||
import { IconEyeCheck, IconReload } from "@tabler/icons-react";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
AdminInvestasi_ComponentButtonBandingTransaksi,
|
||||
AdminInvestasi_ComponentButtonKonfirmasiTransaksi,
|
||||
AdminInvestasi_ComponentCekBuktiTransfer,
|
||||
} from "../../_component";
|
||||
import { apiGetAdminAllTransaksiById } from "../../_lib/api_fetch_admin_investasi";
|
||||
import { RouterAdminInvestasi } from "@/lib/router_admin/router_admin_investasi";
|
||||
import { AdminInvestasi_ComponentCekBuktiTransfer } from "../../_component/new_button/button_cek_bukti_transfer";
|
||||
|
||||
export function AdminInvestasi_ViewDaftarTransaksi() {
|
||||
const params = useParams<{ id: string }>();
|
||||
|
||||
@@ -164,9 +164,9 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
|
||||
)}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<td>
|
||||
<Center>
|
||||
{/* {e.statusInvoiceId === "1" && "-"}
|
||||
{e.statusInvoiceId === "1" && "-"}
|
||||
{e.statusInvoiceId === "2" && (
|
||||
<AdminInvestasi_ComponentButtonKonfirmasiTransaksi
|
||||
invoiceId={e.id}
|
||||
@@ -181,6 +181,7 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
|
||||
{e.statusInvoiceId === "3" && "-"}
|
||||
{e.statusInvoiceId === "4" && (
|
||||
<AdminInvestasi_ComponentButtonBandingTransaksi
|
||||
|
||||
invoiceId={e.id}
|
||||
investasiId={investasiId}
|
||||
lembarTerbeli={e.lembarTerbeli}
|
||||
@@ -189,6 +190,9 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
|
||||
setNPage(val.nPage);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</Center>
|
||||
</td>
|
||||
)} */}
|
||||
<Button
|
||||
loading={isLoading && idData == e.id}
|
||||
|
||||
@@ -3,16 +3,23 @@ import { AdminColor } from '@/app_modules/_global/color/color_pallet';
|
||||
import AdminGlobal_ComponentBackButton from '@/app_modules/admin/_admin_global/back_button';
|
||||
import CustomSkeleton from '@/app_modules/components/CustomSkeleton';
|
||||
import { MODEL_INVOICE_INVESTASI } from '@/app_modules/investasi/_lib/interface';
|
||||
import { Button, Grid, Group, Paper, Stack, Text, Title } from '@mantine/core';
|
||||
import { useState } from 'react';
|
||||
import { apiGetAdminDetailTransaksi } from '../../_lib/api_fetch_admin_investasi';
|
||||
import { useParams } from 'next/navigation';
|
||||
import { clientLogger } from '@/util/clientLogger';
|
||||
import { Badge, Box, Grid, Group, Paper, Stack, Text, Title } from '@mantine/core';
|
||||
import { useShallowEffect } from '@mantine/hooks';
|
||||
import { useParams } from 'next/navigation';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { apiGetAdminDetailTransaksi } from '../../_lib/api_fetch_admin_investasi';
|
||||
import { AdminInvestasi_ComponentButtonKonfirmasiTransaksi } from '../../_component/new_button/button_konfirmasi_transaksi';
|
||||
|
||||
import { AdminInvestasi_ComponentCekBuktiTransfer } from '../../_component/new_button/button_cek_bukti_transfer';
|
||||
import { AdminInvestasi_ComponentButtonBandingTransaksi } from '../../_component/new_button/button_banding_transaksi';
|
||||
|
||||
|
||||
|
||||
function DetailTransaksi() {
|
||||
const params = useParams<{ id: string }>();
|
||||
const investasiId = params.id;
|
||||
const [data, setData] = useState<MODEL_INVOICE_INVESTASI | null>(null);
|
||||
|
||||
useShallowEffect(() => {
|
||||
@@ -21,18 +28,17 @@ function DetailTransaksi() {
|
||||
|
||||
const loadInitialData = async () => {
|
||||
try {
|
||||
|
||||
const response = await apiGetAdminDetailTransaksi({
|
||||
id: params.id
|
||||
id: investasiId
|
||||
})
|
||||
|
||||
if (response?.success && response?.data.data) {
|
||||
if (response?.success && response?.data?.data) {
|
||||
setData(response.data.data)
|
||||
} else {
|
||||
console.error("Invalid data format recieved:", response)
|
||||
setData(null)
|
||||
}
|
||||
|
||||
|
||||
} catch (error) {
|
||||
clientLogger.error("Invalid data format recieved:", error)
|
||||
setData(null)
|
||||
@@ -42,27 +48,6 @@ function DetailTransaksi() {
|
||||
<Stack px={"lg"}>
|
||||
<Group position="apart">
|
||||
<AdminGlobal_ComponentBackButton />
|
||||
|
||||
{/* {data?.masterStatusInvestasiId === "2" ? ( */}
|
||||
<Group>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
color="green"
|
||||
// onClick={() => setOpenModalPublish(true)}
|
||||
>
|
||||
Publish
|
||||
</Button>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
// onClick={() => setOpenModalReject(true)}
|
||||
>
|
||||
Reject
|
||||
</Button>
|
||||
</Group>
|
||||
{/* // ) : (
|
||||
// ""
|
||||
// )} */}
|
||||
</Group>
|
||||
|
||||
<>
|
||||
@@ -124,7 +109,17 @@ function DetailTransaksi() {
|
||||
<Text fw={"bold"}>Status:</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Text>{data?.statusInvoiceId}</Text>
|
||||
<Badge
|
||||
w={150}
|
||||
variant='light'
|
||||
color={
|
||||
data?.StatusInvoice?.id === "1"
|
||||
? "green"
|
||||
: data?.StatusInvoice?.id === "4"
|
||||
? "red"
|
||||
: "blue"
|
||||
}
|
||||
>{data?.StatusInvoice?.name}</Badge>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
@@ -132,7 +127,36 @@ function DetailTransaksi() {
|
||||
<Text fw={"bold"}>Bukti Transfer:</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Text>{data?.Profile?.alamat}</Text>
|
||||
<Box>
|
||||
{data?.statusInvoiceId !== "3" ? (
|
||||
<AdminInvestasi_ComponentCekBuktiTransfer imageId={data?.imageId} />
|
||||
) : (
|
||||
"-"
|
||||
)}
|
||||
</Box>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid pt={"md"}>
|
||||
<Grid.Col span={6}>
|
||||
<Group>
|
||||
{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>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Stack>
|
||||
|
||||
@@ -13,7 +13,11 @@ export async function adminInvestasi_funAcceptTransaksiById({
|
||||
invoiceId: string;
|
||||
investasiId: string;
|
||||
lembarTerbeli: string;
|
||||
}) {
|
||||
}) {
|
||||
console.log("Ini invoiceid", invoiceId)
|
||||
console.log("Ini investasid", investasiId)
|
||||
console.log("Ini lembar terbeli", lembarTerbeli)
|
||||
|
||||
const dataInvestasi: any = await prisma.investasi.findFirst({
|
||||
where: {
|
||||
id: investasiId,
|
||||
@@ -24,7 +28,6 @@ export async function adminInvestasi_funAcceptTransaksiById({
|
||||
lembarTerbeli: true,
|
||||
},
|
||||
});
|
||||
|
||||
// Hitung TOTAL SISA LEMBAR
|
||||
const investasi_sisaLembar = toNumber(dataInvestasi?.sisaLembar);
|
||||
const invoice_lembarTerbeli = toNumber(lembarTerbeli);
|
||||
@@ -47,6 +50,7 @@ export async function adminInvestasi_funAcceptTransaksiById({
|
||||
statusInvoiceId: "1",
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
if (!updt) {
|
||||
return { status: 400, message: "Gagal Update Status" };
|
||||
@@ -83,3 +87,6 @@ export async function adminInvestasi_funAcceptTransaksiById({
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user