diff --git a/src/app/api/investasi/[id]/route.ts b/src/app/api/investasi/[id]/route.ts
new file mode 100644
index 00000000..1c83c6a7
--- /dev/null
+++ b/src/app/api/investasi/[id]/route.ts
@@ -0,0 +1,49 @@
+import { prisma } from "@/lib";
+import { NextResponse } from "next/server";
+export const dynamic = "force-dynamic";
+
+// GET ONE DATA INVESTASI BY ID
+export async function GET(
+ request: Request,
+ context: { params: { id: string } }
+) {
+ try {
+ const { id } = context.params;
+ const data = await prisma.investasi.findUnique({
+ where: {
+ id: id,
+ },
+ include: {
+ author: {
+ include: {
+ Profile: true,
+ },
+ },
+ Investasi_Invoice: true,
+ MasterStatusInvestasi: true,
+ BeritaInvestasi: true,
+ DokumenInvestasi: true,
+ ProspektusInvestasi: true,
+ MasterPembagianDeviden: true,
+ MasterPencarianInvestor: true,
+ MasterPeriodeDeviden: true,
+ MasterProgresInvestasi: true,
+ },
+ });
+
+ return NextResponse.json(
+ { success: true, message: "Berhasil mendapatkan data", data },
+ { status: 200 }
+ );
+ } catch (error) {
+ console.error(error);
+ return NextResponse.json(
+ {
+ success: false,
+ message: "Gagal mendapatkan data, coba lagi nanti ",
+ reason: (error as Error).message,
+ },
+ { status: 500 }
+ );
+ }
+}
diff --git a/src/app/dev/investasi/[id]/investor/page.tsx b/src/app/dev/investasi/[id]/investor/page.tsx
new file mode 100644
index 00000000..bca95f92
--- /dev/null
+++ b/src/app/dev/investasi/[id]/investor/page.tsx
@@ -0,0 +1,11 @@
+import { Investasi_UiListInvestor } from "@/app_modules/investasi/_ui/detail/ui_list_investor";
+
+async function Page() {
+ return (
+ <>
+
+ >
+ );
+}
+
+export default Page;
diff --git a/src/app/dev/investasi/detail/[id]/page.tsx b/src/app/dev/investasi/detail/[id]/page.tsx
index 24d16617..539f2223 100644
--- a/src/app/dev/investasi/detail/[id]/page.tsx
+++ b/src/app/dev/investasi/detail/[id]/page.tsx
@@ -1,20 +1,12 @@
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
-import { investasi_funGetOneInvestasiById } from "@/app_modules/investasi/_fun";
import { Investasi_UiDetailMain } from "@/app_modules/investasi/_ui";
-
-export default async function Page({ params }: { params: { id: string } }) {
- const investasiId = params.id;
+export default async function Page() {
const userLoginId = await funGetUserIdByToken();
- const dataInvestasi = await investasi_funGetOneInvestasiById({ investasiId });
-
return (
<>
-
+
>
);
}
diff --git a/src/app_modules/event/detail/invoice/index.tsx b/src/app_modules/event/detail/invoice/index.tsx
index d3a4ee70..d8f0d382 100644
--- a/src/app_modules/event/detail/invoice/index.tsx
+++ b/src/app_modules/event/detail/invoice/index.tsx
@@ -15,8 +15,6 @@ function Event_Invoice({ userLoginId }: { userLoginId: string }) {
const [nominal, setNominal] = useAtom(gs_nominal_sponsor);
const [bankId, setBankId] = useAtom(gs_event_bank_id);
- console.log("nominal >>", nominal);
- console.log("bankId >>", bankId);
return (
<>
diff --git a/src/app_modules/event/detail/sponsor/metode_pembayaran/index.tsx b/src/app_modules/event/detail/sponsor/metode_pembayaran/index.tsx
index 8ac18bc3..c6a00714 100644
--- a/src/app_modules/event/detail/sponsor/metode_pembayaran/index.tsx
+++ b/src/app_modules/event/detail/sponsor/metode_pembayaran/index.tsx
@@ -25,7 +25,6 @@ function Event_MetodePembayaran() {
const [nominal, setNominal] = useAtom(gs_nominal_sponsor);
const [bankId, setBankId] = useAtom(gs_event_bank_id);
const [isLoading, setIsLoading] = useState(false);
- console.log("nominal >>", nominal);
const [data, setData] = useState(null);
useShallowEffect(() => {
diff --git a/src/app_modules/event/detail/tambah_sponsor/index.tsx b/src/app_modules/event/detail/tambah_sponsor/index.tsx
index da8b794f..43b97eb9 100644
--- a/src/app_modules/event/detail/tambah_sponsor/index.tsx
+++ b/src/app_modules/event/detail/tambah_sponsor/index.tsx
@@ -77,8 +77,6 @@ function Event_TambahSponsor() {
data: data,
});
- console.log("res >>", created);
-
if (created) {
router.replace(RouterEvent.nominal_sponsor({ id: params.id }));
ComponentGlobal_NotifikasiBerhasil(created.message);
diff --git a/src/app_modules/investasi/_component/detail/comp_box_investor.tsx b/src/app_modules/investasi/_component/detail/comp_box_investor.tsx
new file mode 100644
index 00000000..a696e1d0
--- /dev/null
+++ b/src/app_modules/investasi/_component/detail/comp_box_investor.tsx
@@ -0,0 +1,43 @@
+import { NEW_RouterInvestasi } from "@/lib/router_hipmi/router_investasi";
+import { AccentColor, MainColor } from "@/app_modules/_global/color";
+import { ActionIcon, Flex, Loader, Paper, Text } from "@mantine/core";
+import { IconBookDownload, IconZoomMoney } from "@tabler/icons-react";
+import { useRouter } from "next/navigation";
+import { useState } from "react";
+import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
+
+export function Investasi_ComponentBoxInvestor({ id }: { id: string }) {
+ const router = useRouter();
+ const [isLoading, setLoading] = useState(false);
+
+ return (
+ <>
+ {
+ setLoading(true);
+ router.push(NEW_RouterInvestasi.list_investor({id:id}))
+ }}
+ >
+
+
+ Investor
+
+
+ {isLoading ? (
+
+ ) : (
+
+ )}
+
+
+
+ >
+ );
+}
diff --git a/src/app_modules/investasi/_component/index.ts b/src/app_modules/investasi/_component/index.ts
index ef436387..6d83948f 100644
--- a/src/app_modules/investasi/_component/index.ts
+++ b/src/app_modules/investasi/_component/index.ts
@@ -18,6 +18,7 @@ import { Investasi_ComponentDetailDataNonPublish } from "./detail/comp_detail_da
import { Investasi_ComponentButtonUpdateDataInvestasi } from "./button/comp_button_update_investasi";
import { Investasi_ComponentCardRekapDocument } from "./detail/comp_card_rekap_document";
import { Investasi_ComponentCardDaftarDocument } from "./detail/comp_card_daftar_document";
+import { Investasi_ComponentBoxInvestor } from "./detail/comp_box_investor";
export { Investasi_ComponentFooterMain };
export { Investasi_ComponentCardBeranda };
@@ -39,3 +40,4 @@ export { Investasi_ComponentDetailDataNonPublish };
export { Investasi_ComponentButtonUpdateDataInvestasi };
export { Investasi_ComponentCardRekapDocument };
export { Investasi_ComponentCardDaftarDocument };
+export { Investasi_ComponentBoxInvestor };
diff --git a/src/app_modules/investasi/_lib/api_fetch_new_investasi.ts b/src/app_modules/investasi/_lib/api_fetch_new_investasi.ts
index 647af6f5..471703d1 100644
--- a/src/app_modules/investasi/_lib/api_fetch_new_investasi.ts
+++ b/src/app_modules/investasi/_lib/api_fetch_new_investasi.ts
@@ -1,4 +1,4 @@
-export { apiFetchGetAllInvestasi };
+export { apiFetchGetAllInvestasi, apiNewGetOneInvestasiById };
const apiFetchGetAllInvestasi = async ({ page }: { page: string }) => {
try {
@@ -33,3 +33,37 @@ const apiFetchGetAllInvestasi = async ({ page }: { page: string }) => {
throw error; // Re-throw the error to handle it in the calling function
}
};
+
+const apiNewGetOneInvestasiById = async ({ id }: { id: string }) => {
+ try {
+ // Fetch token from cookie
+ const { token } = await fetch("/api/get-cookie").then((res) => res.json());
+ if (!token) {
+ console.error("No token found");
+ return null;
+ }
+
+
+ const response = await fetch(`/api/investasi/${id}`, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ Authorization: `Bearer ${token}`,
+ },
+ });
+
+ // Check if the response is OK
+ if (!response.ok) {
+ const errorData = await response.json().catch(() => null);
+ console.error("Failed to get all forum:", response.statusText, errorData);
+ throw new Error(errorData?.message || "Failed to get all forum");
+ }
+
+ // Return the JSON response
+ return await response.json();
+ } catch (error) {
+ console.error("Error get all forum", error);
+ throw error; // Re-throw the error to handle it in the calling function
+ }
+};
diff --git a/src/app_modules/investasi/_ui/detail/ui_detail_main.tsx b/src/app_modules/investasi/_ui/detail/ui_detail_main.tsx
index dee395b2..e0ff7236 100644
--- a/src/app_modules/investasi/_ui/detail/ui_detail_main.tsx
+++ b/src/app_modules/investasi/_ui/detail/ui_detail_main.tsx
@@ -9,7 +9,7 @@ import { ActionIcon } from "@mantine/core";
import { IconCategoryPlus, IconDotsVertical } from "@tabler/icons-react";
import { MODEL_INVESTASI } from "../../_lib/interface";
import { Investasi_ViewDetailPublish } from "../../_view";
-import { useRouter } from "next/navigation";
+import { useParams, useRouter } from "next/navigation";
import { useState } from "react";
import {
NEW_RouterInvestasi,
@@ -17,32 +17,55 @@ import {
} from "@/lib/router_hipmi/router_investasi";
import { IconDeviceIpadPlus } from "@tabler/icons-react";
import { MainColor } from "@/app_modules/_global/color";
+import { useShallowEffect } from "@mantine/hooks";
+import { apiNewGetOneInvestasiById } from "../../_lib/api_fetch_new_investasi";
+import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
export function Investasi_UiDetailMain({
- dataInvestasi,
userLoginId,
}: {
- dataInvestasi: MODEL_INVESTASI;
userLoginId: string;
}) {
+ const param = useParams<{ id: string }>();
const router = useRouter();
const [openDrawer, setOpenDrawer] = useState(false);
+ const [data, setData] = useState(null);
const listPage = [
{
id: "1",
name: "Tambah & Edit Dokumen",
icon: ,
- path: NEW_RouterInvestasi.rekap_dokumen({ id: dataInvestasi.id }),
+ path: NEW_RouterInvestasi.rekap_dokumen({ id: data?.id as any }),
},
{
id: "2",
name: "Tambah & Edit Berita",
icon: ,
- path: NEW_RouterInvestasi.rekap_berita({ id: dataInvestasi.id }),
+ path: NEW_RouterInvestasi.rekap_berita({ id: data?.id as any }),
},
];
+ useShallowEffect(() => {
+ handleLoadData();
+ }, []);
+
+ const handleLoadData = async () => {
+ try {
+ const response = await apiNewGetOneInvestasiById({ id: param.id });
+
+ if (response.success) {
+ console.log(response.data);
+ setData(response.data);
+ } else {
+ setData(null);
+ }
+ } catch (error) {
+ console.error("Error get investasi", error);
+ setData(null);
+ }
+ };
+
return (
<>
setOpenDrawer(true)}
@@ -65,7 +88,7 @@ export function Investasi_UiDetailMain({
}
>
diff --git a/src/app_modules/investasi/_ui/detail/ui_list_investor.tsx b/src/app_modules/investasi/_ui/detail/ui_list_investor.tsx
new file mode 100644
index 00000000..4f945928
--- /dev/null
+++ b/src/app_modules/investasi/_ui/detail/ui_list_investor.tsx
@@ -0,0 +1,20 @@
+"use client";
+
+import {
+ UIGlobal_LayoutHeaderTamplate,
+ UIGlobal_LayoutTamplate,
+} from "@/app_modules/_global/ui";
+import { Stack } from "@mantine/core";
+import { Investasi_ViewListInvestor } from "../../_view/detail/view_list_investor";
+
+export function Investasi_UiListInvestor() {
+ return (
+ <>
+ }
+ >
+
+
+ >
+ );
+}
diff --git a/src/app_modules/investasi/_ui/file_view/ui_file_view_prospektus.tsx b/src/app_modules/investasi/_ui/file_view/ui_file_view_prospektus.tsx
index f157ce06..fca16f2a 100644
--- a/src/app_modules/investasi/_ui/file_view/ui_file_view_prospektus.tsx
+++ b/src/app_modules/investasi/_ui/file_view/ui_file_view_prospektus.tsx
@@ -20,8 +20,6 @@ export function Investasi_UiFileViewProspektus() {
const param = useParams<{ id: string }>();
const prospektusId = param.id;
- console.log(">>", prospektusId);
-
const [pdfPages, setPdfPages] = useState(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
diff --git a/src/app_modules/investasi/_view/detail/portofolio/view_detail_publish.tsx b/src/app_modules/investasi/_view/detail/portofolio/view_detail_publish.tsx
index 173e2730..c05019d6 100644
--- a/src/app_modules/investasi/_view/detail/portofolio/view_detail_publish.tsx
+++ b/src/app_modules/investasi/_view/detail/portofolio/view_detail_publish.tsx
@@ -1,23 +1,22 @@
"use client";
-import {
- NEW_RouterInvestasi,
- RouterInvestasi_OLD,
-} from "@/lib/router_hipmi/router_investasi";
import { MainColor } from "@/app_modules/_global/color/color_pallet";
import {
ComponentGlobal_AvatarAndUsername,
ComponentGlobal_CardStyles,
ComponentGlobal_LoadImageLandscape,
} from "@/app_modules/_global/component";
+import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import {
Investasi_ComponentBoxDaftarBerita,
Investasi_ComponentBoxDaftarDokumen,
+ Investasi_ComponentBoxInvestor,
Investasi_ComponentBoxProgress,
Investasi_ComponentBoxProspektus,
Investasi_ComponentTitleAndValueInDetail,
} from "@/app_modules/investasi/_component";
import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
+import { NEW_RouterInvestasi } from "@/lib/router_hipmi/router_investasi";
import {
Box,
Button,
@@ -28,25 +27,19 @@ import {
Title,
} from "@mantine/core";
import { useLocalStorage } from "@mantine/hooks";
-import {
- IconBookDownload,
- IconFileDescription,
- IconSpeakerphone,
-} from "@tabler/icons-react";
import _ from "lodash";
import moment from "moment";
import { useRouter } from "next/navigation";
import { useState } from "react";
export default function Investasi_ViewDetailPublish({
- dataInvestasi,
+ data,
userLoginId,
}: {
- dataInvestasi: MODEL_INVESTASI;
+ data: MODEL_INVESTASI | null;
userLoginId: string;
}) {
const router = useRouter();
- const [data, setData] = useState(dataInvestasi);
const [boxId, setBoxId] = useState(0);
const [isLoadingBox, setLoadingBox] = useState(false);
const [isLoadingButton, setLoadingButton] = useState(false);
@@ -62,26 +55,28 @@ export default function Investasi_ViewDetailPublish({
setLoadingButton(true);
//NEW
- router.push(NEW_RouterInvestasi.pembelian + data.id, { scroll: false });
+ router.push(NEW_RouterInvestasi.pembelian + data?.id, { scroll: false });
setTotal(0);
setJumlah(0);
}
+ if (!data) return ;
+
return (
-
+
-
+
{/* Title dan Persentase */}
- {_.startCase(data.title)}
+ {_.startCase(data?.title)}
@@ -90,7 +85,11 @@ export default function Investasi_ViewDetailPublish({
{data.Investasi_Invoice.length} }
+ value={
+
+ {data?.Investasi_Invoice.length}{" "}
+
+ }
/>
}
/>
@@ -111,14 +110,18 @@ export default function Investasi_ViewDetailPublish({
Rp.{" "}
{new Intl.NumberFormat("id-ID", {
maximumSignificantDigits: 10,
- }).format(+data.hargaLembar)}
+ }).format(+data?.hargaLembar)}
}
/>
Return Of Invesment (RoI)}
- value={{data.roi} %}
+ title={
+
+ Return Of Invesment (RoI)
+
+ }
+ value={{data?.roi} %}
/>
{new Intl.NumberFormat("id-ID", {
maximumSignificantDigits: 10,
- }).format(+data.totalLembar)}{" "}
+ }).format(+data?.totalLembar)}{" "}
lembar
}
@@ -139,7 +142,7 @@ export default function Investasi_ViewDetailPublish({
{new Intl.NumberFormat("id-ID", {
maximumSignificantDigits: 10,
- }).format(+data.sisaLembar)}{" "}
+ }).format(+data?.sisaLembar)}{" "}
lembar
}
@@ -147,29 +150,42 @@ export default function Investasi_ViewDetailPublish({
{data.MasterPembagianDeviden.name} Bulan }
+ value={
+
+ {data?.MasterPembagianDeviden.name} Bulan{" "}
+
+ }
/>
{data.MasterPeriodeDeviden.name}}
+ value={
+
+ {data?.MasterPeriodeDeviden.name}
+
+ }
/>
{data.MasterPencarianInvestor.name} Hari }
+ value={
+
+ {data?.MasterPencarianInvestor.name} Hari{" "}
+
+ }
/>
{/* List Box */}
+
@@ -178,9 +194,9 @@ export default function Investasi_ViewDetailPublish({
- {data.sisaLembar === "0" ||
- Number(data.MasterPencarianInvestor.name) -
- moment(new Date()).diff(new Date(data.countDown), "days") <=
+ {data?.sisaLembar === "0" ||
+ Number(data?.MasterPencarianInvestor.name) -
+ moment(new Date()).diff(new Date(data?.countDown), "days") <=
0 ? (
) : (
- {userLoginId === data.authorId ? (
+ {userLoginId === data?.authorId ? (