Merge pull request #358 from bipproduction/bagas/4-mar-25

fix investasi file upload
This commit is contained in:
Bagasbanuna02
2025-03-04 14:26:33 +08:00
committed by GitHub
7 changed files with 42 additions and 17 deletions

View File

@@ -2,6 +2,8 @@
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
## [1.2.71](https://github.com/bipproduction/hipmi/compare/v1.2.70...v1.2.71) (2025-03-04)
## [1.2.70](https://github.com/bipproduction/hipmi/compare/v1.2.69...v1.2.70) (2025-03-04)
## [1.2.69](https://github.com/bipproduction/hipmi/compare/v1.2.68...v1.2.69) (2025-02-28)

View File

@@ -1,6 +1,6 @@
{
"name": "hipmi",
"version": "1.2.70",
"version": "1.2.71",
"private": true,
"prisma": {
"seed": "bun prisma/seed.ts"

View File

@@ -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
}
};

View File

@@ -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");

View File

@@ -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({
}}
>
<Flex direction={"column"} align={"center"} justify={"center"}>
<Text c={MainColor.white} fz={12}>Prospektus</Text>
<Text c={MainColor.white} fz={12}>
Prospektus
</Text>
<ActionIcon radius={"xl"} variant="transparent" size={60}>
{isLoading ? (
<Loader color="yellow" />

View File

@@ -20,6 +20,8 @@ export function Investasi_UiFileViewProspektus() {
const param = useParams<{ id: string }>();
const prospektusId = param.id;
console.log(">>", prospektusId);
const [pdfPages, setPdfPages] = useState<PageData[] | null>(null);
const [loading, setLoading] = useState<boolean>(true);
const [error, setError] = useState<string | null>(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={<IconX />}
customButtonRight={
error && error !== "" ? (
loading ? (
<CustomSkeleton circle height={30} width={30} />
) : error && error !== "" ? (
<ActionIcon disabled />
) : (
<ActionIcon

View File

@@ -27,8 +27,8 @@ import {
import _ from "lodash";
import { useState } from "react";
import { Investasi_ComponentButtonCreateNewInvestasi } from "../_component";
import { apiGetMasterInvestasi } from "../_lib/api_interface";
import { Investasi_ComponentButtonUploadFile } from "../_component/button/comp_button_upload_file_prospektus";
import { apiGetMasterInvestasi } from "../_lib/api_interface";
export default function InvestasiCreateNew() {
const [loadingMasterInvestor, setLoadingMasterInvestor] = useState(true);
@@ -172,14 +172,25 @@ export default function InvestasiCreateNew() {
<IconFileTypePdf size={50} color="gray" />
</Stack>
) : (
<Grid align="center">
<Grid.Col span={2}></Grid.Col>
<Grid align="center" justify="center">
<Grid.Col span={1}></Grid.Col>
<Grid.Col span={"auto"}>
<Text lineClamp={1} align="center">
{filePdf.name}
</Text>
<Center>
<Box p="xs" w={200}>
<Text
style={{
textAlign: "center",
width: "100%",
}}
truncate
align="center"
>
{filePdf.name}
</Text>
</Box>
</Center>
</Grid.Col>
<Grid.Col span={2}>
<Grid.Col span={1}>
<Center>
<IconCircleCheck color="green" />
</Center>