diff --git a/src/app_modules/_global/lib/api_fetch_global.ts b/src/app_modules/_global/lib/api_fetch_global.ts index c07ee4a6..00a7cf12 100644 --- a/src/app_modules/_global/lib/api_fetch_global.ts +++ b/src/app_modules/_global/lib/api_fetch_global.ts @@ -36,7 +36,7 @@ const apiGetPdfToImage = async ({ id }: { id: string }) => { if (!response.ok) { const errorData = await response.json().catch(() => null); console.error( - "Error get admin contact:", + "Failed get file", errorData?.message || "Unknown error" ); @@ -46,7 +46,7 @@ const apiGetPdfToImage = async ({ id }: { id: string }) => { const jsonData: PdfResponse = await response.json(); return jsonData; } catch (error) { - console.error("Error get admin contact:", error); + console.error("Error get file", error); throw error; // Re-throw the error to handle it in the calling function } }; diff --git a/src/app_modules/investasi/_component/button/comp_button_upload_file_prospektus.tsx b/src/app_modules/investasi/_component/button/comp_button_upload_file_prospektus.tsx index 29ea7f97..bcce3cf4 100644 --- a/src/app_modules/investasi/_component/button/comp_button_upload_file_prospektus.tsx +++ b/src/app_modules/investasi/_component/button/comp_button_upload_file_prospektus.tsx @@ -29,8 +29,6 @@ export function Investasi_ComponentButtonUploadFile({ new Blob([new Uint8Array(await files.arrayBuffer())]) ); - console.log("files", files); - if (files.size > 100 * 1024 * 1024) { setIsLoading(false); ComponentGlobal_NotifikasiPeringatan("File terlalu besar"); diff --git a/src/app_modules/investasi/_component/detail/comp_box_prospektus.tsx b/src/app_modules/investasi/_component/detail/comp_box_prospektus.tsx index c482bf5e..884b055e 100644 --- a/src/app_modules/investasi/_component/detail/comp_box_prospektus.tsx +++ b/src/app_modules/investasi/_component/detail/comp_box_prospektus.tsx @@ -4,6 +4,7 @@ import { ActionIcon, Flex, Loader, Paper, Text } from "@mantine/core"; import { IconBookDownload } from "@tabler/icons-react"; import { useRouter } from "next/navigation"; import { useState } from "react"; +import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global"; export function Investasi_ComponentBoxProspektus({ prospektusFileId, @@ -24,6 +25,10 @@ export function Investasi_ComponentBoxProspektus({ color: "white", }} onClick={() => { + if (!prospektusFileId) + return ComponentGlobal_NotifikasiPeringatan( + "Prospektus belum diupload" + ); setLoading(true); router.push( NEW_RouterInvestasi.file_prospektus({ id: prospektusFileId }), @@ -32,7 +37,9 @@ export function Investasi_ComponentBoxProspektus({ }} > - Prospektus + + Prospektus + {isLoading ? ( diff --git a/src/app_modules/investasi/_ui/file_view/ui_file_view_prospektus.tsx b/src/app_modules/investasi/_ui/file_view/ui_file_view_prospektus.tsx index 0beb0c64..f157ce06 100644 --- a/src/app_modules/investasi/_ui/file_view/ui_file_view_prospektus.tsx +++ b/src/app_modules/investasi/_ui/file_view/ui_file_view_prospektus.tsx @@ -20,6 +20,8 @@ export function Investasi_UiFileViewProspektus() { const param = useParams<{ id: string }>(); const prospektusId = param.id; + console.log(">>", prospektusId); + const [pdfPages, setPdfPages] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); @@ -36,10 +38,13 @@ export function Investasi_UiFileViewProspektus() { setPdfPages(response.pages as any); setLoading(false); } - } catch (err) { - console.error("Error fetching PDF:", err); - setError(err instanceof Error ? err.message : "Unknown error occurred"); + } catch (error) { + console.error("Error fetching PDF:", error); + setError( + error instanceof Error ? error.message : "Unknown error occurred" + ); setLoading(false); + setPdfPages(null); } }; @@ -73,7 +78,9 @@ export function Investasi_UiFileViewProspektus() { title="Pratinjau Prospektus" iconLeft={} customButtonRight={ - error && error !== "" ? ( + loading ? ( + + ) : error && error !== "" ? ( ) : ( ) : ( - - + + - - {filePdf.name} - +
+ + + {filePdf.name} + + +
- +