fix admin investasi

This commit is contained in:
2025-02-26 08:32:32 +08:00
parent 9e6ea4b185
commit c0d0773999
9 changed files with 476 additions and 559 deletions

View File

@@ -1,101 +0,0 @@
import backendLogger from "@/util/backendLogger";
import _ from "lodash";
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
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

@@ -3,25 +3,24 @@ import _ from "lodash";
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
import prisma from "@/lib/prisma"; import prisma from "@/lib/prisma";
export async function GET(
export async function GET(request: Request, { params }: { params: { id: string } }) { request: Request,
{ params }: { params: { id: string } }
) {
try { try {
let fixData let fixData;
const { id } = params; const { id } = params;
const { searchParams } = new URL(request.url); const { searchParams } = new URL(request.url);
const page = searchParams.get("page"); const page = searchParams.get("page");
const status = searchParams.get("status"); const status = searchParams.get("status");
const takeData = 10; const takeData = 10
const skipData = Number(page) * takeData - takeData; const skipData = Number(page) * takeData - takeData;
if (!page) { if (!page) {
fixData = await prisma.investasi_Invoice.findMany({ fixData = await prisma.investasi_Invoice.findMany({
orderBy: [ orderBy: {
{
createdAt: "desc", createdAt: "desc",
}, },
],
where: { where: {
investasiId: id, investasiId: id,
isActive: true, isActive: true,
@@ -33,27 +32,24 @@ export async function GET(request: Request, { params }: { params: { id: string }
MasterBank: true, MasterBank: true,
}, },
}); });
} else { } else {
const fixStatus = _.startCase(status ? status : "");
const data = await prisma.investasi_Invoice.findMany({ const data = await prisma.investasi_Invoice.findMany({
take: takeData, take: takeData,
skip: skipData, skip: skipData,
orderBy: [ orderBy: {
{
createdAt: "desc", createdAt: "desc",
}, },
],
where: { where: {
investasiId: id, investasiId: id,
isActive: true, isActive: true,
StatusInvoice: { StatusInvoice: {
name: { name: {
contains: status ? status : "", contains: fixStatus,
mode: "insensitive", mode: "insensitive",
},
} },
}
}, },
include: { include: {
Author: true, Author: true,
@@ -69,12 +65,10 @@ export async function GET(request: Request, { params }: { params: { id: string }
isActive: true, isActive: true,
StatusInvoice: { StatusInvoice: {
name: { name: {
contains: status ? status : "", contains: fixStatus,
mode: "insensitive", mode: "insensitive",
},
} },
}
}, },
}); });
@@ -82,24 +76,25 @@ export async function GET(request: Request, { params }: { params: { id: string }
data: data, data: data,
nPage: _.ceil(nCount / takeData), nPage: _.ceil(nCount / takeData),
}; };
} }
return NextResponse.json({ return NextResponse.json(
{
success: true, success: true,
message: "Success get status transaksi", message: "Success get status transaksi",
data: fixData data: fixData,
}, },
{ status: 200 } { status: 200 }
) );
} catch (error) { } catch (error) {
backendLogger.error("Eror get status transaksi", error); backendLogger.error("Eror get status transaksi", error);
return NextResponse.json({ return NextResponse.json(
{
success: false, success: false,
message: "Error get status transaksi", message: "Error get status transaksi",
reason: (error as Error).message reason: (error as Error).message,
}, },
{ status: 500 } { status: 500 }
) );
} }
} }

View File

@@ -2,32 +2,36 @@ import { prisma } from "@/lib";
import _ from "lodash"; import _ from "lodash";
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
export async function GET(request: Request, { params }: { export async function GET(
params: { name: string } request: Request,
} {
params,
}: {
params: { name: string };
}
) { ) {
const method = request.method; const method = request.method;
if (method !== "GET") { if (method !== "GET") {
return NextResponse.json({ return NextResponse.json(
{
success: false, success: false,
message: "Method not allowed", message: "Method not allowed",
}, },
{ status: 405 } { status: 405 }
) );
} }
const { name } = params; const { name } = params;
const { searchParams } = new URL(request.url); const { searchParams } = new URL(request.url);
const search = searchParams.get("search"); const search = searchParams.get("search");
const page = searchParams.get("page"); const page = searchParams.get("page");
const takeData = 10 const takeData = 10;
const skipData = Number(page) * takeData - takeData; const skipData = Number(page) * takeData - takeData;
try { try {
let fixData; let fixData;
const fixStatus = _.startCase(name); const fixStatus = _.startCase(name);
if (!page) { if (!page) {
fixData = await prisma.investasi.findMany({ fixData = await prisma.investasi.findMany({
orderBy: { orderBy: {
@@ -36,12 +40,12 @@ export async function GET(request: Request, { params }: {
where: { where: {
active: true, active: true,
MasterStatusInvestasi: { MasterStatusInvestasi: {
name: fixStatus name: fixStatus,
}, },
title: { title: {
contains: search ? search : "", contains: search ? search : "",
mode: "insensitive" mode: "insensitive",
} },
}, },
include: { include: {
MasterStatusInvestasi: true, MasterStatusInvestasi: true,
@@ -69,12 +73,12 @@ export async function GET(request: Request, { params }: {
where: { where: {
active: true, active: true,
MasterStatusInvestasi: { MasterStatusInvestasi: {
name: fixStatus name: fixStatus,
}, },
title: { title: {
contains: search ? search : "", contains: search ? search : "",
mode: "insensitive" mode: "insensitive",
} },
}, },
include: { include: {
MasterStatusInvestasi: true, MasterStatusInvestasi: true,
@@ -97,9 +101,12 @@ export async function GET(request: Request, { params }: {
where: { where: {
active: true, active: true,
MasterStatusInvestasi: { MasterStatusInvestasi: {
name: fixStatus name: fixStatus,
} },
title: {
contains: search ? search : "",
mode: "insensitive",
},
}, },
}); });
@@ -107,28 +114,25 @@ export async function GET(request: Request, { params }: {
data: data, data: data,
nPage: _.ceil(nCount / takeData), nPage: _.ceil(nCount / takeData),
}; };
} }
return NextResponse.json({ return NextResponse.json(
{
success: true, success: true,
message: "Success", message: "Success",
data: fixData, data: fixData,
}, },
{ status: 200 } { status: 200 }
) );
} catch (error) { } catch (error) {
console.log(error) console.log(error);
return NextResponse.json({ return NextResponse.json(
{
success: false, success: false,
message: "Failed", message: "Failed",
reason: (error as Error).message, reason: (error as Error).message,
}, },
{ status: 500 } { status: 500 }
) );
} }
} }

View File

@@ -9,7 +9,7 @@ export async function GET(request: Request) {
const { searchParams } = new URL(request.url); const { searchParams } = new URL(request.url);
const search = searchParams.get("search"); const search = searchParams.get("search");
const page = searchParams.get("page"); const page = searchParams.get("page");
const takeData = 2; const takeData = 10;
const skipData = Number(page) * takeData - takeData; const skipData = Number(page) * takeData - takeData;
if (!page) { if (!page) {

View File

@@ -1,4 +1,4 @@
import { globalStatusApp } from "./list_status_app"; import { globalStatusApp } from "./master_list_app";
import { MAX_SIZE } from "./max_size"; import { MAX_SIZE } from "./max_size";
export { MAX_SIZE }; export { MAX_SIZE };

View File

@@ -1,3 +1,5 @@
import statusTransaksi from "../../../../src/bin/seeder/master/master_status_transaksi.json"
export const globalStatusApp = [ export const globalStatusApp = [
{ {
id: "1", id: "1",
@@ -16,3 +18,5 @@ export const globalStatusApp = [
name: "Reject", name: "Reject",
}, },
]; ];
export const globalStatusTransaksi = statusTransaksi;

View File

@@ -1,19 +1,20 @@
import { globalStatusTransaksi } from "@/app_modules/_global/lib/master_list_app";
export { export {
apiGetAdminInvestasiCountDashboard, apiGetAdminInvestasiCountDashboard,
apiGetAdminInvestasiByStatus, apiGetAdminInvestasiByStatus,
apiGetAdminInvestasiById, apiGetAdminInvestasiById,
apiGetAdminAllTransaksiById, apiGetAdminAllTransaksiById,
apiGetAdminStatusTransaksi apiGetAdminStatusTransaksi,
};
} const apiGetAdminInvestasiCountDashboard = async ({
const apiGetAdminInvestasiCountDashboard = async ({ name }: name,
{ name: "Publish" | "Review" | "Reject" }) => { }: {
name: "Publish" | "Review" | "Reject";
}) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json()); const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null); if (!token) return await token.json().catch(() => null);
const response = await fetch(`/api/admin/investasi/dashboard/${name}`, { const response = await fetch(`/api/admin/investasi/dashboard/${name}`, {
method: "GET", method: "GET",
headers: { headers: {
@@ -22,25 +23,28 @@ const apiGetAdminInvestasiCountDashboard = async ({ name }:
"Access-Control-Allow-Origin": "*", "Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
}, },
}) });
return await response.json().catch(() => null); return await response.json().catch(() => null);
}; };
const apiGetAdminInvestasiByStatus = async ({ name, page, search }: { const apiGetAdminInvestasiByStatus = async ({
name: "Publish" | "Review" | "Reject", name,
page: string, page,
search: string search,
}: {
name: "Publish" | "Review" | "Reject";
page: string;
search: string;
}) => { }) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json()); const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null); if (!token) return await token.json().catch(() => null);
const isPage = page ? `?page=${page}` : ""; const isPage = page ? `?page=${page}` : "";
const isSearch = search ? `&search=${search}` : ""; const isSearch = search ? `&search=${search}` : "";
const response = await fetch(`/api/admin/investasi/status/${name}${isPage}${isSearch}`, { const response = await fetch(
`/api/admin/investasi/status/${name}${isPage}${isSearch}`,
{
method: "GET", method: "GET",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@@ -48,16 +52,16 @@ const apiGetAdminInvestasiByStatus = async ({ name, page, search }: {
"Access-Control-Allow-Origin": "*", "Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
}, },
}) }
);
return await response.json().catch(() => null); return await response.json().catch(() => null);
} };
const apiGetAdminInvestasiById = async ({id} : {id: string}) => { const apiGetAdminInvestasiById = async ({ id }: { id: string }) => {
const { token } = await fetch ("/api/get-cookie").then((res) => res.json()); const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null); if (!token) return await token.json().catch(() => null);
const response = await fetch(`/api/admin/investasi/${id}/detail`, { const response = await fetch(`/api/admin/investasi/${id}/detail`, {
method: "GET", method: "GET",
headers: { headers: {
@@ -65,32 +69,61 @@ const apiGetAdminInvestasiById = async ({id} : {id: string}) => {
Accept: "application/json", Accept: "application/json",
"Access-Control-Allow-Origin": "*", "Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
} },
}) });
return await response.json().catch(() => null); return await response.json().catch(() => null);
} };
const apiGetAdminAllTransaksiById = async ({id, page, status} : {id: string, page: string, status?: string}) => { const apiGetAdminAllTransaksiById = async ({
id,
page,
status,
}: {
id: string;
page: string;
status?: string | undefined;
}) => {
try {
// Fetch token from cookie
const { token } = await fetch("/api/get-cookie").then((res) => res.json()); const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null); if (!token) {
console.error("No token found");
return null;
}
// Fetch data
const isStatus = status ? `&status=${status}` : ""; const isStatus = status ? `&status=${status}` : "";
const isPage = page ? `?page=${page}` : ""; const isPage = page ? `?page=${page}` : "";
const response = await fetch(`/api/admin/investasi/${id}/transaksi${isPage}${isStatus}`, { const response = await fetch(
`/api/admin/investasi/${id}/transaksi${isPage}${isStatus}`,
{
method: "GET", method: "GET",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
Accept: "application/json", Accept: "application/json",
"Access-Control-Allow-Origin": "*", "Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
},
} }
}) );
return await response.json().catch(() => null); // Check if the response is OK
} if (!response.ok) {
const errorData = await response.json().catch(() => null);
console.error(
"Error get data transaksi invetsasi",
errorData?.message || "Unknown error"
);
return null;
}
return response.json();
} catch (error) {
console.error("Error get data transaksi invetsasi", error);
throw error;
}
};
const apiGetAdminStatusTransaksi = async () => { const apiGetAdminStatusTransaksi = async () => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json()); const { token } = await fetch("/api/get-cookie").then((res) => res.json());
@@ -103,8 +136,8 @@ const apiGetAdminStatusTransaksi = async () => {
Accept: "application/json", Accept: "application/json",
"Access-Control-Allow-Origin": "*", "Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
} },
}) });
return await response.json().catch(() => null); return await response.json().catch(() => null);
} };

View File

@@ -1,8 +1,16 @@
import { ComponentAdminGlobal_TampilanRupiah, ComponentAdminGlobal_TitlePage } from "@/app_modules/admin/_admin_global/_component"; 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";
import {
ComponentAdminGlobal_TampilanRupiah,
ComponentAdminGlobal_TitlePage,
} from "@/app_modules/admin/_admin_global/_component";
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import { import {
MODEL_INVOICE_INVESTASI, MODEL_INVOICE_INVESTASI,
MODEL_STATUS_INVOICE_INVESTASI, MODEL_STATUS_INVOICE_INVESTASI,
} from "@/app_modules/investasi/_lib/interface"; } from "@/app_modules/investasi/_lib/interface";
import { clientLogger } from "@/util/clientLogger";
import { import {
ActionIcon, ActionIcon,
Badge, Badge,
@@ -15,32 +23,24 @@ import {
Stack, Stack,
Table, Table,
Text, Text,
Title,
} from "@mantine/core"; } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { IconReload } from "@tabler/icons-react"; import { IconReload } from "@tabler/icons-react";
import { isEmpty } from "lodash"; import { useParams } from "next/navigation";
import { useParams, useRouter } from "next/navigation";
import { useState } from "react"; import { useState } from "react";
import { import {
AdminInvestasi_ComponentButtonBandingTransaksi, AdminInvestasi_ComponentButtonBandingTransaksi,
AdminInvestasi_ComponentButtonKonfirmasiTransaksi, AdminInvestasi_ComponentButtonKonfirmasiTransaksi,
AdminInvestasi_ComponentCekBuktiTransfer, AdminInvestasi_ComponentCekBuktiTransfer,
} from "../../_component"; } from "../../_component";
import { adminInvestasi_funGetAllTransaksiById } from "../../fun"; import { apiGetAdminAllTransaksiById } from "../../_lib/api_fetch_admin_investasi";
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() { export function AdminInvestasi_ViewDaftarTransaksi() {
const params = useParams<{ id: string }>(); const params = useParams<{ id: string }>();
const investasiId = params.id; const investasiId = params.id;
const router = useRouter(); const [listStatus, setListStatus] = useState<
const [isLoading, setLoading] = useState(false); MODEL_STATUS_INVOICE_INVESTASI[] | null
const [idData, setIdData] = useState(""); >(null);
const [listStatus, setListStatus] = useState<MODEL_STATUS_INVOICE_INVESTASI[] | null>(null);
const [data, setData] = useState<MODEL_INVOICE_INVESTASI[] | null>(null); const [data, setData] = useState<MODEL_INVOICE_INVESTASI[] | null>(null);
const [isNPage, setNPage] = useState<number>(1); const [isNPage, setNPage] = useState<number>(1);
@@ -48,25 +48,25 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
const [selectedStatus, setSelectedStatus] = useState(""); const [selectedStatus, setSelectedStatus] = useState("");
useShallowEffect(() => { useShallowEffect(() => {
loadInitialData(); handleLoadData();
}, [isActivePage, selectedStatus]) }, [isActivePage, selectedStatus]);
useShallowEffect(() => { useShallowEffect(() => {
loadStatus(); handleLoadStatus();
}, []) }, []);
const loadInitialData = async () => { const handleLoadData = async () => {
try { try {
const cek = globalStatusTransaksi.find((e) => e.id === selectedStatus);
const response = await apiGetAdminAllTransaksiById({ const response = await apiGetAdminAllTransaksiById({
id: investasiId, id: investasiId,
page: `${isNPage}`, page: `${isActivePage}`,
status: selectedStatus, status: cek?.name,
}) });
if (response?.success && response?.data?.data) { if (response?.success && response?.data?.data) {
setData(response.data.data); setData(response.data.data);
setNPage(response.nPage || 1); setNPage(response.data.nPage || 1);
setListStatus(response.data.data);
} else { } else {
console.error("Invalid data format received:", response); console.error("Invalid data format received:", response);
setData([]); setData([]);
@@ -75,16 +75,14 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
clientLogger.error("Error get data daftar tramnsaksi", error); clientLogger.error("Error get data daftar tramnsaksi", error);
setData([]); setData([]);
} }
} };
const handleLoadStatus = async () => {
const loadStatus = async () => {
try { try {
const response = await apiGetMasterStatusTransaksi() const response = await apiGetMasterStatusTransaksi();
if (response?.success && response?.data) { if (response?.success && response?.data) {
setListStatus(response.data); setListStatus(response.data);
console.log("status", response.data)
} else { } else {
console.error("Invalid data format received:", response); console.error("Invalid data format received:", response);
setListStatus(null); setListStatus(null);
@@ -93,33 +91,19 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
clientLogger.error("Error get status transaksi", error); clientLogger.error("Error get status transaksi", error);
setListStatus(null); setListStatus(null);
} }
} };
const onPageClick = async (page: number) => { const onPageClick = async (page: number) => {
const loadData = await apiGetAdminAllTransaksiById({
id: investasiId,
page: `${isNPage}`
})
setActivePage(page); setActivePage(page);
setData(loadData.data as any); };
setNPage(loadData.nPage);
}
async function onSelected(selectStatus: any) { async function onSelected(selectStatus: any) {
setSelectedStatus(selectStatus); setSelectedStatus(selectStatus);
// const loadData = await apiGetAdminStatusTransaksi();
// setData(loadData.data as any);
// setNPage(loadData.nPage);
} }
async function onReload() { async function onReload() {
const loadData = await apiGetAdminAllTransaksiById({ setSelectedStatus("");
id: investasiId, handleLoadData();
page: '1'
});
setData(loadData.data as any);
setNPage(loadData.nPage);
} }
const renderTableBody = () => { const renderTableBody = () => {
@@ -149,14 +133,16 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
</td> </td>
<td> <td>
<Center c={AdminColor.white}> <Center c={AdminColor.white}>
{new Intl.NumberFormat("id-ID", { maximumFractionDigits: 10 }).format( {new Intl.NumberFormat("id-ID", {
+e?.lembarTerbeli maximumFractionDigits: 10,
)} }).format(+e?.lembarTerbeli)}
</Center> </Center>
</td> </td>
<td> <td>
<Center c={AdminColor.white}> <Center c={AdminColor.white}>
{new Intl.DateTimeFormat("id-ID", { dateStyle: "full" }).format(new Date(e?.createdAt))} {new Intl.DateTimeFormat("id-ID", { dateStyle: "full" }).format(
new Date(e?.createdAt)
)}
</Center> </Center>
</td> </td>
<td> <td>
@@ -202,7 +188,6 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
{e.statusInvoiceId === "3" && "-"} {e.statusInvoiceId === "3" && "-"}
{e.statusInvoiceId === "4" && ( {e.statusInvoiceId === "4" && (
<AdminInvestasi_ComponentButtonBandingTransaksi <AdminInvestasi_ComponentButtonBandingTransaksi
invoiceId={e.id} invoiceId={e.id}
investasiId={investasiId} investasiId={investasiId}
lembarTerbeli={e.lembarTerbeli} lembarTerbeli={e.lembarTerbeli}
@@ -216,7 +201,9 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
</td> </td>
</tr> </tr>
)); ));
} };
if (!data && !listStatus) return <CustomSkeleton height={"80vh"} />;
return ( return (
<> <>
@@ -224,39 +211,7 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
<ComponentAdminGlobal_TitlePage <ComponentAdminGlobal_TitlePage
name="Transkasi" name="Transkasi"
color={AdminColor.softBlue} color={AdminColor.softBlue}
component={<Group> component={
<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> <Group>
<ActionIcon <ActionIcon
size={"lg"} size={"lg"}
@@ -272,21 +227,22 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
placeholder="Pilih status" placeholder="Pilih status"
value={selectedStatus} value={selectedStatus}
data={ data={
isEmpty(listStatsus) listStatus?.map((e, i) => ({
? []
: listStatsus.map((e) => ({
value: e.id, value: e.id,
label: e.name, label: e.name,
})) })) || []
} }
onChange={(val: any) => { onChange={(val: any) => {
onSelected(val); onSelected(val);
}} }}
/> />
</Group> </Group>
</Group> */} }
/>
{!data ? (<CustomSkeleton height={"80vh"} width={"100%"} />) : ( {!data ? (
<CustomSkeleton height={"80vh"} width={"100%"} />
) : (
<Paper bg={AdminColor.softBlue} p={"md"} shadow="lg" h={"80vh"}> <Paper bg={AdminColor.softBlue} p={"md"} shadow="lg" h={"80vh"}>
<ScrollArea w={"100%"} h={"90%"}> <ScrollArea w={"100%"} h={"90%"}>
<Table <Table
@@ -342,4 +298,3 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
</> </>
); );
} }

View File

@@ -15,7 +15,13 @@ import {
TextInput, TextInput,
Title, Title,
} from "@mantine/core"; } from "@mantine/core";
import { IconDetails, IconEye, IconEyeCheck, IconInfoCircle, IconSearch } from "@tabler/icons-react"; import {
IconDetails,
IconEye,
IconEyeCheck,
IconInfoCircle,
IconSearch,
} from "@tabler/icons-react";
import _ from "lodash"; import _ from "lodash";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { useState } from "react"; import { useState } from "react";
@@ -24,7 +30,10 @@ import ComponentAdminGlobal_IsEmptyData from "../../_admin_global/is_empty_data"
import { adminInvestasi_funGetAllPublish } from "../fun/get/get_all_publish"; import { adminInvestasi_funGetAllPublish } from "../fun/get/get_all_publish";
import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component"; import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component";
import { MainColor } from "@/app_modules/_global/color"; import { MainColor } from "@/app_modules/_global/color";
import { AccentColor, AdminColor } from "@/app_modules/_global/color/color_pallet"; import {
AccentColor,
AdminColor,
} from "@/app_modules/_global/color/color_pallet";
import { apiGetAdminInvestasiByStatus } from "../_lib/api_fetch_admin_investasi"; import { apiGetAdminInvestasiByStatus } from "../_lib/api_fetch_admin_investasi";
import { useShallowEffect } from "@mantine/hooks"; import { useShallowEffect } from "@mantine/hooks";
import { clientLogger } from "@/util/clientLogger"; import { clientLogger } from "@/util/clientLogger";
@@ -56,7 +65,7 @@ function TableView() {
if (typeof window !== "undefined") { if (typeof window !== "undefined") {
setOrigin(window.location.origin); setOrigin(window.location.origin);
} }
}, []) }, []);
useShallowEffect(() => { useShallowEffect(() => {
const loadInitialData = async () => { const loadInitialData = async () => {
@@ -84,15 +93,14 @@ function TableView() {
}, [activePage, isSearch]); }, [activePage, isSearch]);
const onSearch = async (searchTerm: string) => { const onSearch = async (searchTerm: string) => {
setSearch(searchTerm); setSearch(searchTerm);
setActivePage(1); };
}
const onPageClick = (page: number) => { const onPageClick = (page: number) => {
setActivePage(page) setActivePage(page);
} };
const renderTableBody = () => { const renderTableBody = () => {
if(!Array.isArray(data) || data.length === 0) { if (!Array.isArray(data) || data.length === 0) {
return ( return (
<tr> <tr>
<td colSpan={12}> <td colSpan={12}>
@@ -107,16 +115,22 @@ function TableView() {
<tr key={i}> <tr key={i}>
<td> <td>
<Center w={200}> <Center w={200}>
<Text c={AccentColor.white} lineClamp={1}>{e.author.username}</Text> <Text c={AccentColor.white} lineClamp={1}>
{e.author.username}
</Text>
</Center> </Center>
</td> </td>
<td> <td>
<Center w={400}> <Center w={400}>
<Text c={AccentColor.white} lineClamp={1}>{e.title}</Text> <Text c={AccentColor.white} lineClamp={1}>
{e.title}
</Text>
</Center> </Center>
</td> </td>
<td> <td>
<Center c={AccentColor.white} w={200}>{_.toNumber(e.progress).toFixed(2)} %</Center> <Center c={AccentColor.white} w={200}>
{_.toNumber(e.progress).toFixed(2)} %
</Center>
</td> </td>
<td> <td>
<Center c={AccentColor.white} w={200}> <Center c={AccentColor.white} w={200}>
@@ -134,7 +148,9 @@ function TableView() {
</td> </td>
<td> <td>
<Center w={200}> <Center w={200}>
<Text c={AccentColor.white} lineClamp={1}>{e.Investasi_Invoice.length}</Text> <Text c={AccentColor.white} lineClamp={1}>
{e.Investasi_Invoice.length}
</Text>
</Center> </Center>
</td> </td>
<td> <td>
@@ -158,8 +174,7 @@ function TableView() {
</td> </td>
</tr> </tr>
)); ));
} };
return ( return (
<> <>
@@ -208,31 +223,43 @@ function TableView() {
p={"md"} p={"md"}
w={"100%"} w={"100%"}
h={"100%"} h={"100%"}
> >
<thead> <thead>
<tr> <tr>
<th> <th>
<Center c={AccentColor.white} w={200}>Username</Center> <Center c={AccentColor.white} w={200}>
Username
</Center>
</th> </th>
<th> <th>
<Center c={AccentColor.white} w={400}>Nama Proyek</Center> <Center c={AccentColor.white} w={400}>
Nama Proyek
</Center>
</th> </th>
<th> <th>
<Center c={AccentColor.white} w={200}>Progres</Center> <Center c={AccentColor.white} w={200}>
Progres
</Center>
</th> </th>
<th> <th>
<Center c={AccentColor.white} w={200}>Sisa Saham</Center> <Center c={AccentColor.white} w={200}>
Sisa Saham
</Center>
</th> </th>
<th> <th>
<Center c={AccentColor.white} w={200}>Total Saham</Center> <Center c={AccentColor.white} w={200}>
Total Saham
</Center>
</th> </th>
<th> <th>
<Center c={AccentColor.white} w={200}>Validasi</Center> <Center c={AccentColor.white} w={200}>
Validasi
</Center>
</th> </th>
<th> <th>
<Center c={AccentColor.white} w={200}>Aksi</Center> <Center c={AccentColor.white} w={200}>
Aksi
</Center>
</th> </th>
</tr> </tr>
</thead> </thead>