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";
|
||||
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,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
targetDana: true,
|
||||
hargaLembar: true,
|
||||
totalLembar: true,
|
||||
roi: true,
|
||||
countDown: true,
|
||||
catatan: true,
|
||||
sisaLembar: true,
|
||||
imageId: true,
|
||||
prospektusFileId: true,
|
||||
masterPencarianInvestorId: true,
|
||||
masterPeriodeDevidenId: true,
|
||||
masterPembagianDevidenId: true,
|
||||
}
|
||||
});
|
||||
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 });
|
||||
}
|
||||
}
|
||||
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 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const investasiId = params.id;
|
||||
|
||||
export default async function Page() {
|
||||
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";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const investasiId = params.id;
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const dataPortofolio = await investasi_funGetOneInvestasiById({
|
||||
investasiId,
|
||||
});
|
||||
|
||||
export default async function Page() {
|
||||
return (
|
||||
<>
|
||||
<Investasi_UiDetailPortofolio
|
||||
dataInvestasi={dataPortofolio as any}
|
||||
userLoginId={userLoginId as string}
|
||||
/>
|
||||
<Investasi_UiDetailPortofolio />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,21 +1,9 @@
|
||||
import {
|
||||
investasi_funGetAllDocumentById
|
||||
} from "@/app_modules/investasi/_fun";
|
||||
import { Investasi_UiDaftarDokmen } from "@/app_modules/investasi/_ui";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const investasiId = params.id;
|
||||
const dataDokumen = await investasi_funGetAllDocumentById({
|
||||
investasiId: investasiId,
|
||||
page: 1,
|
||||
});
|
||||
|
||||
export default async function Page() {
|
||||
return (
|
||||
<>
|
||||
<Investasi_UiDaftarDokmen
|
||||
dataDokumen={dataDokumen}
|
||||
investasiId={investasiId}
|
||||
/>
|
||||
<Investasi_UiDaftarDokmen />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,9 @@
|
||||
import { investasi_funGetAllDocumentById } from "@/app_modules/investasi/_fun";
|
||||
import { Investasi_UiRekapDokumen } from "@/app_modules/investasi/_ui";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const investasiId = params.id;
|
||||
const dataDokumen = await investasi_funGetAllDocumentById({
|
||||
investasiId,
|
||||
page: 1,
|
||||
});
|
||||
|
||||
export default async function Page() {
|
||||
return (
|
||||
<>
|
||||
<Investasi_UiRekapDokumen
|
||||
investasiId={investasiId}
|
||||
dataDokumen={dataDokumen}
|
||||
/>
|
||||
<Investasi_UiRekapDokumen />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
import { investasi_funGetOneDocumentById } from "@/app_modules/investasi/_fun";
|
||||
import { Investasi_UiEditDokumen } from "@/app_modules/investasi/_ui";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const documentId = params.id;
|
||||
const dataDokumen = await investasi_funGetOneDocumentById({ documentId });
|
||||
|
||||
|
||||
export default async function Page() {
|
||||
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";
|
||||
|
||||
// Singleton PrismaClient untuk pengembangan
|
||||
@@ -20,8 +21,9 @@ if (process.env.NODE_ENV !== "production") {
|
||||
}
|
||||
|
||||
process.on("SIGINT", async () => {
|
||||
// console.log("Disconnecting PrismaClient...");
|
||||
await prisma.$disconnect();
|
||||
console.log("Start in Disconnecting PrismaClient...");
|
||||
const disconnect = await prisma.$disconnect();
|
||||
console.log("End of Disconnecting PrismaClient...", disconnect);
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
Text,
|
||||
} from "@mantine/core";
|
||||
import { IconDots, IconEdit, IconTrash } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface";
|
||||
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
|
||||
@@ -30,6 +30,8 @@ import {
|
||||
ComponentGlobal_NotifikasiBerhasil,
|
||||
ComponentGlobal_NotifikasiPeringatan,
|
||||
} from "@/app_modules/_global/notif_global";
|
||||
import { apiGetDokumenInvestasiById } from "../../_lib/api_interface";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
|
||||
export function Investasi_ComponentCardRekapDocument({
|
||||
data,
|
||||
@@ -38,6 +40,9 @@ export function Investasi_ComponentCardRekapDocument({
|
||||
data: MODEL_INVESTASI_DOKUMEN;
|
||||
onSetData: (val: any) => any[];
|
||||
}) {
|
||||
const params = useParams<{ id: string }>();
|
||||
const investasiId = params.id;
|
||||
|
||||
const router = useRouter();
|
||||
const [openDrawer, setOpenDrawer] = useState(false);
|
||||
const [isLoadingEdit, setIsLoadingEdit] = useState(false);
|
||||
@@ -63,18 +68,22 @@ export function Investasi_ComponentCardRekapDocument({
|
||||
|
||||
if (deleteFromDB.status !== 200) {
|
||||
ComponentGlobal_NotifikasiPeringatan(deleteFromDB.message);
|
||||
return;
|
||||
}
|
||||
ComponentGlobal_NotifikasiBerhasil(deleteFromDB.message);
|
||||
setOpenModal(false);
|
||||
|
||||
const loadData = await investasi_funGetAllDocumentById({
|
||||
investasiId: data.investasiId,
|
||||
page: 1,
|
||||
const respone = await apiGetDokumenInvestasiById({
|
||||
id: investasiId,
|
||||
kategori: "get-all",
|
||||
page: "1",
|
||||
});
|
||||
|
||||
onSetData(loadData);
|
||||
if (respone.success) {
|
||||
onSetData(respone.data);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
clientLogger.error("Error hapus dokumen", error);
|
||||
} finally {
|
||||
setIsLoadingDelete(false);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { Box, Center, Stack } from "@mantine/core";
|
||||
|
||||
export { Investasi_SkeletonEditProspektus };
|
||||
export { Investasi_SkeletonEditProspektus, Investasi_SkeletonListDokumen };
|
||||
|
||||
function Investasi_SkeletonEditProspektus() {
|
||||
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 }) {
|
||||
const data = await prisma.dokumenInvestasi.findFirst({
|
||||
where: {
|
||||
id: documentId
|
||||
}
|
||||
})
|
||||
export async function investasi_funGetOneDocumentById({
|
||||
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) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
@@ -14,21 +29,6 @@ export const apiGetMasterInvestasi = async (path?: string) => {
|
||||
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) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
@@ -62,3 +62,29 @@ export const apiGetAllSahamSaya = async (path?: string) => {
|
||||
);
|
||||
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 { Investasi_ViewCreateDocument } from "../../_view";
|
||||
|
||||
export function Investasi_UiCreateDocument({ investasiId }: { investasiId : string}) {
|
||||
export function Investasi_UiCreateDocument() {
|
||||
return (
|
||||
<>
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={<UIGlobal_LayoutHeaderTamplate title="Tambah Dokumen" />}
|
||||
>
|
||||
<Investasi_ViewCreateDocument investasiId={investasiId}/>
|
||||
<Investasi_ViewCreateDocument />
|
||||
</UIGlobal_LayoutTamplate>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -6,22 +6,13 @@ import {
|
||||
} from "@/app_modules/_global/ui";
|
||||
import { Investasi_ViewDaftarDokumen } from "../../_view";
|
||||
|
||||
export function Investasi_UiDaftarDokmen({
|
||||
dataDokumen,
|
||||
investasiId,
|
||||
}: {
|
||||
dataDokumen: any[];
|
||||
investasiId: string
|
||||
}) {
|
||||
export function Investasi_UiDaftarDokmen() {
|
||||
return (
|
||||
<>
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={<UIGlobal_LayoutHeaderTamplate title="Daftar Dokumen" />}
|
||||
>
|
||||
<Investasi_ViewDaftarDokumen
|
||||
dataDokumen={dataDokumen}
|
||||
investasiId={investasiId}
|
||||
/>
|
||||
<Investasi_ViewDaftarDokumen />
|
||||
</UIGlobal_LayoutTamplate>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,63 +1,93 @@
|
||||
"use client";
|
||||
|
||||
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 {
|
||||
UIGlobal_Drawer,
|
||||
UIGlobal_DrawerCustom,
|
||||
UIGlobal_LayoutHeaderTamplate,
|
||||
UIGlobal_LayoutTamplate,
|
||||
} 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 {
|
||||
IconCategoryPlus,
|
||||
IconDotsVertical,
|
||||
IconEdit,
|
||||
IconFilePencil,
|
||||
} from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { apiGetOneInvestasiById } from "../../_lib/api_interface";
|
||||
import { MODEL_INVESTASI } from "../../_lib/interface";
|
||||
import {
|
||||
Investasi_ViewDetailDraft,
|
||||
Investasi_ViewDetailReject,
|
||||
Investasi_ViewDetailReview,
|
||||
} from "../../_view";
|
||||
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
|
||||
import { MainColor } from "@/app_modules/_global/color";
|
||||
|
||||
export function Investasi_UiDetailPortofolio({
|
||||
dataInvestasi,
|
||||
userLoginId,
|
||||
}: {
|
||||
dataInvestasi: MODEL_INVESTASI;
|
||||
userLoginId: string;
|
||||
}) {
|
||||
export function Investasi_UiDetailPortofolio() {
|
||||
const params = useParams<{ id: string }>();
|
||||
const investasiId = params.id;
|
||||
|
||||
const router = useRouter();
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
const [pageId, setPageId] = useState("");
|
||||
const [openDrawer, setOpenDrawer] = useState(false);
|
||||
const [data, setData] = useState<any>(dataInvestasi);
|
||||
const [data, setData] = useState<MODEL_INVESTASI | null>(null);
|
||||
const listPage = [
|
||||
{
|
||||
id: "1",
|
||||
name: "Edit Investasi",
|
||||
icon: <IconEdit />,
|
||||
path: NEW_RouterInvestasi.edit_investasi({ id: data.id }),
|
||||
path: NEW_RouterInvestasi.edit_investasi({ id: investasiId }),
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
name: "Edit Prospektus",
|
||||
icon: <IconFilePencil />,
|
||||
path: NEW_RouterInvestasi.edit_prospektus({ id: data.id }),
|
||||
path: NEW_RouterInvestasi.edit_prospektus({ id: investasiId }),
|
||||
},
|
||||
{
|
||||
id: "3",
|
||||
name: "Tambah & Edit Dokumen",
|
||||
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")
|
||||
return (
|
||||
<>
|
||||
@@ -76,15 +106,9 @@ export function Investasi_UiDetailPortofolio({
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Investasi_ViewDetailDraft dataInvestasi={dataInvestasi} />
|
||||
<Investasi_ViewDetailDraft dataInvestasi={data} />
|
||||
</UIGlobal_LayoutTamplate>
|
||||
|
||||
{/* <UIGlobal_Drawer
|
||||
opened={openDrawer}
|
||||
close={() => setOpenDrawer(false)}
|
||||
component={listPage}
|
||||
/> */}
|
||||
|
||||
<UIGlobal_DrawerCustom
|
||||
opened={openDrawer}
|
||||
close={() => setOpenDrawer(false)}
|
||||
@@ -98,9 +122,7 @@ export function Investasi_UiDetailPortofolio({
|
||||
onClick={() => {
|
||||
setPageId(e?.id);
|
||||
setLoading(true);
|
||||
if (e.id === "1") {
|
||||
setData({});
|
||||
}
|
||||
|
||||
router.push(e?.path, { scroll: false });
|
||||
}}
|
||||
>
|
||||
@@ -125,16 +147,16 @@ export function Investasi_UiDetailPortofolio({
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={
|
||||
<UIGlobal_LayoutHeaderTamplate
|
||||
title={`Detail ${dataInvestasi.MasterStatusInvestasi.name}`}
|
||||
title={`Detail ${data.MasterStatusInvestasi.name}`}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{dataInvestasi.masterStatusInvestasiId === "2" && (
|
||||
<Investasi_ViewDetailReview dataInvestasi={dataInvestasi} />
|
||||
{data.masterStatusInvestasiId === "2" && (
|
||||
<Investasi_ViewDetailReview dataInvestasi={data} />
|
||||
)}
|
||||
|
||||
{dataInvestasi.masterStatusInvestasiId === "4" && (
|
||||
<Investasi_ViewDetailReject dataInvestasi={dataInvestasi} />
|
||||
{data.masterStatusInvestasiId === "4" && (
|
||||
<Investasi_ViewDetailReject dataInvestasi={data} />
|
||||
)}
|
||||
</UIGlobal_LayoutTamplate>
|
||||
);
|
||||
|
||||
@@ -10,16 +10,13 @@ import { ActionIcon } from "@mantine/core";
|
||||
import { IconCirclePlus, IconDotsVertical } from "@tabler/icons-react";
|
||||
import { useState } from "react";
|
||||
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 listPage = [
|
||||
{
|
||||
id: "1",
|
||||
@@ -47,8 +44,6 @@ export function Investasi_UiRekapDokumen({
|
||||
}
|
||||
>
|
||||
<Investasi_ViewRekapDokumen
|
||||
dataDokumen={dataDokumen}
|
||||
investasiId={investasiId}
|
||||
/>
|
||||
</UIGlobal_LayoutTamplate>
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ import {
|
||||
} from "@/app_modules/_global/ui";
|
||||
import { Investasi_ViewEditDokumen } from "../../_view";
|
||||
|
||||
export function Investasi_UiEditDokumen({ dataDokumen }: { dataDokumen: any }) {
|
||||
export function Investasi_UiEditDokumen() {
|
||||
return (
|
||||
<>
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={<UIGlobal_LayoutHeaderTamplate title="Edit Dokumen" />}
|
||||
>
|
||||
<Investasi_ViewEditDokumen dataDokumen={dataDokumen} />
|
||||
<Investasi_ViewEditDokumen />
|
||||
</UIGlobal_LayoutTamplate>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import { UIGlobal_LayoutHeaderTamplate, UIGlobal_LayoutTamplate, } from "@/app_modules/_global/ui";
|
||||
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 {
|
||||
ComponentGlobal_BoxInformation,
|
||||
ComponentGlobal_ButtonUploadFileImage,
|
||||
ComponentGlobal_CardStyles,
|
||||
} 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 { DIRECTORY_ID } from "@/app/lib";
|
||||
import {
|
||||
ComponentGlobal_NotifikasiBerhasil,
|
||||
ComponentGlobal_NotifikasiPeringatan,
|
||||
} 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 [filePdf, setFilePdf] = useState<File | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [title, setTitle] = useState("");
|
||||
|
||||
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 {
|
||||
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({
|
||||
data: {
|
||||
investasiId: investasiId,
|
||||
@@ -54,15 +56,17 @@ export function Investasi_ViewCreateDocument({
|
||||
},
|
||||
});
|
||||
|
||||
if (create.status !== 201)
|
||||
if (create.status !== 201) {
|
||||
setIsLoading(false);
|
||||
ComponentGlobal_NotifikasiPeringatan(create.message);
|
||||
return;
|
||||
}
|
||||
|
||||
router.back();
|
||||
ComponentGlobal_NotifikasiBerhasil(create.message);
|
||||
router.back();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
clientLogger.error("Error create document", error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +77,7 @@ export function Investasi_ViewCreateDocument({
|
||||
|
||||
<Stack>
|
||||
<TextInput
|
||||
withAsterisk
|
||||
label="Judul Dokumen"
|
||||
placeholder="Masukan judul dokumen"
|
||||
styles={{
|
||||
@@ -84,9 +89,9 @@ export function Investasi_ViewCreateDocument({
|
||||
/>
|
||||
<ComponentGlobal_CardStyles marginBottom={"0px"}>
|
||||
{!filePdf ? (
|
||||
<Text lineClamp={1} align="center" c={"gray"}>
|
||||
Upload Dokumen
|
||||
</Text>
|
||||
<Stack justify="center" align="center" h={"100%"}>
|
||||
<IconFileTypePdf size={40} color="gray" />
|
||||
</Stack>
|
||||
) : (
|
||||
<Grid align="center">
|
||||
<Grid.Col span={2}></Grid.Col>
|
||||
@@ -104,55 +109,43 @@ export function Investasi_ViewCreateDocument({
|
||||
)}
|
||||
</ComponentGlobal_CardStyles>
|
||||
|
||||
<Group position="center">
|
||||
<FileButton
|
||||
accept={"application/pdf"}
|
||||
onChange={async (files: any) => {
|
||||
try {
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
|
||||
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>
|
||||
<Center>
|
||||
<ComponentGlobal_ButtonUploadFileImage
|
||||
onSetFile={setFilePdf}
|
||||
accept="application/pdf"
|
||||
text="Upload Dokumen"
|
||||
/>
|
||||
</Center>
|
||||
</Stack>
|
||||
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoading}
|
||||
disabled={filePdf === null || title === ""}
|
||||
mt={50}
|
||||
radius={50}
|
||||
bg={MainColor.yellow}
|
||||
color="yellow"
|
||||
c={"black"}
|
||||
<Box
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
}}
|
||||
onClick={() => {
|
||||
onCreate();
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
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>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -7,17 +7,43 @@ import { useState } from "react";
|
||||
import { Investasi_ComponentCardDaftarDocument } from "../../_component";
|
||||
import { investasi_funGetAllDocumentById } from "../../_fun";
|
||||
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({
|
||||
dataDokumen,
|
||||
investasiId,
|
||||
}: {
|
||||
dataDokumen: any[];
|
||||
investasiId: string;
|
||||
}) {
|
||||
const [data, setData] = useState<MODEL_INVESTASI_DOKUMEN[]>(dataDokumen);
|
||||
export function Investasi_ViewDaftarDokumen() {
|
||||
const params = useParams<{ id: string }>();
|
||||
const investasiId = params.id;
|
||||
|
||||
const [data, setData] = useState<MODEL_INVESTASI_DOKUMEN[] | null>(null);
|
||||
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 (
|
||||
<>
|
||||
<Stack>
|
||||
@@ -34,16 +60,23 @@ export function Investasi_ViewDaftarDokumen({
|
||||
</Center>
|
||||
)}
|
||||
data={data}
|
||||
setData={setData}
|
||||
setData={setData as any}
|
||||
moreData={async () => {
|
||||
const loadData = await investasi_funGetAllDocumentById({
|
||||
investasiId: investasiId,
|
||||
page: activePage + 1,
|
||||
});
|
||||
try {
|
||||
const respone = await apiGetDokumenInvestasiById({
|
||||
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) => (
|
||||
|
||||
@@ -8,17 +8,41 @@ import { Investasi_ComponentCardRekapDocument } from "../../_component";
|
||||
import { investasi_funGetAllDocumentById } from "../../_fun";
|
||||
import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface";
|
||||
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({
|
||||
dataDokumen,
|
||||
investasiId,
|
||||
}: {
|
||||
dataDokumen: any[];
|
||||
investasiId: string;
|
||||
}) {
|
||||
const [data, setData] = useState<MODEL_INVESTASI_DOKUMEN[]>(dataDokumen);
|
||||
export function Investasi_ViewRekapDokumen() {
|
||||
const params = useParams<{ id: string }>();
|
||||
const investasiId = params.id;
|
||||
|
||||
const [data, setData] = useState<MODEL_INVESTASI_DOKUMEN[] | null>(null);
|
||||
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 (
|
||||
<>
|
||||
@@ -34,16 +58,23 @@ export function Investasi_ViewRekapDokumen({
|
||||
</Center>
|
||||
)}
|
||||
data={data}
|
||||
setData={setData}
|
||||
setData={setData as any}
|
||||
moreData={async () => {
|
||||
const loadData = await investasi_funGetAllDocumentById({
|
||||
investasiId: investasiId,
|
||||
page: activePage + 1,
|
||||
});
|
||||
try {
|
||||
const respone = await apiGetDokumenInvestasiById({
|
||||
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) => (
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { DIRECTORY_ID } from "@/app/lib";
|
||||
import { MainColor } from "@/app_modules/_global/color";
|
||||
import {
|
||||
ComponentGlobal_CardStyles
|
||||
ComponentGlobal_ButtonUploadFileImage,
|
||||
ComponentGlobal_CardStyles,
|
||||
} from "@/app_modules/_global/component";
|
||||
import {
|
||||
funGlobal_DeleteFileById,
|
||||
@@ -11,44 +12,62 @@ import {
|
||||
ComponentGlobal_NotifikasiBerhasil,
|
||||
ComponentGlobal_NotifikasiPeringatan,
|
||||
} from "@/app_modules/_global/notif_global";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
FileButton,
|
||||
Grid,
|
||||
Group,
|
||||
Stack,
|
||||
Text,
|
||||
TextInput,
|
||||
} 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 { useRouter } from "next/navigation";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { Investasi_SkeletonEditProspektus } from "../../_component/skeleton_view";
|
||||
import { investasi_funUpdateDocument } from "../../_fun";
|
||||
import { apiGetDokumenInvestasiById } from "../../_lib/api_interface";
|
||||
import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface";
|
||||
|
||||
export function Investasi_ViewEditDokumen({
|
||||
dataDokumen,
|
||||
}: {
|
||||
dataDokumen: MODEL_INVESTASI_DOKUMEN;
|
||||
}) {
|
||||
export function Investasi_ViewEditDokumen() {
|
||||
const params = useParams<{ id: string }>();
|
||||
const dokumenId = params.id;
|
||||
|
||||
const router = useRouter();
|
||||
const [filePdf, setFilePdf] = useState<File | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [data, setData] = useState(dataDokumen);
|
||||
const [title, setTitle] = useState(data.title);
|
||||
const [data, setData] = useState<MODEL_INVESTASI_DOKUMEN | null>(null);
|
||||
// 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() {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
if (filePdf) {
|
||||
const delfile = await funGlobal_DeleteFileById({ fileId: data.fileId });
|
||||
|
||||
if (!delfile.success) {
|
||||
ComponentGlobal_NotifikasiPeringatan("Gagal hapus file lama");
|
||||
}
|
||||
|
||||
const uploadFile = await funGlobal_UploadToStorage({
|
||||
file: filePdf,
|
||||
dirId: DIRECTORY_ID.investasi_dokumen,
|
||||
@@ -57,35 +76,52 @@ export function Investasi_ViewEditDokumen({
|
||||
if (!uploadFile.success) {
|
||||
setIsLoading(false);
|
||||
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({
|
||||
data: data,
|
||||
data: data as any,
|
||||
fileId: uploadFile.data.id,
|
||||
});
|
||||
|
||||
if (updateWithFile.status !== 200) {
|
||||
setIsLoading(false);
|
||||
ComponentGlobal_NotifikasiPeringatan(updateWithFile.message);
|
||||
}
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(updateWithFile.message);
|
||||
router.back();
|
||||
} else {
|
||||
const updateNoFile = await investasi_funUpdateDocument({
|
||||
data: data,
|
||||
data: data as any,
|
||||
});
|
||||
|
||||
if (updateNoFile.status !== 200) {
|
||||
setIsLoading(false);
|
||||
ComponentGlobal_NotifikasiPeringatan(updateNoFile.message);
|
||||
}
|
||||
ComponentGlobal_NotifikasiBerhasil(updateNoFile.message);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
router.back();
|
||||
setIsLoading(false);
|
||||
clientLogger.error(" Error update dokumen", error);
|
||||
}
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return <Investasi_SkeletonEditProspektus />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xl"} px={"sm"}>
|
||||
@@ -95,18 +131,23 @@ export function Investasi_ViewEditDokumen({
|
||||
<TextInput
|
||||
label="Judul Dokumen"
|
||||
placeholder="Masukan judul dokumen"
|
||||
value={data.title}
|
||||
value={data?.title}
|
||||
styles={{
|
||||
label: {
|
||||
color: "white",
|
||||
},
|
||||
}}
|
||||
onChange={(val) => setData({ ...data, title: val.target.value })}
|
||||
onChange={(val) =>
|
||||
setData({
|
||||
...(data as any),
|
||||
title: val.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
<ComponentGlobal_CardStyles marginBottom={"0px"}>
|
||||
{!filePdf ? (
|
||||
<Text lineClamp={1} align="center" c={"gray"}>
|
||||
Dokumen {_.startCase(title)}.pdf
|
||||
{_.startCase(data?.title)}.pdf
|
||||
</Text>
|
||||
) : (
|
||||
<Grid align="center">
|
||||
@@ -125,7 +166,15 @@ export function Investasi_ViewEditDokumen({
|
||||
)}
|
||||
</ComponentGlobal_CardStyles>
|
||||
|
||||
<Group position="center">
|
||||
<Center>
|
||||
<ComponentGlobal_ButtonUploadFileImage
|
||||
onSetFile={setFilePdf}
|
||||
accept="application/pdf"
|
||||
text="Upload dokumen"
|
||||
/>
|
||||
</Center>
|
||||
|
||||
{/* <Group position="center">
|
||||
<FileButton
|
||||
accept={"application/pdf"}
|
||||
onChange={async (files: any) => {
|
||||
@@ -153,27 +202,37 @@ export function Investasi_ViewEditDokumen({
|
||||
</Button>
|
||||
)}
|
||||
</FileButton>
|
||||
</Group>
|
||||
</Group> */}
|
||||
</Stack>
|
||||
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoading}
|
||||
disabled={data.title === ""}
|
||||
mt={50}
|
||||
radius={50}
|
||||
bg={MainColor.yellow}
|
||||
color="yellow"
|
||||
c={"black"}
|
||||
<Box
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
}}
|
||||
onClick={() => {
|
||||
onUpdate();
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
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>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -52,7 +52,10 @@ export function Investasi_ViewEditInvestasiNew() {
|
||||
async function onGetOneInvestasiById() {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await apiGetOneInvestasiById(param.id);
|
||||
const response = await apiGetOneInvestasiById({
|
||||
id: param.id,
|
||||
|
||||
});
|
||||
if (response.success) {
|
||||
setData(response.data);
|
||||
setTotalLembar(response.data.totalLembar);
|
||||
|
||||
@@ -48,7 +48,9 @@ export function Investasi_ViewEditProspektus() {
|
||||
|
||||
async function onLoadData() {
|
||||
try {
|
||||
const respone = await apiGetOneInvestasiById(investasiId);
|
||||
const respone = await apiGetOneInvestasiById({
|
||||
id: investasiId,
|
||||
});
|
||||
if (respone.success) {
|
||||
setFileRemoveId(respone.data.prospektusFileId);
|
||||
}
|
||||
@@ -111,7 +113,7 @@ export function Investasi_ViewEditProspektus() {
|
||||
<ComponentGlobal_CardStyles marginBottom={"0px"}>
|
||||
{!filePdf ? (
|
||||
<Stack justify="center" align="center" h={"100%"}>
|
||||
<IconFileTypePdf size={50} color="gray" />
|
||||
<IconFileTypePdf size={40} color="gray" />
|
||||
</Stack>
|
||||
) : (
|
||||
<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 EditIntroInvestasi from "./edit_intro/view";
|
||||
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 LayoutEditBeritaInvestasi from "./edit_berita/layout";
|
||||
import DetailPropektus from "./detail_prospektus/view";
|
||||
@@ -56,8 +54,6 @@ export {
|
||||
LayoutPortofolioInvestasi,
|
||||
EditIntroInvestasi,
|
||||
LayoutEditIntroInvestasi,
|
||||
EditDokumenInvestasi,
|
||||
LayoutEditDokumenInvestasi,
|
||||
EditBeritaInvestasi,
|
||||
LayoutEditBeritaInvestasi,
|
||||
DetailPropektus,
|
||||
|
||||
Reference in New Issue
Block a user