diff --git a/src/app/api/investasi/saham/[id]/route.ts b/src/app/api/investasi/saham/[id]/route.ts
new file mode 100644
index 00000000..7fc89611
--- /dev/null
+++ b/src/app/api/investasi/saham/[id]/route.ts
@@ -0,0 +1,60 @@
+import { NextResponse } from "next/server";
+
+export { GET };
+
+async function GET(request: Request, { params }: { params: { id: string } }) {
+ try {
+ const { id } = params;
+ const data = await prisma.investasi_Invoice.findFirst({
+ where: {
+ id: id,
+ },
+ include: {
+ MasterBank: true,
+ StatusInvoice: {
+ where: {
+ name: "Berhasil",
+ }
+ },
+ Investasi: {
+ include: {
+ MasterPembagianDeviden: true,
+ MasterPencarianInvestor: true,
+ MasterPeriodeDeviden: true,
+ ProspektusInvestasi: true,
+ Investasi_Invoice: {
+ where: {
+ statusInvoiceId: "1",
+ },
+ },
+ },
+ },
+ Author: {
+ include: {
+ Profile: true,
+ },
+ },
+ },
+ });
+
+ const { ...allData } = data;
+ const Investor = data?.Investasi?.Investasi_Invoice;
+ const result = { ...allData, Investor };
+
+ return NextResponse.json({
+ success: true,
+ message: "Berhasil mengambil data",
+ data: result,
+ });
+ } catch (error) {
+ console.log(error);
+ return NextResponse.json(
+ {
+ success: false,
+ message: "Gagal mengambil data",
+ reason: (error as Error).message,
+ },
+ { status: 500 }
+ );
+ }
+}
diff --git a/src/app/dev/investasi/detail/saham/[id]/page.tsx b/src/app/dev/investasi/detail/saham/[id]/page.tsx
index 0b3edcea..3a6e6e22 100644
--- a/src/app/dev/investasi/detail/saham/[id]/page.tsx
+++ b/src/app/dev/investasi/detail/saham/[id]/page.tsx
@@ -3,11 +3,11 @@ import { Investasi_UiDetailSahamSaya } from "@/app_modules/investasi/_ui";
export default async function Page({ params }: { params: { id: string } }) {
const invoiceId = params.id;
- const dataSaham = await investasi_funGetOneInvoiceById({ invoiceId });
+ // const dataSaham = await investasi_funGetOneInvoiceById({ invoiceId });
return (
<>
-
+
>
);
}
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 68bd5a55..086d08da 100644
--- a/src/app_modules/investasi/_lib/api_fetch_new_investasi.ts
+++ b/src/app_modules/investasi/_lib/api_fetch_new_investasi.ts
@@ -2,6 +2,7 @@ export {
apiFetchGetAllInvestasi,
apiNewGetOneInvestasiById,
apiGetInvestorById,
+ apiGetOneSahamInvestasiById,
};
const apiFetchGetAllInvestasi = async ({ page }: { page: string }) => {
@@ -114,3 +115,44 @@ const apiGetInvestorById = async ({
throw error; // Re-throw the error to handle it in the calling function
}
};
+
+const apiGetOneSahamInvestasiById = 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/saham/${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 list investor",
+ response.statusText,
+ errorData
+ );
+ throw new Error(errorData?.message || "Failed to get list investor");
+ }
+
+ // Return the JSON response
+ return await response.json();
+ } catch (error) {
+ console.error("Error get list investor", 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 bbf23bb3..8ed687b3 100644
--- a/src/app_modules/investasi/_ui/detail/ui_detail_main.tsx
+++ b/src/app_modules/investasi/_ui/detail/ui_detail_main.tsx
@@ -1,25 +1,22 @@
"use client";
+import { MainColor } from "@/app_modules/_global/color";
import {
UIGlobal_Drawer,
UIGlobal_LayoutHeaderTamplate,
UIGlobal_LayoutTamplate,
} from "@/app_modules/_global/ui";
+import {
+ NEW_RouterInvestasi
+} from "@/lib/router_hipmi/router_investasi";
import { ActionIcon } from "@mantine/core";
-import { IconCategoryPlus, IconDotsVertical } from "@tabler/icons-react";
-import { MODEL_INVESTASI } from "../../_lib/interface";
-import { Investasi_ViewDetailPublish } from "../../_view";
+import { useShallowEffect } from "@mantine/hooks";
+import { IconCategoryPlus, IconDeviceIpadPlus, IconDotsVertical } from "@tabler/icons-react";
import { useParams, useRouter } from "next/navigation";
import { useState } from "react";
-import {
- NEW_RouterInvestasi,
- RouterInvestasi_OLD,
-} 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";
+import { MODEL_INVESTASI } from "../../_lib/interface";
+import { Investasi_ViewDetailPublish } from "../../_view";
export function Investasi_UiDetailMain({
userLoginId,
@@ -31,21 +28,6 @@ export function Investasi_UiDetailMain({
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: data?.id as any }),
- },
- {
- id: "2",
- name: "Tambah & Edit Berita",
- icon: ,
- path: NEW_RouterInvestasi.rekap_berita({ id: data?.id as any }),
- },
- ];
-
useShallowEffect(() => {
handleLoadData();
}, []);
@@ -65,6 +47,21 @@ export function Investasi_UiDetailMain({
}
};
+ const listPage = [
+ {
+ id: "1",
+ name: "Tambah & Edit Dokumen",
+ icon: ,
+ path: NEW_RouterInvestasi.rekap_dokumen({ id: data?.id as any }),
+ },
+ {
+ id: "2",
+ name: "Tambah & Edit Berita",
+ icon: ,
+ path: NEW_RouterInvestasi.rekap_berita({ id: data?.id as any }),
+ },
+ ];
+
return (
<>
}
>
-
+
>
);
diff --git a/src/app_modules/investasi/_view/detail/view_detail_saham_saya.tsx b/src/app_modules/investasi/_view/detail/view_detail_saham_saya.tsx
index cdcfb312..bf2de920 100644
--- a/src/app_modules/investasi/_view/detail/view_detail_saham_saya.tsx
+++ b/src/app_modules/investasi/_view/detail/view_detail_saham_saya.tsx
@@ -5,21 +5,42 @@ import {
Investasi_ComponentBoxHargaDanLembarSaham,
Investasi_ComponentBoxProgress,
} from "../../_component";
-import { MODEL_INVOICE_INVESTASI } from "../../_lib/interface";
+import { MODEL_INVESTASI, MODEL_INVOICE_INVESTASI } from "../../_lib/interface";
+import { useShallowEffect } from "@mantine/hooks";
+import { apiGetOneSahamInvestasiById, apiNewGetOneInvestasiById } from "../../_lib/api_fetch_new_investasi";
+import { useParams } from "next/navigation";
+import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
-export function Investasi_ViewDetailSahamSaya({
- dataSaham,
-}: {
- dataSaham: MODEL_INVOICE_INVESTASI;
-}) {
- const [data, setData] = useState(dataSaham);
+export function Investasi_ViewDetailSahamSaya() {
+ const param = useParams<{ id: string }>();
+ const [data, setData] = useState(null);
+
+ useShallowEffect(() => {
+ handleLoadData();
+ }, []);
+
+ const handleLoadData = async () => {
+ try {
+ const response = await apiGetOneSahamInvestasiById({ id: param.id });
+ if (response.success) {
+ setData(response.data);
+ } else {
+ setData(null);
+ }
+ } catch (error) {
+ console.error("Error get investasi", error);
+ setData(null);
+ }
+ };
+
+ if (!data) return ;
return (
<>
-
-
-
+
+
+
>
);