fix investasi upload file
This commit is contained in:
@@ -36,7 +36,7 @@ const apiGetPdfToImage = async ({ id }: { id: string }) => {
|
|||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const errorData = await response.json().catch(() => null);
|
const errorData = await response.json().catch(() => null);
|
||||||
console.error(
|
console.error(
|
||||||
"Error get admin contact:",
|
"Failed get file",
|
||||||
errorData?.message || "Unknown error"
|
errorData?.message || "Unknown error"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ const apiGetPdfToImage = async ({ id }: { id: string }) => {
|
|||||||
const jsonData: PdfResponse = await response.json();
|
const jsonData: PdfResponse = await response.json();
|
||||||
return jsonData;
|
return jsonData;
|
||||||
} catch (error) {
|
} 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
|
throw error; // Re-throw the error to handle it in the calling function
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ export function Investasi_ComponentButtonUploadFile({
|
|||||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log("files", files);
|
|
||||||
|
|
||||||
if (files.size > 100 * 1024 * 1024) {
|
if (files.size > 100 * 1024 * 1024) {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
ComponentGlobal_NotifikasiPeringatan("File terlalu besar");
|
ComponentGlobal_NotifikasiPeringatan("File terlalu besar");
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { ActionIcon, Flex, Loader, Paper, Text } from "@mantine/core";
|
|||||||
import { IconBookDownload } from "@tabler/icons-react";
|
import { IconBookDownload } from "@tabler/icons-react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||||
|
|
||||||
export function Investasi_ComponentBoxProspektus({
|
export function Investasi_ComponentBoxProspektus({
|
||||||
prospektusFileId,
|
prospektusFileId,
|
||||||
@@ -24,6 +25,10 @@ export function Investasi_ComponentBoxProspektus({
|
|||||||
color: "white",
|
color: "white",
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
if (!prospektusFileId)
|
||||||
|
return ComponentGlobal_NotifikasiPeringatan(
|
||||||
|
"Prospektus belum diupload"
|
||||||
|
);
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
router.push(
|
router.push(
|
||||||
NEW_RouterInvestasi.file_prospektus({ id: prospektusFileId }),
|
NEW_RouterInvestasi.file_prospektus({ id: prospektusFileId }),
|
||||||
@@ -32,7 +37,9 @@ export function Investasi_ComponentBoxProspektus({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Flex direction={"column"} align={"center"} justify={"center"}>
|
<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}>
|
<ActionIcon radius={"xl"} variant="transparent" size={60}>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<Loader color="yellow" />
|
<Loader color="yellow" />
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ export function Investasi_UiFileViewProspektus() {
|
|||||||
const param = useParams<{ id: string }>();
|
const param = useParams<{ id: string }>();
|
||||||
const prospektusId = param.id;
|
const prospektusId = param.id;
|
||||||
|
|
||||||
|
console.log(">>", prospektusId);
|
||||||
|
|
||||||
const [pdfPages, setPdfPages] = useState<PageData[] | null>(null);
|
const [pdfPages, setPdfPages] = useState<PageData[] | null>(null);
|
||||||
const [loading, setLoading] = useState<boolean>(true);
|
const [loading, setLoading] = useState<boolean>(true);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
@@ -36,10 +38,13 @@ export function Investasi_UiFileViewProspektus() {
|
|||||||
setPdfPages(response.pages as any);
|
setPdfPages(response.pages as any);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
console.error("Error fetching PDF:", err);
|
console.error("Error fetching PDF:", error);
|
||||||
setError(err instanceof Error ? err.message : "Unknown error occurred");
|
setError(
|
||||||
|
error instanceof Error ? error.message : "Unknown error occurred"
|
||||||
|
);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
setPdfPages(null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -73,7 +78,9 @@ export function Investasi_UiFileViewProspektus() {
|
|||||||
title="Pratinjau Prospektus"
|
title="Pratinjau Prospektus"
|
||||||
iconLeft={<IconX />}
|
iconLeft={<IconX />}
|
||||||
customButtonRight={
|
customButtonRight={
|
||||||
error && error !== "" ? (
|
loading ? (
|
||||||
|
<CustomSkeleton circle height={30} width={30} />
|
||||||
|
) : error && error !== "" ? (
|
||||||
<ActionIcon disabled />
|
<ActionIcon disabled />
|
||||||
) : (
|
) : (
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ import {
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Investasi_ComponentButtonCreateNewInvestasi } from "../_component";
|
import { Investasi_ComponentButtonCreateNewInvestasi } from "../_component";
|
||||||
import { apiGetMasterInvestasi } from "../_lib/api_interface";
|
|
||||||
import { Investasi_ComponentButtonUploadFile } from "../_component/button/comp_button_upload_file_prospektus";
|
import { Investasi_ComponentButtonUploadFile } from "../_component/button/comp_button_upload_file_prospektus";
|
||||||
|
import { apiGetMasterInvestasi } from "../_lib/api_interface";
|
||||||
|
|
||||||
export default function InvestasiCreateNew() {
|
export default function InvestasiCreateNew() {
|
||||||
const [loadingMasterInvestor, setLoadingMasterInvestor] = useState(true);
|
const [loadingMasterInvestor, setLoadingMasterInvestor] = useState(true);
|
||||||
@@ -172,14 +172,25 @@ export default function InvestasiCreateNew() {
|
|||||||
<IconFileTypePdf size={50} color="gray" />
|
<IconFileTypePdf size={50} color="gray" />
|
||||||
</Stack>
|
</Stack>
|
||||||
) : (
|
) : (
|
||||||
<Grid align="center">
|
<Grid align="center" justify="center">
|
||||||
<Grid.Col span={2}></Grid.Col>
|
<Grid.Col span={1}></Grid.Col>
|
||||||
<Grid.Col span={"auto"}>
|
<Grid.Col span={"auto"}>
|
||||||
<Text lineClamp={1} align="center">
|
<Center>
|
||||||
{filePdf.name}
|
<Box p="xs" w={200}>
|
||||||
</Text>
|
<Text
|
||||||
|
style={{
|
||||||
|
textAlign: "center",
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
truncate
|
||||||
|
align="center"
|
||||||
|
>
|
||||||
|
{filePdf.name}
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
</Center>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={2}>
|
<Grid.Col span={1}>
|
||||||
<Center>
|
<Center>
|
||||||
<IconCircleCheck color="green" />
|
<IconCircleCheck color="green" />
|
||||||
</Center>
|
</Center>
|
||||||
|
|||||||
Reference in New Issue
Block a user