API Detail Publish Daftar Transaksi

This commit is contained in:
2025-02-14 14:00:06 +08:00
parent f9cbf63a44
commit 54314ee506
6 changed files with 129 additions and 27 deletions

View File

@@ -0,0 +1,100 @@
import backendLogger from "@/util/backendLogger";
import _ from "lodash";
import { NextResponse } from "next/server";
export async function GET( request: Request,
{ params }: { params: { id: string,} }) {
let fixData;
const { searchParams } = new URL(request.url);
const page = searchParams.get("page");
const selectStatus = searchParams.get("status");
const { id } = params;
const investasiId = id;
const takeData = 10;
const skipData = Number(page) * takeData - takeData;
try {
if (!page) {
fixData = await prisma.investasi_Invoice.findMany({
orderBy: [
{
createdAt: "desc",
},
],
where: {
investasiId: investasiId,
isActive: true,
statusInvoiceId: {
contains: selectStatus ? selectStatus : "",
mode: "insensitive",
},
},
include: {
Author: true,
Images: true,
StatusInvoice: true,
MasterBank: true,
},
});
} else {
const data = await prisma.investasi_Invoice.findMany({
take: takeData,
skip: skipData,
orderBy: [
{
createdAt: "desc",
},
],
where: {
investasiId: investasiId,
isActive: true,
statusInvoiceId: {
contains: selectStatus ? selectStatus : "",
mode: "insensitive",
},
},
include: {
Author: true,
Images: true,
StatusInvoice: true,
MasterBank: true,
},
});
const nCount = await prisma.investasi_Invoice.count({
where: {
investasiId: investasiId,
isActive: true,
statusInvoiceId: {
contains: selectStatus ? selectStatus : "",
mode: "insensitive",
},
},
});
fixData = {
data: data,
nPage: _.ceil(nCount / takeData),
}
}
return NextResponse.json({
success: true,
message: "Success get data all transaksi investasi dashboard",
data: fixData,
},
{ status: 200 }
);
} catch (error) {
backendLogger.error("Error get data all transaksi investasi dashboard >>", error);
return NextResponse.json({
success: false,
message: "Error get data all transaksi investasi dashboard",
reason: (error as Error).message
},
{ status: 500 }
)
}
}

View File

@@ -1,4 +1,4 @@
import { MainColor } from "@/app_modules/_global/color/color_pallet";
import { AdminColor, MainColor } from "@/app_modules/_global/color/color_pallet";
import { Text } from "@mantine/core";
export function ComponentAdminGlobal_TampilanRupiah({
@@ -15,7 +15,7 @@ export function ComponentAdminGlobal_TampilanRupiah({
<Text
fz={fontSize ? fontSize : "md"}
style={{
color: color ? color : "black",
color: color ? color : AdminColor.white,
}}
>
Rp.{" "}

View File

@@ -67,4 +67,8 @@ const apiGetAdminInvestasiById = async ({id} : {id: string}) => {
})
return await response.json().catch(() => null);
}
const apiGetAdminAllTransaksiById = async () => {
}

View File

@@ -82,25 +82,25 @@ export function AdminInvestasi_ViewDaftarTransaksi({
const tableRows = data?.map((e, i) => (
<tr key={i}>
<td>
<Center>{e?.Author.username}</Center>
<Center c={AdminColor.white}>{e?.Author.username}</Center>
</td>
<td>
<Center>{e?.MasterBank.namaBank}</Center>
<Center c={AdminColor.white}>{e?.MasterBank.namaBank}</Center>
</td>
<td>
<Center>
<Center c={AdminColor.white}>
<ComponentAdminGlobal_TampilanRupiah nominal={+e?.nominal} />
</Center>
</td>
<td>
<Center>
<Center c={AdminColor.white}>
{new Intl.NumberFormat("id-ID", { maximumFractionDigits: 10 }).format(
+e?.lembarTerbeli
)}
</Center>
</td>
<td>
<Center>
<Center c={AdminColor.white}>
{new Intl.DateTimeFormat("id-ID", { dateStyle: "full" }).format(
e?.createdAt
)}
@@ -149,6 +149,7 @@ export function AdminInvestasi_ViewDaftarTransaksi({
{e.statusInvoiceId === "3" && "-"}
{e.statusInvoiceId === "4" && (
<AdminInvestasi_ComponentButtonBandingTransaksi
invoiceId={e.id}
investasiId={investasiId}
lembarTerbeli={e.lembarTerbeli}
@@ -240,8 +241,6 @@ export function AdminInvestasi_ViewDaftarTransaksi({
horizontalSpacing={"md"}
p={"md"}
w={1500}
striped
highlightOnHover
>
<thead>
<tr>

View File

@@ -34,7 +34,7 @@ const middlewareConfig: MiddlewareConfig = {
// ADMIN API
// >> buat dibawah sini <<
"/api/user",
"/api/admin/investasi/*",
// Akses awal