fix ( upload image & api )
deskripsi: - fix upload dokumen investasi - fix api investasi
This commit is contained in:
@@ -2,39 +2,48 @@ import { prisma } from "@/app/lib";
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
export const dynamic = "force-dynamic";
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// GET ONE DATA INVESTASI BY ID
|
// GET ONE DATA INVESTASI BY ID
|
||||||
export async function GET(request: Request, context: { params: { id: string } }) {
|
export async function GET(
|
||||||
try {
|
request: Request,
|
||||||
const { id } = context.params
|
context: { params: { id: string } }
|
||||||
const data = await prisma.investasi.findUnique({
|
) {
|
||||||
where: {
|
try {
|
||||||
id: id,
|
const { id } = context.params;
|
||||||
},
|
const data = await prisma.investasi.findUnique({
|
||||||
select: {
|
where: {
|
||||||
id: true,
|
id: id,
|
||||||
title: true,
|
},
|
||||||
targetDana: true,
|
include: {
|
||||||
hargaLembar: true,
|
author: {
|
||||||
totalLembar: true,
|
include: {
|
||||||
roi: true,
|
Profile: true,
|
||||||
countDown: true,
|
},
|
||||||
catatan: true,
|
},
|
||||||
sisaLembar: true,
|
Investasi_Invoice: true,
|
||||||
imageId: true,
|
MasterStatusInvestasi: true,
|
||||||
prospektusFileId: true,
|
BeritaInvestasi: true,
|
||||||
masterPencarianInvestorId: true,
|
DokumenInvestasi: true,
|
||||||
masterPeriodeDevidenId: true,
|
ProspektusInvestasi: true,
|
||||||
masterPembagianDevidenId: true,
|
MasterPembagianDeviden: true,
|
||||||
}
|
MasterPencarianInvestor: true,
|
||||||
});
|
MasterPeriodeDeviden: true,
|
||||||
|
MasterProgresInvestasi: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
return NextResponse.json({ success: true, message: "Berhasil mendapatkan data", data }, { status: 200 });
|
return NextResponse.json(
|
||||||
|
{ success: true, message: "Berhasil mendapatkan data", data },
|
||||||
}
|
{ status: 200 }
|
||||||
catch (error) {
|
);
|
||||||
console.error(error);
|
} catch (error) {
|
||||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan data, coba lagi nanti ", reason: (error as Error).message, }, { status: 500 });
|
console.error(error);
|
||||||
}
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Gagal mendapatkan data, coba lagi nanti ",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
61
src/app/api/new/investasi/dokumen/[id]/route.ts
Normal file
61
src/app/api/new/investasi/dokumen/[id]/route.ts
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import { prisma } from "@/app/lib";
|
||||||
|
import backendLogger from "@/util/backendLogger";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
export async function GET(
|
||||||
|
request: Request,
|
||||||
|
context: { params: { id: string } }
|
||||||
|
) {
|
||||||
|
if (request.method === "GET") {
|
||||||
|
try {
|
||||||
|
let fixData;
|
||||||
|
const { id } = context.params;
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const kategori = searchParams.get("kategori");
|
||||||
|
const page = searchParams.get("page");
|
||||||
|
const takeData = 10;
|
||||||
|
const skipData = Number(page) * takeData - takeData;
|
||||||
|
|
||||||
|
if (kategori == null) {
|
||||||
|
fixData = await prisma.dokumenInvestasi.findFirst({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else if (kategori == "get-all") {
|
||||||
|
fixData = await prisma.dokumenInvestasi.findMany({
|
||||||
|
take: takeData,
|
||||||
|
skip: skipData,
|
||||||
|
orderBy: {
|
||||||
|
updatedAt: "desc",
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
investasiId: id,
|
||||||
|
active: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await prisma.$disconnect();
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{ success: true, message: "Success get data document", data: fixData },
|
||||||
|
{ status: 200 }
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
backendLogger.error("Error get data document", error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Failed to get data, try again later",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NextResponse.json(
|
||||||
|
{ success: false, message: "Method not allowed" },
|
||||||
|
{ status: 405 }
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
import { Investasi_UiCreateDocument } from "@/app_modules/investasi/_ui";
|
import { Investasi_UiCreateDocument } from "@/app_modules/investasi/_ui";
|
||||||
|
|
||||||
export default async function Page({ params }: { params: { id: string } }) {
|
export default async function Page() {
|
||||||
const investasiId = params.id;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Investasi_UiCreateDocument investasiId={investasiId} />
|
<Investasi_UiCreateDocument />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,9 @@
|
|||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
|
||||||
import { investasi_funGetOneInvestasiById } from "@/app_modules/investasi/_fun";
|
|
||||||
import { Investasi_UiDetailPortofolio } from "@/app_modules/investasi/_ui";
|
import { Investasi_UiDetailPortofolio } from "@/app_modules/investasi/_ui";
|
||||||
|
|
||||||
export default async function Page({ params }: { params: { id: string } }) {
|
export default async function Page() {
|
||||||
const investasiId = params.id;
|
|
||||||
const userLoginId = await funGetUserIdByToken();
|
|
||||||
|
|
||||||
const dataPortofolio = await investasi_funGetOneInvestasiById({
|
|
||||||
investasiId,
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Investasi_UiDetailPortofolio
|
<Investasi_UiDetailPortofolio />
|
||||||
dataInvestasi={dataPortofolio as any}
|
|
||||||
userLoginId={userLoginId as string}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,9 @@
|
|||||||
import {
|
|
||||||
investasi_funGetAllDocumentById
|
|
||||||
} from "@/app_modules/investasi/_fun";
|
|
||||||
import { Investasi_UiDaftarDokmen } from "@/app_modules/investasi/_ui";
|
import { Investasi_UiDaftarDokmen } from "@/app_modules/investasi/_ui";
|
||||||
|
|
||||||
export default async function Page({ params }: { params: { id: string } }) {
|
export default async function Page() {
|
||||||
const investasiId = params.id;
|
|
||||||
const dataDokumen = await investasi_funGetAllDocumentById({
|
|
||||||
investasiId: investasiId,
|
|
||||||
page: 1,
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Investasi_UiDaftarDokmen
|
<Investasi_UiDaftarDokmen />
|
||||||
dataDokumen={dataDokumen}
|
|
||||||
investasiId={investasiId}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,9 @@
|
|||||||
import { investasi_funGetAllDocumentById } from "@/app_modules/investasi/_fun";
|
|
||||||
import { Investasi_UiRekapDokumen } from "@/app_modules/investasi/_ui";
|
import { Investasi_UiRekapDokumen } from "@/app_modules/investasi/_ui";
|
||||||
|
|
||||||
export default async function Page({ params }: { params: { id: string } }) {
|
export default async function Page() {
|
||||||
const investasiId = params.id;
|
|
||||||
const dataDokumen = await investasi_funGetAllDocumentById({
|
|
||||||
investasiId,
|
|
||||||
page: 1,
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Investasi_UiRekapDokumen
|
<Investasi_UiRekapDokumen />
|
||||||
investasiId={investasiId}
|
|
||||||
dataDokumen={dataDokumen}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
import { investasi_funGetOneDocumentById } from "@/app_modules/investasi/_fun";
|
|
||||||
import { Investasi_UiEditDokumen } from "@/app_modules/investasi/_ui";
|
import { Investasi_UiEditDokumen } from "@/app_modules/investasi/_ui";
|
||||||
|
|
||||||
export default async function Page({ params }: { params: { id: string } }) {
|
export default async function Page() {
|
||||||
const documentId = params.id;
|
|
||||||
const dataDokumen = await investasi_funGetOneDocumentById({ documentId });
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Investasi_UiEditDokumen dataDokumen={dataDokumen} />
|
<Investasi_UiEditDokumen/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
import { LayoutEditDokumenInvestasi } from "@/app_modules/investasi";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
export default async function Layout({children, params}: {children: React.ReactNode, params: {id: string}}) {
|
|
||||||
return<>
|
|
||||||
<LayoutEditDokumenInvestasi idInves={params.id}>{children}</LayoutEditDokumenInvestasi>
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import { EditDokumenInvestasi } from "@/app_modules/investasi";
|
|
||||||
import getOneInvestasiById from "@/app_modules/investasi/fun/get_one_investasi_by_id";
|
|
||||||
|
|
||||||
export default async function Page({params}: {params: {id: string}}) {
|
|
||||||
const dataInvestasi = await getOneInvestasiById(params.id)
|
|
||||||
// console.log(dataInvestasi)
|
|
||||||
return<>
|
|
||||||
<EditDokumenInvestasi dataInvestasi={dataInvestasi as any} />
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { useDisclosure } from "@mantine/hooks";
|
||||||
import { PrismaClient } from "@prisma/client";
|
import { PrismaClient } from "@prisma/client";
|
||||||
|
|
||||||
// Singleton PrismaClient untuk pengembangan
|
// Singleton PrismaClient untuk pengembangan
|
||||||
@@ -20,8 +21,9 @@ if (process.env.NODE_ENV !== "production") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
process.on("SIGINT", async () => {
|
process.on("SIGINT", async () => {
|
||||||
// console.log("Disconnecting PrismaClient...");
|
console.log("Start in Disconnecting PrismaClient...");
|
||||||
await prisma.$disconnect();
|
const disconnect = await prisma.$disconnect();
|
||||||
|
console.log("End of Disconnecting PrismaClient...", disconnect);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
Text,
|
Text,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { IconDots, IconEdit, IconTrash } from "@tabler/icons-react";
|
import { IconDots, IconEdit, IconTrash } from "@tabler/icons-react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useParams, useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface";
|
import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface";
|
||||||
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
|
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
|
||||||
@@ -30,6 +30,8 @@ import {
|
|||||||
ComponentGlobal_NotifikasiBerhasil,
|
ComponentGlobal_NotifikasiBerhasil,
|
||||||
ComponentGlobal_NotifikasiPeringatan,
|
ComponentGlobal_NotifikasiPeringatan,
|
||||||
} from "@/app_modules/_global/notif_global";
|
} from "@/app_modules/_global/notif_global";
|
||||||
|
import { apiGetDokumenInvestasiById } from "../../_lib/api_interface";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
|
|
||||||
export function Investasi_ComponentCardRekapDocument({
|
export function Investasi_ComponentCardRekapDocument({
|
||||||
data,
|
data,
|
||||||
@@ -38,6 +40,9 @@ export function Investasi_ComponentCardRekapDocument({
|
|||||||
data: MODEL_INVESTASI_DOKUMEN;
|
data: MODEL_INVESTASI_DOKUMEN;
|
||||||
onSetData: (val: any) => any[];
|
onSetData: (val: any) => any[];
|
||||||
}) {
|
}) {
|
||||||
|
const params = useParams<{ id: string }>();
|
||||||
|
const investasiId = params.id;
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [openDrawer, setOpenDrawer] = useState(false);
|
const [openDrawer, setOpenDrawer] = useState(false);
|
||||||
const [isLoadingEdit, setIsLoadingEdit] = useState(false);
|
const [isLoadingEdit, setIsLoadingEdit] = useState(false);
|
||||||
@@ -63,18 +68,22 @@ export function Investasi_ComponentCardRekapDocument({
|
|||||||
|
|
||||||
if (deleteFromDB.status !== 200) {
|
if (deleteFromDB.status !== 200) {
|
||||||
ComponentGlobal_NotifikasiPeringatan(deleteFromDB.message);
|
ComponentGlobal_NotifikasiPeringatan(deleteFromDB.message);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
ComponentGlobal_NotifikasiBerhasil(deleteFromDB.message);
|
ComponentGlobal_NotifikasiBerhasil(deleteFromDB.message);
|
||||||
setOpenModal(false);
|
setOpenModal(false);
|
||||||
|
|
||||||
const loadData = await investasi_funGetAllDocumentById({
|
const respone = await apiGetDokumenInvestasiById({
|
||||||
investasiId: data.investasiId,
|
id: investasiId,
|
||||||
page: 1,
|
kategori: "get-all",
|
||||||
|
page: "1",
|
||||||
});
|
});
|
||||||
|
|
||||||
onSetData(loadData);
|
if (respone.success) {
|
||||||
|
onSetData(respone.data);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
clientLogger.error("Error hapus dokumen", error);
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoadingDelete(false);
|
setIsLoadingDelete(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||||
import { Box, Center, Stack } from "@mantine/core";
|
import { Box, Center, Stack } from "@mantine/core";
|
||||||
|
|
||||||
export { Investasi_SkeletonEditProspektus };
|
export { Investasi_SkeletonEditProspektus, Investasi_SkeletonListDokumen };
|
||||||
|
|
||||||
function Investasi_SkeletonEditProspektus() {
|
function Investasi_SkeletonEditProspektus() {
|
||||||
return (
|
return (
|
||||||
@@ -33,3 +33,14 @@ function Investasi_SkeletonEditProspektus() {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Investasi_SkeletonListDokumen() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Stack>
|
||||||
|
<CustomSkeleton h={70} radius={"md"} />
|
||||||
|
<CustomSkeleton h={70} radius={"md"} />
|
||||||
|
</Stack>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
"use server"
|
"use server";
|
||||||
|
|
||||||
import { prisma } from "@/app/lib"
|
import { prisma } from "@/app/lib";
|
||||||
|
|
||||||
export async function investasi_funGetOneDocumentById({ documentId }: { documentId: string }) {
|
export async function investasi_funGetOneDocumentById({
|
||||||
const data = await prisma.dokumenInvestasi.findFirst({
|
documentId,
|
||||||
where: {
|
}: {
|
||||||
id: documentId
|
documentId: string;
|
||||||
}
|
}) {
|
||||||
})
|
const data = await prisma.dokumenInvestasi.findFirst({
|
||||||
|
where: {
|
||||||
|
id: documentId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
return data
|
return data;
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,18 @@
|
|||||||
|
export const apiGetOneInvestasiById = async ({ id }: { id: string }) => {
|
||||||
|
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||||
|
if (!token) return await token.json().catch(() => null);
|
||||||
|
|
||||||
|
const response = await fetch(`/api/new/investasi/${id}`, {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Accept: "application/json",
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return await response.json().catch(() => null);
|
||||||
|
};
|
||||||
|
|
||||||
export const apiGetMasterInvestasi = async (path?: string) => {
|
export const apiGetMasterInvestasi = async (path?: 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);
|
||||||
@@ -14,21 +29,6 @@ export const apiGetMasterInvestasi = async (path?: string) => {
|
|||||||
return await response.json().catch(() => null);
|
return await response.json().catch(() => null);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const apiGetOneInvestasiById = async (path: string) => {
|
|
||||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
|
||||||
if (!token) return await token.json().catch(() => null);
|
|
||||||
|
|
||||||
const response = await fetch(`/api/new/investasi/${path}`, {
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
Accept: "application/json",
|
|
||||||
"Access-Control-Allow-Origin": "*",
|
|
||||||
Authorization: `Bearer ${token}`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return await response.json().catch(() => null);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const apiGetAllInvestasi = async (path?: string) => {
|
export const apiGetAllInvestasi = async (path?: 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);
|
||||||
@@ -62,3 +62,29 @@ export const apiGetAllSahamSaya = async (path?: string) => {
|
|||||||
);
|
);
|
||||||
return await response.json().catch(() => null);
|
return await response.json().catch(() => null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const apiGetDokumenInvestasiById = async ({
|
||||||
|
id,
|
||||||
|
kategori,
|
||||||
|
page,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
kategori?: undefined | "get-all";
|
||||||
|
page?: string;
|
||||||
|
}) => {
|
||||||
|
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||||
|
if (!token) return await token.json().catch(() => null);
|
||||||
|
|
||||||
|
const response = await fetch(
|
||||||
|
`/api/new/investasi/dokumen/${id}${kategori ? `?kategori=${kategori}&page=${page}` : ""}`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Accept: "application/json",
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return await response.json().catch(() => null);
|
||||||
|
};
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
import { UIGlobal_LayoutHeaderTamplate, UIGlobal_LayoutTamplate } from "@/app_modules/_global/ui"
|
import { UIGlobal_LayoutHeaderTamplate, UIGlobal_LayoutTamplate } from "@/app_modules/_global/ui"
|
||||||
import { Investasi_ViewCreateDocument } from "../../_view";
|
import { Investasi_ViewCreateDocument } from "../../_view";
|
||||||
|
|
||||||
export function Investasi_UiCreateDocument({ investasiId }: { investasiId : string}) {
|
export function Investasi_UiCreateDocument() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<UIGlobal_LayoutTamplate
|
<UIGlobal_LayoutTamplate
|
||||||
header={<UIGlobal_LayoutHeaderTamplate title="Tambah Dokumen" />}
|
header={<UIGlobal_LayoutHeaderTamplate title="Tambah Dokumen" />}
|
||||||
>
|
>
|
||||||
<Investasi_ViewCreateDocument investasiId={investasiId}/>
|
<Investasi_ViewCreateDocument />
|
||||||
</UIGlobal_LayoutTamplate>
|
</UIGlobal_LayoutTamplate>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,22 +6,13 @@ import {
|
|||||||
} from "@/app_modules/_global/ui";
|
} from "@/app_modules/_global/ui";
|
||||||
import { Investasi_ViewDaftarDokumen } from "../../_view";
|
import { Investasi_ViewDaftarDokumen } from "../../_view";
|
||||||
|
|
||||||
export function Investasi_UiDaftarDokmen({
|
export function Investasi_UiDaftarDokmen() {
|
||||||
dataDokumen,
|
|
||||||
investasiId,
|
|
||||||
}: {
|
|
||||||
dataDokumen: any[];
|
|
||||||
investasiId: string
|
|
||||||
}) {
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<UIGlobal_LayoutTamplate
|
<UIGlobal_LayoutTamplate
|
||||||
header={<UIGlobal_LayoutHeaderTamplate title="Daftar Dokumen" />}
|
header={<UIGlobal_LayoutHeaderTamplate title="Daftar Dokumen" />}
|
||||||
>
|
>
|
||||||
<Investasi_ViewDaftarDokumen
|
<Investasi_ViewDaftarDokumen />
|
||||||
dataDokumen={dataDokumen}
|
|
||||||
investasiId={investasiId}
|
|
||||||
/>
|
|
||||||
</UIGlobal_LayoutTamplate>
|
</UIGlobal_LayoutTamplate>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,63 +1,93 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||||
|
import { MainColor } from "@/app_modules/_global/color";
|
||||||
|
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
|
||||||
import {
|
import {
|
||||||
UIGlobal_Drawer,
|
|
||||||
UIGlobal_DrawerCustom,
|
UIGlobal_DrawerCustom,
|
||||||
UIGlobal_LayoutHeaderTamplate,
|
UIGlobal_LayoutHeaderTamplate,
|
||||||
UIGlobal_LayoutTamplate,
|
UIGlobal_LayoutTamplate,
|
||||||
} from "@/app_modules/_global/ui";
|
} from "@/app_modules/_global/ui";
|
||||||
import { ActionIcon, Box, SimpleGrid, Stack, Text } from "@mantine/core";
|
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
|
import { ActionIcon, SimpleGrid, Stack, Text } from "@mantine/core";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import {
|
import {
|
||||||
IconCategoryPlus,
|
IconCategoryPlus,
|
||||||
IconDotsVertical,
|
IconDotsVertical,
|
||||||
IconEdit,
|
IconEdit,
|
||||||
IconFilePencil,
|
IconFilePencil,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useParams, useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { apiGetOneInvestasiById } from "../../_lib/api_interface";
|
||||||
import { MODEL_INVESTASI } from "../../_lib/interface";
|
import { MODEL_INVESTASI } from "../../_lib/interface";
|
||||||
import {
|
import {
|
||||||
Investasi_ViewDetailDraft,
|
Investasi_ViewDetailDraft,
|
||||||
Investasi_ViewDetailReject,
|
Investasi_ViewDetailReject,
|
||||||
Investasi_ViewDetailReview,
|
Investasi_ViewDetailReview,
|
||||||
} from "../../_view";
|
} from "../../_view";
|
||||||
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
|
|
||||||
import { MainColor } from "@/app_modules/_global/color";
|
|
||||||
|
|
||||||
export function Investasi_UiDetailPortofolio({
|
export function Investasi_UiDetailPortofolio() {
|
||||||
dataInvestasi,
|
const params = useParams<{ id: string }>();
|
||||||
userLoginId,
|
const investasiId = params.id;
|
||||||
}: {
|
|
||||||
dataInvestasi: MODEL_INVESTASI;
|
|
||||||
userLoginId: string;
|
|
||||||
}) {
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isLoading, setLoading] = useState(false);
|
const [isLoading, setLoading] = useState(false);
|
||||||
const [pageId, setPageId] = useState("");
|
const [pageId, setPageId] = useState("");
|
||||||
const [openDrawer, setOpenDrawer] = useState(false);
|
const [openDrawer, setOpenDrawer] = useState(false);
|
||||||
const [data, setData] = useState<any>(dataInvestasi);
|
const [data, setData] = useState<MODEL_INVESTASI | null>(null);
|
||||||
const listPage = [
|
const listPage = [
|
||||||
{
|
{
|
||||||
id: "1",
|
id: "1",
|
||||||
name: "Edit Investasi",
|
name: "Edit Investasi",
|
||||||
icon: <IconEdit />,
|
icon: <IconEdit />,
|
||||||
path: NEW_RouterInvestasi.edit_investasi({ id: data.id }),
|
path: NEW_RouterInvestasi.edit_investasi({ id: investasiId }),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "2",
|
id: "2",
|
||||||
name: "Edit Prospektus",
|
name: "Edit Prospektus",
|
||||||
icon: <IconFilePencil />,
|
icon: <IconFilePencil />,
|
||||||
path: NEW_RouterInvestasi.edit_prospektus({ id: data.id }),
|
path: NEW_RouterInvestasi.edit_prospektus({ id: investasiId }),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "3",
|
id: "3",
|
||||||
name: "Tambah & Edit Dokumen",
|
name: "Tambah & Edit Dokumen",
|
||||||
icon: <IconCategoryPlus />,
|
icon: <IconCategoryPlus />,
|
||||||
path: NEW_RouterInvestasi.rekap_dokumen({ id: data.id }),
|
path: NEW_RouterInvestasi.rekap_dokumen({ id: investasiId }),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function onLoadData() {
|
||||||
|
try {
|
||||||
|
const respone = await apiGetOneInvestasiById({
|
||||||
|
id: investasiId,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (respone.success) {
|
||||||
|
setData(respone.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
clientLogger.error("Error get detail investasi:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data === null) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<UIGlobal_LayoutTamplate
|
||||||
|
header={<UIGlobal_LayoutHeaderTamplate title={`Detail`} />}
|
||||||
|
>
|
||||||
|
<CustomSkeleton height={"80vh"} />
|
||||||
|
</UIGlobal_LayoutTamplate>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (data.masterStatusInvestasiId == "3")
|
if (data.masterStatusInvestasiId == "3")
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -76,15 +106,9 @@ export function Investasi_UiDetailPortofolio({
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Investasi_ViewDetailDraft dataInvestasi={dataInvestasi} />
|
<Investasi_ViewDetailDraft dataInvestasi={data} />
|
||||||
</UIGlobal_LayoutTamplate>
|
</UIGlobal_LayoutTamplate>
|
||||||
|
|
||||||
{/* <UIGlobal_Drawer
|
|
||||||
opened={openDrawer}
|
|
||||||
close={() => setOpenDrawer(false)}
|
|
||||||
component={listPage}
|
|
||||||
/> */}
|
|
||||||
|
|
||||||
<UIGlobal_DrawerCustom
|
<UIGlobal_DrawerCustom
|
||||||
opened={openDrawer}
|
opened={openDrawer}
|
||||||
close={() => setOpenDrawer(false)}
|
close={() => setOpenDrawer(false)}
|
||||||
@@ -98,9 +122,7 @@ export function Investasi_UiDetailPortofolio({
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
setPageId(e?.id);
|
setPageId(e?.id);
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
if (e.id === "1") {
|
|
||||||
setData({});
|
|
||||||
}
|
|
||||||
router.push(e?.path, { scroll: false });
|
router.push(e?.path, { scroll: false });
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -125,16 +147,16 @@ export function Investasi_UiDetailPortofolio({
|
|||||||
<UIGlobal_LayoutTamplate
|
<UIGlobal_LayoutTamplate
|
||||||
header={
|
header={
|
||||||
<UIGlobal_LayoutHeaderTamplate
|
<UIGlobal_LayoutHeaderTamplate
|
||||||
title={`Detail ${dataInvestasi.MasterStatusInvestasi.name}`}
|
title={`Detail ${data.MasterStatusInvestasi.name}`}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{dataInvestasi.masterStatusInvestasiId === "2" && (
|
{data.masterStatusInvestasiId === "2" && (
|
||||||
<Investasi_ViewDetailReview dataInvestasi={dataInvestasi} />
|
<Investasi_ViewDetailReview dataInvestasi={data} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{dataInvestasi.masterStatusInvestasiId === "4" && (
|
{data.masterStatusInvestasiId === "4" && (
|
||||||
<Investasi_ViewDetailReject dataInvestasi={dataInvestasi} />
|
<Investasi_ViewDetailReject dataInvestasi={data} />
|
||||||
)}
|
)}
|
||||||
</UIGlobal_LayoutTamplate>
|
</UIGlobal_LayoutTamplate>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,16 +10,13 @@ import { ActionIcon } from "@mantine/core";
|
|||||||
import { IconCirclePlus, IconDotsVertical } from "@tabler/icons-react";
|
import { IconCirclePlus, IconDotsVertical } from "@tabler/icons-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Investasi_ViewRekapDokumen } from "../../_view";
|
import { Investasi_ViewRekapDokumen } from "../../_view";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
|
|
||||||
|
export function Investasi_UiRekapDokumen() {
|
||||||
|
const params = useParams<{ id: string }>();
|
||||||
|
const investasiId = params.id;
|
||||||
|
|
||||||
export function Investasi_UiRekapDokumen({
|
|
||||||
investasiId,
|
|
||||||
dataDokumen,
|
|
||||||
}: {
|
|
||||||
investasiId: string;
|
|
||||||
dataDokumen: any[]
|
|
||||||
}) {
|
|
||||||
const [openDrawer, setOpenDrawer] = useState(false);
|
const [openDrawer, setOpenDrawer] = useState(false);
|
||||||
|
|
||||||
const listPage = [
|
const listPage = [
|
||||||
{
|
{
|
||||||
id: "1",
|
id: "1",
|
||||||
@@ -47,8 +44,6 @@ export function Investasi_UiRekapDokumen({
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Investasi_ViewRekapDokumen
|
<Investasi_ViewRekapDokumen
|
||||||
dataDokumen={dataDokumen}
|
|
||||||
investasiId={investasiId}
|
|
||||||
/>
|
/>
|
||||||
</UIGlobal_LayoutTamplate>
|
</UIGlobal_LayoutTamplate>
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ import {
|
|||||||
} from "@/app_modules/_global/ui";
|
} from "@/app_modules/_global/ui";
|
||||||
import { Investasi_ViewEditDokumen } from "../../_view";
|
import { Investasi_ViewEditDokumen } from "../../_view";
|
||||||
|
|
||||||
export function Investasi_UiEditDokumen({ dataDokumen }: { dataDokumen: any }) {
|
export function Investasi_UiEditDokumen() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<UIGlobal_LayoutTamplate
|
<UIGlobal_LayoutTamplate
|
||||||
header={<UIGlobal_LayoutHeaderTamplate title="Edit Dokumen" />}
|
header={<UIGlobal_LayoutHeaderTamplate title="Edit Dokumen" />}
|
||||||
>
|
>
|
||||||
<Investasi_ViewEditDokumen dataDokumen={dataDokumen} />
|
<Investasi_ViewEditDokumen />
|
||||||
</UIGlobal_LayoutTamplate>
|
</UIGlobal_LayoutTamplate>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { UIGlobal_LayoutHeaderTamplate, UIGlobal_LayoutTamplate, } from "@/app_modules/_global/ui";
|
import { UIGlobal_LayoutHeaderTamplate, UIGlobal_LayoutTamplate, } from "@/app_modules/_global/ui";
|
||||||
import { Investasi_ViewEditInvestasiNew } from "../../_view/edit/view_edit_investasi_new";
|
import { Investasi_ViewEditInvestasiNew } from "../../_view/edit/view_edit_investasi_new";
|
||||||
|
|
||||||
|
|||||||
@@ -1,51 +1,53 @@
|
|||||||
|
import { DIRECTORY_ID } from "@/app/lib";
|
||||||
import { MainColor } from "@/app_modules/_global/color";
|
import { MainColor } from "@/app_modules/_global/color";
|
||||||
import {
|
import {
|
||||||
ComponentGlobal_BoxInformation,
|
ComponentGlobal_BoxInformation,
|
||||||
|
ComponentGlobal_ButtonUploadFileImage,
|
||||||
ComponentGlobal_CardStyles,
|
ComponentGlobal_CardStyles,
|
||||||
} from "@/app_modules/_global/component";
|
} from "@/app_modules/_global/component";
|
||||||
import {
|
|
||||||
Stack,
|
|
||||||
Grid,
|
|
||||||
Center,
|
|
||||||
Group,
|
|
||||||
FileButton,
|
|
||||||
Button,
|
|
||||||
Text,
|
|
||||||
TextInput,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { IconCircleCheck, IconCamera } from "@tabler/icons-react";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { investasi_funCreateDocument } from "../../_fun";
|
|
||||||
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
||||||
import { DIRECTORY_ID } from "@/app/lib";
|
|
||||||
import {
|
import {
|
||||||
ComponentGlobal_NotifikasiBerhasil,
|
ComponentGlobal_NotifikasiBerhasil,
|
||||||
ComponentGlobal_NotifikasiPeringatan,
|
ComponentGlobal_NotifikasiPeringatan,
|
||||||
} from "@/app_modules/_global/notif_global";
|
} from "@/app_modules/_global/notif_global";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
|
import {
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
Center,
|
||||||
|
Grid,
|
||||||
|
Stack,
|
||||||
|
Text,
|
||||||
|
TextInput,
|
||||||
|
} from "@mantine/core";
|
||||||
|
import { IconCircleCheck, IconFileTypePdf } from "@tabler/icons-react";
|
||||||
|
import { useParams, useRouter } from "next/navigation";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { investasi_funCreateDocument } from "../../_fun";
|
||||||
|
|
||||||
|
export function Investasi_ViewCreateDocument() {
|
||||||
|
const params = useParams<{ id: string }>();
|
||||||
|
const investasiId = params.id;
|
||||||
|
|
||||||
export function Investasi_ViewCreateDocument({
|
|
||||||
investasiId,
|
|
||||||
}: {
|
|
||||||
investasiId: string;
|
|
||||||
}) {
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [filePdf, setFilePdf] = useState<File | null>(null);
|
const [filePdf, setFilePdf] = useState<File | null>(null);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [title, setTitle] = useState("");
|
const [title, setTitle] = useState("");
|
||||||
|
|
||||||
async function onCreate() {
|
async function onCreate() {
|
||||||
setIsLoading(true);
|
|
||||||
const uploadFileDokumen = await funGlobal_UploadToStorage({
|
|
||||||
file: filePdf as any,
|
|
||||||
dirId: DIRECTORY_ID.investasi_dokumen,
|
|
||||||
});
|
|
||||||
if (!uploadFileDokumen.success) {
|
|
||||||
setIsLoading(false);
|
|
||||||
ComponentGlobal_NotifikasiPeringatan("Gagal upload file pdf");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
const uploadFileDokumen = await funGlobal_UploadToStorage({
|
||||||
|
file: filePdf as any,
|
||||||
|
dirId: DIRECTORY_ID.investasi_dokumen,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!uploadFileDokumen.success) {
|
||||||
|
setIsLoading(false);
|
||||||
|
ComponentGlobal_NotifikasiPeringatan("Gagal upload file pdf");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const create = await investasi_funCreateDocument({
|
const create = await investasi_funCreateDocument({
|
||||||
data: {
|
data: {
|
||||||
investasiId: investasiId,
|
investasiId: investasiId,
|
||||||
@@ -54,15 +56,17 @@ export function Investasi_ViewCreateDocument({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (create.status !== 201)
|
if (create.status !== 201) {
|
||||||
|
setIsLoading(false);
|
||||||
ComponentGlobal_NotifikasiPeringatan(create.message);
|
ComponentGlobal_NotifikasiPeringatan(create.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
router.back();
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(create.message);
|
ComponentGlobal_NotifikasiBerhasil(create.message);
|
||||||
|
router.back();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
|
||||||
} finally {
|
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
clientLogger.error("Error create document", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,6 +77,7 @@ export function Investasi_ViewCreateDocument({
|
|||||||
|
|
||||||
<Stack>
|
<Stack>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
withAsterisk
|
||||||
label="Judul Dokumen"
|
label="Judul Dokumen"
|
||||||
placeholder="Masukan judul dokumen"
|
placeholder="Masukan judul dokumen"
|
||||||
styles={{
|
styles={{
|
||||||
@@ -84,9 +89,9 @@ export function Investasi_ViewCreateDocument({
|
|||||||
/>
|
/>
|
||||||
<ComponentGlobal_CardStyles marginBottom={"0px"}>
|
<ComponentGlobal_CardStyles marginBottom={"0px"}>
|
||||||
{!filePdf ? (
|
{!filePdf ? (
|
||||||
<Text lineClamp={1} align="center" c={"gray"}>
|
<Stack justify="center" align="center" h={"100%"}>
|
||||||
Upload Dokumen
|
<IconFileTypePdf size={40} color="gray" />
|
||||||
</Text>
|
</Stack>
|
||||||
) : (
|
) : (
|
||||||
<Grid align="center">
|
<Grid align="center">
|
||||||
<Grid.Col span={2}></Grid.Col>
|
<Grid.Col span={2}></Grid.Col>
|
||||||
@@ -104,55 +109,43 @@ export function Investasi_ViewCreateDocument({
|
|||||||
)}
|
)}
|
||||||
</ComponentGlobal_CardStyles>
|
</ComponentGlobal_CardStyles>
|
||||||
|
|
||||||
<Group position="center">
|
<Center>
|
||||||
<FileButton
|
<ComponentGlobal_ButtonUploadFileImage
|
||||||
accept={"application/pdf"}
|
onSetFile={setFilePdf}
|
||||||
onChange={async (files: any) => {
|
accept="application/pdf"
|
||||||
try {
|
text="Upload Dokumen"
|
||||||
const buffer = URL.createObjectURL(
|
/>
|
||||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
</Center>
|
||||||
);
|
|
||||||
|
|
||||||
setFilePdf(files);
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{(props) => (
|
|
||||||
<Button
|
|
||||||
leftIcon={<IconCamera />}
|
|
||||||
{...props}
|
|
||||||
radius={"xl"}
|
|
||||||
bg={MainColor.yellow}
|
|
||||||
color="yellow"
|
|
||||||
c={"black"}
|
|
||||||
>
|
|
||||||
Upload Dokumen
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</FileButton>
|
|
||||||
</Group>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Button
|
<Box
|
||||||
loaderPosition="center"
|
|
||||||
loading={isLoading}
|
|
||||||
disabled={filePdf === null || title === ""}
|
|
||||||
mt={50}
|
|
||||||
radius={50}
|
|
||||||
bg={MainColor.yellow}
|
|
||||||
color="yellow"
|
|
||||||
c={"black"}
|
|
||||||
style={{
|
style={{
|
||||||
transition: "0.5s",
|
display: "flex",
|
||||||
}}
|
justifyContent: "center",
|
||||||
onClick={() => {
|
|
||||||
onCreate();
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Simpan
|
<Button
|
||||||
</Button>
|
loaderPosition="center"
|
||||||
|
loading={isLoading}
|
||||||
|
disabled={filePdf === null || title === ""}
|
||||||
|
mt={50}
|
||||||
|
radius={50}
|
||||||
|
bg={MainColor.yellow}
|
||||||
|
color="yellow"
|
||||||
|
c={"black"}
|
||||||
|
style={{
|
||||||
|
transition: "0.5s",
|
||||||
|
position: "absolute",
|
||||||
|
bottom: 20,
|
||||||
|
width: "90%",
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
onCreate();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Simpan
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,17 +7,43 @@ import { useState } from "react";
|
|||||||
import { Investasi_ComponentCardDaftarDocument } from "../../_component";
|
import { Investasi_ComponentCardDaftarDocument } from "../../_component";
|
||||||
import { investasi_funGetAllDocumentById } from "../../_fun";
|
import { investasi_funGetAllDocumentById } from "../../_fun";
|
||||||
import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface";
|
import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
|
import { Investasi_SkeletonListDokumen } from "../../_component/skeleton_view";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
|
import { apiGetDokumenInvestasiById } from "../../_lib/api_interface";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
|
||||||
export function Investasi_ViewDaftarDokumen({
|
export function Investasi_ViewDaftarDokumen() {
|
||||||
dataDokumen,
|
const params = useParams<{ id: string }>();
|
||||||
investasiId,
|
const investasiId = params.id;
|
||||||
}: {
|
|
||||||
dataDokumen: any[];
|
const [data, setData] = useState<MODEL_INVESTASI_DOKUMEN[] | null>(null);
|
||||||
investasiId: string;
|
|
||||||
}) {
|
|
||||||
const [data, setData] = useState<MODEL_INVESTASI_DOKUMEN[]>(dataDokumen);
|
|
||||||
const [activePage, setActivePage] = useState(1);
|
const [activePage, setActivePage] = useState(1);
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function onLoadData() {
|
||||||
|
try {
|
||||||
|
const respone = await apiGetDokumenInvestasiById({
|
||||||
|
id: investasiId,
|
||||||
|
kategori: "get-all",
|
||||||
|
page: `${activePage}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (respone.success) {
|
||||||
|
setData(respone.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
clientLogger.error("Error get data dokumen", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data === null) {
|
||||||
|
return <Investasi_SkeletonListDokumen />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack>
|
<Stack>
|
||||||
@@ -34,16 +60,23 @@ export function Investasi_ViewDaftarDokumen({
|
|||||||
</Center>
|
</Center>
|
||||||
)}
|
)}
|
||||||
data={data}
|
data={data}
|
||||||
setData={setData}
|
setData={setData as any}
|
||||||
moreData={async () => {
|
moreData={async () => {
|
||||||
const loadData = await investasi_funGetAllDocumentById({
|
try {
|
||||||
investasiId: investasiId,
|
const respone = await apiGetDokumenInvestasiById({
|
||||||
page: activePage + 1,
|
id: investasiId,
|
||||||
});
|
kategori: "get-all",
|
||||||
|
page: `${activePage + 1}`,
|
||||||
|
});
|
||||||
|
|
||||||
setActivePage((val) => val + 1);
|
if (respone.success) {
|
||||||
|
setActivePage((val) => val + 1);
|
||||||
|
|
||||||
return loadData;
|
return respone.data;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
clientLogger.error("Error load data dokumen:", error);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{(item) => (
|
{(item) => (
|
||||||
|
|||||||
@@ -8,17 +8,41 @@ import { Investasi_ComponentCardRekapDocument } from "../../_component";
|
|||||||
import { investasi_funGetAllDocumentById } from "../../_fun";
|
import { investasi_funGetAllDocumentById } from "../../_fun";
|
||||||
import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface";
|
import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
|
import { apiGetDokumenInvestasiById } from "../../_lib/api_interface";
|
||||||
|
import { Investasi_SkeletonListDokumen } from "../../_component/skeleton_view";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
|
|
||||||
export function Investasi_ViewRekapDokumen({
|
export function Investasi_ViewRekapDokumen() {
|
||||||
dataDokumen,
|
const params = useParams<{ id: string }>();
|
||||||
investasiId,
|
const investasiId = params.id;
|
||||||
}: {
|
|
||||||
dataDokumen: any[];
|
const [data, setData] = useState<MODEL_INVESTASI_DOKUMEN[] | null>(null);
|
||||||
investasiId: string;
|
|
||||||
}) {
|
|
||||||
const [data, setData] = useState<MODEL_INVESTASI_DOKUMEN[]>(dataDokumen);
|
|
||||||
const [activePage, setActivePage] = useState(1);
|
const [activePage, setActivePage] = useState(1);
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function onLoadData() {
|
||||||
|
try {
|
||||||
|
const respone = await apiGetDokumenInvestasiById({
|
||||||
|
id: investasiId,
|
||||||
|
kategori: "get-all",
|
||||||
|
page: `${activePage}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (respone.success) {
|
||||||
|
setData(respone.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
clientLogger.error("Error get data dokumen", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data === null) {
|
||||||
|
return <Investasi_SkeletonListDokumen />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -34,16 +58,23 @@ export function Investasi_ViewRekapDokumen({
|
|||||||
</Center>
|
</Center>
|
||||||
)}
|
)}
|
||||||
data={data}
|
data={data}
|
||||||
setData={setData}
|
setData={setData as any}
|
||||||
moreData={async () => {
|
moreData={async () => {
|
||||||
const loadData = await investasi_funGetAllDocumentById({
|
try {
|
||||||
investasiId: investasiId,
|
const respone = await apiGetDokumenInvestasiById({
|
||||||
page: activePage + 1,
|
id: investasiId,
|
||||||
});
|
kategori: "get-all",
|
||||||
|
page: `${activePage + 1}`,
|
||||||
|
});
|
||||||
|
|
||||||
setActivePage((val) => val + 1);
|
if (respone.success) {
|
||||||
|
setActivePage((val) => val + 1);
|
||||||
|
|
||||||
return loadData;
|
return respone.data;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
clientLogger.error("Error load data dokumen:", error);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{(item) => (
|
{(item) => (
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { DIRECTORY_ID } from "@/app/lib";
|
import { DIRECTORY_ID } from "@/app/lib";
|
||||||
import { MainColor } from "@/app_modules/_global/color";
|
import { MainColor } from "@/app_modules/_global/color";
|
||||||
import {
|
import {
|
||||||
ComponentGlobal_CardStyles
|
ComponentGlobal_ButtonUploadFileImage,
|
||||||
|
ComponentGlobal_CardStyles,
|
||||||
} from "@/app_modules/_global/component";
|
} from "@/app_modules/_global/component";
|
||||||
import {
|
import {
|
||||||
funGlobal_DeleteFileById,
|
funGlobal_DeleteFileById,
|
||||||
@@ -11,44 +12,62 @@ import {
|
|||||||
ComponentGlobal_NotifikasiBerhasil,
|
ComponentGlobal_NotifikasiBerhasil,
|
||||||
ComponentGlobal_NotifikasiPeringatan,
|
ComponentGlobal_NotifikasiPeringatan,
|
||||||
} from "@/app_modules/_global/notif_global";
|
} from "@/app_modules/_global/notif_global";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
import {
|
import {
|
||||||
|
Box,
|
||||||
Button,
|
Button,
|
||||||
Center,
|
Center,
|
||||||
FileButton,
|
|
||||||
Grid,
|
Grid,
|
||||||
Group,
|
|
||||||
Stack,
|
Stack,
|
||||||
Text,
|
Text,
|
||||||
TextInput,
|
TextInput,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { IconCamera, IconCircleCheck } from "@tabler/icons-react";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
import { IconCircleCheck } from "@tabler/icons-react";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { useRouter } from "next/navigation";
|
import { useParams, useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { Investasi_SkeletonEditProspektus } from "../../_component/skeleton_view";
|
||||||
import { investasi_funUpdateDocument } from "../../_fun";
|
import { investasi_funUpdateDocument } from "../../_fun";
|
||||||
|
import { apiGetDokumenInvestasiById } from "../../_lib/api_interface";
|
||||||
import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface";
|
import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface";
|
||||||
|
|
||||||
export function Investasi_ViewEditDokumen({
|
export function Investasi_ViewEditDokumen() {
|
||||||
dataDokumen,
|
const params = useParams<{ id: string }>();
|
||||||
}: {
|
const dokumenId = params.id;
|
||||||
dataDokumen: MODEL_INVESTASI_DOKUMEN;
|
|
||||||
}) {
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [filePdf, setFilePdf] = useState<File | null>(null);
|
const [filePdf, setFilePdf] = useState<File | null>(null);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [data, setData] = useState(dataDokumen);
|
const [data, setData] = useState<MODEL_INVESTASI_DOKUMEN | null>(null);
|
||||||
const [title, setTitle] = useState(data.title);
|
// const [title, setTitle] = useState(data.title);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
onGetDataDokumenById();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function onGetDataDokumenById() {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const response = await apiGetDokumenInvestasiById({
|
||||||
|
id: dokumenId,
|
||||||
|
});
|
||||||
|
if (response.success) {
|
||||||
|
console.log(response.data);
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function onUpdate() {
|
async function onUpdate() {
|
||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
if (filePdf) {
|
if (filePdf) {
|
||||||
const delfile = await funGlobal_DeleteFileById({ fileId: data.fileId });
|
|
||||||
|
|
||||||
if (!delfile.success) {
|
|
||||||
ComponentGlobal_NotifikasiPeringatan("Gagal hapus file lama");
|
|
||||||
}
|
|
||||||
|
|
||||||
const uploadFile = await funGlobal_UploadToStorage({
|
const uploadFile = await funGlobal_UploadToStorage({
|
||||||
file: filePdf,
|
file: filePdf,
|
||||||
dirId: DIRECTORY_ID.investasi_dokumen,
|
dirId: DIRECTORY_ID.investasi_dokumen,
|
||||||
@@ -57,35 +76,52 @@ export function Investasi_ViewEditDokumen({
|
|||||||
if (!uploadFile.success) {
|
if (!uploadFile.success) {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
ComponentGlobal_NotifikasiPeringatan("Gagal upload file dokumen");
|
ComponentGlobal_NotifikasiPeringatan("Gagal upload file dokumen");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const delfile = await funGlobal_DeleteFileById({
|
||||||
|
fileId: data?.fileId as any,
|
||||||
|
dirId: DIRECTORY_ID.investasi_dokumen,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!delfile.success) {
|
||||||
|
setIsLoading(false);
|
||||||
|
clientLogger.error("Gagal hapus file lama", delfile.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateWithFile = await investasi_funUpdateDocument({
|
const updateWithFile = await investasi_funUpdateDocument({
|
||||||
data: data,
|
data: data as any,
|
||||||
fileId: uploadFile.data.id,
|
fileId: uploadFile.data.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (updateWithFile.status !== 200) {
|
if (updateWithFile.status !== 200) {
|
||||||
|
setIsLoading(false);
|
||||||
ComponentGlobal_NotifikasiPeringatan(updateWithFile.message);
|
ComponentGlobal_NotifikasiPeringatan(updateWithFile.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(updateWithFile.message);
|
ComponentGlobal_NotifikasiBerhasil(updateWithFile.message);
|
||||||
|
router.back();
|
||||||
} else {
|
} else {
|
||||||
const updateNoFile = await investasi_funUpdateDocument({
|
const updateNoFile = await investasi_funUpdateDocument({
|
||||||
data: data,
|
data: data as any,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (updateNoFile.status !== 200) {
|
if (updateNoFile.status !== 200) {
|
||||||
|
setIsLoading(false);
|
||||||
ComponentGlobal_NotifikasiPeringatan(updateNoFile.message);
|
ComponentGlobal_NotifikasiPeringatan(updateNoFile.message);
|
||||||
}
|
}
|
||||||
ComponentGlobal_NotifikasiBerhasil(updateNoFile.message);
|
ComponentGlobal_NotifikasiBerhasil(updateNoFile.message);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
|
||||||
} finally {
|
|
||||||
router.back();
|
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
clientLogger.error(" Error update dokumen", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return <Investasi_SkeletonEditProspektus />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack spacing={"xl"} px={"sm"}>
|
<Stack spacing={"xl"} px={"sm"}>
|
||||||
@@ -95,18 +131,23 @@ export function Investasi_ViewEditDokumen({
|
|||||||
<TextInput
|
<TextInput
|
||||||
label="Judul Dokumen"
|
label="Judul Dokumen"
|
||||||
placeholder="Masukan judul dokumen"
|
placeholder="Masukan judul dokumen"
|
||||||
value={data.title}
|
value={data?.title}
|
||||||
styles={{
|
styles={{
|
||||||
label: {
|
label: {
|
||||||
color: "white",
|
color: "white",
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
onChange={(val) => setData({ ...data, title: val.target.value })}
|
onChange={(val) =>
|
||||||
|
setData({
|
||||||
|
...(data as any),
|
||||||
|
title: val.target.value,
|
||||||
|
})
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<ComponentGlobal_CardStyles marginBottom={"0px"}>
|
<ComponentGlobal_CardStyles marginBottom={"0px"}>
|
||||||
{!filePdf ? (
|
{!filePdf ? (
|
||||||
<Text lineClamp={1} align="center" c={"gray"}>
|
<Text lineClamp={1} align="center" c={"gray"}>
|
||||||
Dokumen {_.startCase(title)}.pdf
|
{_.startCase(data?.title)}.pdf
|
||||||
</Text>
|
</Text>
|
||||||
) : (
|
) : (
|
||||||
<Grid align="center">
|
<Grid align="center">
|
||||||
@@ -125,7 +166,15 @@ export function Investasi_ViewEditDokumen({
|
|||||||
)}
|
)}
|
||||||
</ComponentGlobal_CardStyles>
|
</ComponentGlobal_CardStyles>
|
||||||
|
|
||||||
<Group position="center">
|
<Center>
|
||||||
|
<ComponentGlobal_ButtonUploadFileImage
|
||||||
|
onSetFile={setFilePdf}
|
||||||
|
accept="application/pdf"
|
||||||
|
text="Upload dokumen"
|
||||||
|
/>
|
||||||
|
</Center>
|
||||||
|
|
||||||
|
{/* <Group position="center">
|
||||||
<FileButton
|
<FileButton
|
||||||
accept={"application/pdf"}
|
accept={"application/pdf"}
|
||||||
onChange={async (files: any) => {
|
onChange={async (files: any) => {
|
||||||
@@ -153,27 +202,37 @@ export function Investasi_ViewEditDokumen({
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</FileButton>
|
</FileButton>
|
||||||
</Group>
|
</Group> */}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Button
|
<Box
|
||||||
loaderPosition="center"
|
|
||||||
loading={isLoading}
|
|
||||||
disabled={data.title === ""}
|
|
||||||
mt={50}
|
|
||||||
radius={50}
|
|
||||||
bg={MainColor.yellow}
|
|
||||||
color="yellow"
|
|
||||||
c={"black"}
|
|
||||||
style={{
|
style={{
|
||||||
transition: "0.5s",
|
display: "flex",
|
||||||
}}
|
justifyContent: "center",
|
||||||
onClick={() => {
|
|
||||||
onUpdate();
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Update
|
<Button
|
||||||
</Button>
|
loaderPosition="center"
|
||||||
|
loading={isLoading}
|
||||||
|
disabled={data?.title === ""}
|
||||||
|
mt={50}
|
||||||
|
radius={50}
|
||||||
|
bg={MainColor.yellow}
|
||||||
|
color="yellow"
|
||||||
|
c={"black"}
|
||||||
|
style={{
|
||||||
|
transition: "0.5s",
|
||||||
|
position: "absolute",
|
||||||
|
bottom: 20,
|
||||||
|
width: "90%",
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
onUpdate();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Update
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -52,7 +52,10 @@ export function Investasi_ViewEditInvestasiNew() {
|
|||||||
async function onGetOneInvestasiById() {
|
async function onGetOneInvestasiById() {
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const response = await apiGetOneInvestasiById(param.id);
|
const response = await apiGetOneInvestasiById({
|
||||||
|
id: param.id,
|
||||||
|
|
||||||
|
});
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setData(response.data);
|
setData(response.data);
|
||||||
setTotalLembar(response.data.totalLembar);
|
setTotalLembar(response.data.totalLembar);
|
||||||
|
|||||||
@@ -48,7 +48,9 @@ export function Investasi_ViewEditProspektus() {
|
|||||||
|
|
||||||
async function onLoadData() {
|
async function onLoadData() {
|
||||||
try {
|
try {
|
||||||
const respone = await apiGetOneInvestasiById(investasiId);
|
const respone = await apiGetOneInvestasiById({
|
||||||
|
id: investasiId,
|
||||||
|
});
|
||||||
if (respone.success) {
|
if (respone.success) {
|
||||||
setFileRemoveId(respone.data.prospektusFileId);
|
setFileRemoveId(respone.data.prospektusFileId);
|
||||||
}
|
}
|
||||||
@@ -111,7 +113,7 @@ export function Investasi_ViewEditProspektus() {
|
|||||||
<ComponentGlobal_CardStyles marginBottom={"0px"}>
|
<ComponentGlobal_CardStyles marginBottom={"0px"}>
|
||||||
{!filePdf ? (
|
{!filePdf ? (
|
||||||
<Stack justify="center" align="center" h={"100%"}>
|
<Stack justify="center" align="center" h={"100%"}>
|
||||||
<IconFileTypePdf size={50} color="gray" />
|
<IconFileTypePdf size={40} color="gray" />
|
||||||
</Stack>
|
</Stack>
|
||||||
) : (
|
) : (
|
||||||
<Grid align="center">
|
<Grid align="center">
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { RouterInvestasi_OLD } from "@/app/lib/router_hipmi/router_investasi";
|
|
||||||
import UIGlobal_Drawer from "@/app_modules/_global/ui/ui_drawer";
|
|
||||||
import UIGlobal_LayoutHeaderTamplate from "@/app_modules/_global/ui/ui_header_tamplate";
|
|
||||||
import UIGlobal_LayoutTamplate from "@/app_modules/_global/ui/ui_layout_tamplate";
|
|
||||||
import { ActionIcon } from "@mantine/core";
|
|
||||||
import { IconDotsVertical, IconFilePlus } from "@tabler/icons-react";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
export default function LayoutEditDokumenInvestasi({
|
|
||||||
children,
|
|
||||||
idInves,
|
|
||||||
}: {
|
|
||||||
children: React.ReactNode;
|
|
||||||
idInves: string;
|
|
||||||
}) {
|
|
||||||
const router = useRouter();
|
|
||||||
const [isOpenDrawer, setIsOpenDrawer] = React.useState(false);
|
|
||||||
|
|
||||||
const listPage = [
|
|
||||||
{
|
|
||||||
id: "1",
|
|
||||||
name: "Tambah Dokumen",
|
|
||||||
icon: <IconFilePlus />,
|
|
||||||
path: RouterInvestasi_OLD.upload_dokumen + `${idInves}`,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<UIGlobal_LayoutTamplate
|
|
||||||
header={
|
|
||||||
<UIGlobal_LayoutHeaderTamplate
|
|
||||||
title="Daftar Dokumen"
|
|
||||||
// iconRight={<IconEdit />}
|
|
||||||
// routerRight={RouterInvestasi.upload_dokumen + `${idInves}`}
|
|
||||||
customButtonRight={
|
|
||||||
<ActionIcon
|
|
||||||
variant="transparent"
|
|
||||||
onClick={() => setIsOpenDrawer(true)}
|
|
||||||
>
|
|
||||||
<IconDotsVertical color="white" />
|
|
||||||
</ActionIcon>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</UIGlobal_LayoutTamplate>
|
|
||||||
|
|
||||||
<UIGlobal_Drawer
|
|
||||||
opened={isOpenDrawer}
|
|
||||||
close={() => setIsOpenDrawer(false)}
|
|
||||||
component={listPage}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import {
|
|
||||||
AccentColor,
|
|
||||||
MainColor,
|
|
||||||
} from "@/app_modules/_global/color/color_pallet";
|
|
||||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
|
||||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
|
||||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
|
||||||
import { ActionIcon, Group, Paper, Text } from "@mantine/core";
|
|
||||||
import { IconFolderOpen, IconTrash, IconWorldShare } from "@tabler/icons-react";
|
|
||||||
import _ from "lodash";
|
|
||||||
import Link from "next/link";
|
|
||||||
import { useState } from "react";
|
|
||||||
import funDeleteDokumenInvestasi from "../fun/fun_delete_dokumen";
|
|
||||||
import funLoadDataInvestasi from "../fun/fun_load_data";
|
|
||||||
import { MODEL_INVESTASI } from "../_lib/interface";
|
|
||||||
import { IconFile } from "@tabler/icons-react";
|
|
||||||
import { IconFileTypePdf } from "@tabler/icons-react";
|
|
||||||
|
|
||||||
export default function EditDokumenInvestasi({
|
|
||||||
dataInvestasi,
|
|
||||||
}: {
|
|
||||||
dataInvestasi: MODEL_INVESTASI;
|
|
||||||
}) {
|
|
||||||
const [dokumen, setDokumen] = useState(dataInvestasi);
|
|
||||||
|
|
||||||
async function onDelete(id: string) {
|
|
||||||
await funDeleteDokumenInvestasi(id).then(async (res) => {
|
|
||||||
if (res.status === 200) {
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
|
||||||
|
|
||||||
const load = await funLoadDataInvestasi(dokumen.id);
|
|
||||||
setDokumen(load as any);
|
|
||||||
} else {
|
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{!_.isEmpty(dokumen.DokumenInvestasi) ? (
|
|
||||||
dokumen.DokumenInvestasi.map((e) => (
|
|
||||||
<Paper
|
|
||||||
key={e.id}
|
|
||||||
style={{
|
|
||||||
padding: "15px",
|
|
||||||
backgroundColor: AccentColor.darkblue,
|
|
||||||
border: `2px solid ${AccentColor.blue}`,
|
|
||||||
borderRadius: "10px",
|
|
||||||
color: "white",
|
|
||||||
marginBottom: "15px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Group position="apart">
|
|
||||||
<Text lineClamp={1}>{e.title}</Text>
|
|
||||||
<Group position="center">
|
|
||||||
<Link href={`/file/${e.url}`} target="_blank">
|
|
||||||
<ActionIcon variant="transparent">
|
|
||||||
<IconFileTypePdf
|
|
||||||
style={{
|
|
||||||
color: MainColor.yellow,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</ActionIcon>
|
|
||||||
</Link>
|
|
||||||
<ActionIcon
|
|
||||||
variant="transparent"
|
|
||||||
onClick={() => {
|
|
||||||
onDelete(e.id);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<IconTrash color="red" />
|
|
||||||
</ActionIcon>
|
|
||||||
</Group>
|
|
||||||
</Group>
|
|
||||||
</Paper>
|
|
||||||
))
|
|
||||||
) : (
|
|
||||||
<ComponentGlobal_IsEmptyData />
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* <Divider mt={"lg"} /> */}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -7,8 +7,6 @@ import PortofolioInvestasi from "./portofolio/view";
|
|||||||
import LayoutPortofolioInvestasi from "./portofolio/layout";
|
import LayoutPortofolioInvestasi from "./portofolio/layout";
|
||||||
import EditIntroInvestasi from "./edit_intro/view";
|
import EditIntroInvestasi from "./edit_intro/view";
|
||||||
import LayoutEditIntroInvestasi from "./edit_intro/layout";
|
import LayoutEditIntroInvestasi from "./edit_intro/layout";
|
||||||
import EditDokumenInvestasi from "./edit_dokumen/view";
|
|
||||||
import LayoutEditDokumenInvestasi from "./edit_dokumen/layout";
|
|
||||||
import EditBeritaInvestasi from "./edit_berita/view";
|
import EditBeritaInvestasi from "./edit_berita/view";
|
||||||
import LayoutEditBeritaInvestasi from "./edit_berita/layout";
|
import LayoutEditBeritaInvestasi from "./edit_berita/layout";
|
||||||
import DetailPropektus from "./detail_prospektus/view";
|
import DetailPropektus from "./detail_prospektus/view";
|
||||||
@@ -56,8 +54,6 @@ export {
|
|||||||
LayoutPortofolioInvestasi,
|
LayoutPortofolioInvestasi,
|
||||||
EditIntroInvestasi,
|
EditIntroInvestasi,
|
||||||
LayoutEditIntroInvestasi,
|
LayoutEditIntroInvestasi,
|
||||||
EditDokumenInvestasi,
|
|
||||||
LayoutEditDokumenInvestasi,
|
|
||||||
EditBeritaInvestasi,
|
EditBeritaInvestasi,
|
||||||
LayoutEditBeritaInvestasi,
|
LayoutEditBeritaInvestasi,
|
||||||
DetailPropektus,
|
DetailPropektus,
|
||||||
|
|||||||
Reference in New Issue
Block a user