Merge pull request #239 from bipproduction/bagas/14-jan-25

fix ( upload image )
This commit is contained in:
Bagasbanuna02
2025-01-15 10:27:32 +08:00
committed by GitHub
24 changed files with 725 additions and 859 deletions

View File

@@ -23,6 +23,7 @@ export async function GET(request: Request, context: { params: { id: string } })
catatan: true, catatan: true,
sisaLembar: true, sisaLembar: true,
imageId: true, imageId: true,
prospektusFileId: true,
masterPencarianInvestorId: true, masterPencarianInvestorId: true,
masterPeriodeDevidenId: true, masterPeriodeDevidenId: true,
masterPembagianDevidenId: true, masterPembagianDevidenId: true,

View File

@@ -1,38 +1,8 @@
import { investasi_funGetOneInvestasiById } from "@/app_modules/investasi/_fun"; import { Investasi_UiEditInvestasiNew } from "@/app_modules/investasi/_ui";
import { Investasi_UiEditInvestasi, Investasi_UiEditInvestasiNew } from "@/app_modules/investasi/_ui";
import getPembagianDeviden from "@/app_modules/investasi/fun/master/get_pembagian_deviden";
import getPencarianInvestor from "@/app_modules/investasi/fun/master/get_pencarian_investor";
import getPeriodeDeviden from "@/app_modules/investasi/fun/master/get_periode_deviden";
import _ from "lodash";
export default async function Page({ params }: { params: { id: string } }) {
// const investasiId = params.id;
// const allData = await investasi_funGetOneInvestasiById({ investasiId });
// const dataInvestasi = _.omit(allData, [
// "BeritaInvestasi",
// "DokumenInvestasi",
// "MasterPembagianDeviden",
// "MasterPencarianInvestor",
// "MasterProgresInvestasi",
// "MasterStatusInvestasi",
// "ProspektusInvestasi",
// "MasterPeriodeDeviden",
// "author",
// ]);
// const listPencarian = await getPencarianInvestor();
// const listPeriode = await getPeriodeDeviden();
// const listPembagian = await getPembagianDeviden();
export default async function Page() {
return ( return (
<> <>
{/* <Investasi_UiEditInvestasi
dataInvestasi={dataInvestasi}
pembagianDeviden={listPembagian}
pencarianInvestor={listPencarian}
periodeDeviden={listPeriode}
/> */}
<Investasi_UiEditInvestasiNew /> <Investasi_UiEditInvestasiNew />
</> </>
); );

View File

@@ -1,11 +1,10 @@
import { Investasi_UiEditProspektus } from "@/app_modules/investasi/_ui"; import { Investasi_UiEditProspektus } 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_UiEditProspektus investasiId={investasiId} /> <Investasi_UiEditProspektus />
</> </>
); );
} }

View File

@@ -1,21 +0,0 @@
import { LayoutEditProspektusInvestasi } from "@/app_modules/investasi";
import getOneInvestasiById from "@/app_modules/investasi/fun/get_one_investasi_by_id";
import React from "react";
export default async function Layout({
children,
params,
}: {
children: React.ReactNode;
params: { id: string };
}) {
const dataInvestasi = await getOneInvestasiById(params.id);
return (
<>
<LayoutEditProspektusInvestasi dataInvestasi={dataInvestasi as any}>
{children}
</LayoutEditProspektusInvestasi>
</>
);
}

View File

@@ -1,12 +0,0 @@
import { EditProspektusInvestasi } 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 (
<>
<EditProspektusInvestasi dataInvestasi={dataInvestasi as any} />
</>
);
}

View File

@@ -10,9 +10,15 @@ import { ComponentGlobal_NotifikasiPeringatan } from "../notif_global";
export function ComponentGlobal_ButtonUploadFileImage({ export function ComponentGlobal_ButtonUploadFileImage({
onSetFile, onSetFile,
onSetImage, onSetImage,
text,
icon,
accept,
}: { }: {
onSetFile: File | null | any; onSetFile: File | null | any;
onSetImage: any | null; onSetImage?: any | null;
text?: string;
icon?: string | any
accept?: string;
}) { }) {
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
@@ -28,6 +34,7 @@ export function ComponentGlobal_ButtonUploadFileImage({
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");
return
} }
onSetFile(files); onSetFile(files);
@@ -38,7 +45,7 @@ export function ComponentGlobal_ButtonUploadFileImage({
setIsLoading(false); setIsLoading(false);
} }
}} }}
accept="image/png,image/png,image/jpeg,image/gif" accept={accept ? accept : "image/png,image/png,image/jpeg,image/gif"}
> >
{(props) => ( {(props) => (
<Button <Button
@@ -50,10 +57,10 @@ export function ComponentGlobal_ButtonUploadFileImage({
backgroundColor: MainColor.yellow, backgroundColor: MainColor.yellow,
border: `1px solid ${AccentColor.yellow}`, border: `1px solid ${AccentColor.yellow}`,
}} }}
leftIcon={<IconUpload color="black" size={20} />} leftIcon={icon ? icon : <IconUpload color="black" size={20} />}
c={MainColor.darkblue} c={MainColor.darkblue}
> >
Upload {text ? text : "Upload"}
</Button> </Button>
)} )}
</FileButton> </FileButton>

View File

@@ -42,7 +42,13 @@ export default function ComponentGlobal_BoxInformation({
<IconInfoCircle color={MainColor.white} /> <IconInfoCircle color={MainColor.white} />
</Grid.Col> </Grid.Col>
<Grid.Col span={10}> <Grid.Col span={10}>
<Text span inherit c={MainColor.white} fw={"normal"}> <Text
fz={fonsize ? fonsize : 12}
span
inherit
c={MainColor.white}
fw={"normal"}
>
{informasi} {informasi}
</Text> </Text>
</Grid.Col> </Grid.Col>

View File

@@ -65,6 +65,7 @@ export function Investasi_ComponentButtonCreateNewInvestasi({
dirId: DIRECTORY_ID.investasi_prospektus, dirId: DIRECTORY_ID.investasi_prospektus,
}); });
if (!uploadFilePdf.success) { if (!uploadFilePdf.success) {
setIsLoading(false);
ComponentGlobal_NotifikasiPeringatan("Gagal upload file pdf"); ComponentGlobal_NotifikasiPeringatan("Gagal upload file pdf");
return; return;
} }
@@ -104,17 +105,16 @@ export function Investasi_ComponentButtonCreateNewInvestasi({
router.push(NEW_RouterInvestasi.portofolio({ id: "2" })); router.push(NEW_RouterInvestasi.portofolio({ id: "2" }));
setActiveTab("Review"); setActiveTab("Review");
setHotMenu(1); setHotMenu(1);
setIsLoading(true);
ComponentGlobal_NotifikasiBerhasil(res.message); ComponentGlobal_NotifikasiBerhasil(res.message);
} }
} else { } else {
setIsLoading(false);
ComponentGlobal_NotifikasiGagal(res.message); ComponentGlobal_NotifikasiGagal(res.message);
} }
} catch (error) { } catch (error) {
clientLogger.error("Error create new investasi", error);
} finally {
setIsLoading(false); setIsLoading(false);
} clientLogger.error("Error create new investasi", error);
}
} }
return ( return (

View File

@@ -6,11 +6,15 @@ import {
ComponentGlobal_NotifikasiPeringatan, ComponentGlobal_NotifikasiPeringatan,
} from "@/app_modules/_global/notif_global"; } from "@/app_modules/_global/notif_global";
import { DIRECTORY_ID } from "@/app/lib"; import { DIRECTORY_ID } from "@/app/lib";
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun"; import {
funGlobal_DeleteFileById,
funGlobal_UploadToStorage,
} from "@/app_modules/_global/fun";
import _ from "lodash"; import _ from "lodash";
import { investasi_funUpdateInvestasi } from "../../_fun"; import { investasi_funUpdateInvestasi } from "../../_fun";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { useState } from "react"; import { useState } from "react";
import { clientLogger } from "@/util/clientLogger";
export function Investasi_ComponentButtonUpdateDataInvestasi({ export function Investasi_ComponentButtonUpdateDataInvestasi({
data, data,
@@ -37,11 +41,21 @@ export function Investasi_ComponentButtonUpdateDataInvestasi({
file: file as any, file: file as any,
dirId: DIRECTORY_ID.investasi_image, dirId: DIRECTORY_ID.investasi_image,
}); });
if (!uploadImage.success) { if (!uploadImage.success) {
setIsLoading(false); setIsLoading(false);
return ComponentGlobal_NotifikasiPeringatan("Gagal upload file gambar"); return ComponentGlobal_NotifikasiPeringatan("Gagal upload file gambar");
} }
const deleteFile = await funGlobal_DeleteFileById({
fileId: data.imageId,
});
if (!deleteFile.success) {
setIsLoading(false);
clientLogger.error("Error delete file:", deleteFile.message);
}
const updtWithImage = await investasi_funUpdateInvestasi({ const updtWithImage = await investasi_funUpdateInvestasi({
data: data, data: data,
imageId: uploadImage.data.id, imageId: uploadImage.data.id,

View File

@@ -0,0 +1,35 @@
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import { Box, Center, Stack } from "@mantine/core";
export { Investasi_SkeletonEditProspektus };
function Investasi_SkeletonEditProspektus() {
return (
<>
<Stack>
<CustomSkeleton h={70} radius={"md"} />
<CustomSkeleton h={70} radius={"md"} />
<Center>
<CustomSkeleton h={40} w={100} radius={"xl"} />
</Center>
<Box
style={{
display: "flex",
justifyContent: "center",
}}
>
<Box
style={{
transition: "all 0.3s ease",
position: "absolute",
bottom: 20,
width: "90%",
}}
>
<CustomSkeleton h={40} width={"100%"} radius={"xl"} />
</Box>
</Box>
</Stack>
</>
);
}

View File

@@ -1,6 +1,6 @@
"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/vew_edit_investasi_new"; import { Investasi_ViewEditInvestasiNew } from "../../_view/edit/view_edit_investasi_new";
export function Investasi_UiEditInvestasiNew() { export function Investasi_UiEditInvestasiNew() {
return ( return (

View File

@@ -6,17 +6,13 @@ import {
} from "@/app_modules/_global/ui"; } from "@/app_modules/_global/ui";
import { Investasi_ViewEditProspektus } from "../../_view"; import { Investasi_ViewEditProspektus } from "../../_view";
export function Investasi_UiEditProspektus({ export function Investasi_UiEditProspektus() {
investasiId,
}: {
investasiId: string;
}) {
return ( return (
<> <>
<UIGlobal_LayoutTamplate <UIGlobal_LayoutTamplate
header={<UIGlobal_LayoutHeaderTamplate title="Edit Prospektus" />} header={<UIGlobal_LayoutHeaderTamplate title="Edit Prospektus" />}
> >
<Investasi_ViewEditProspektus investasiId={investasiId} /> <Investasi_ViewEditProspektus />
</UIGlobal_LayoutTamplate> </UIGlobal_LayoutTamplate>
</> </>
); );

View File

@@ -1,420 +0,0 @@
import { MainColor } from "@/app_modules/_global/color";
import { ComponentGlobal_BoxInformation, ComponentGlobal_BoxUploadImage, ComponentGlobal_LoadImage, } from "@/app_modules/_global/component";
import { AspectRatio, Box, Button, FileButton, Group, Image, Select, Stack, Text, TextInput, } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { IconCamera } from "@tabler/icons-react";
import _ from "lodash";
import { useState } from "react";
import { Investasi_ComponentButtonUpdateDataInvestasi } from "../../_component";
import { apiGetMasterInvestasi, apiGetOneInvestasiById } from "../../_lib/api_interface";
import { IDataInvestasi } from "../../_lib/type_investasi";
import { useParams } from "next/navigation";
import SkeletonEditInvestasi from "./skeleton_edit_investasi";
export function Investasi_ViewEditInvestasiNew() {
const param = useParams<{ id: string }>()
const [loading, setLoading] = useState(true)
const [loadingMasterInvestor, setLoadingMasterInvestor] = useState(true)
const [loadingMasterPeriodeDeviden, setLoadingMasterPeriodeDeviden] = useState(true)
const [loadingMasterPembagianDeviden, setLoadingMasterPembagianDeviden] = useState(true)
const [periodeDeviden, setPeriodeDeviden] = useState<any[]>([]);
const [pembagianDeviden, setPembagianDeviden] = useState<any[]>([]);
const [pencarianInvestor, setPencarianInvestor] = useState<any[]>([]);
const [data, setData] = useState<IDataInvestasi>();
const [file, setFile] = useState<File | null>(null);
const [img, setImg] = useState<any | null>();
const [target, setTarget] = useState("");
const [harga, setHarga] = useState("");
const [totalLembar, setTotalLembar] = useState<any>("");
async function onGetOneInvestasiById() {
try {
setLoading(true)
const response = await apiGetOneInvestasiById(param.id)
if (response.success) {
setData(response.data)
setTotalLembar(response.data.totalLembar)
}
} catch (error) {
console.error(error)
} finally {
setLoading(false)
}
}
async function onGetMasterInvestor() {
try {
setLoadingMasterInvestor(true)
const response = await apiGetMasterInvestasi("?cat=pencarian-investor")
if (response.success) {
setPencarianInvestor(response.data)
}
} catch (error) {
console.log(error)
} finally {
setLoadingMasterInvestor(false)
}
}
async function onGetMasterPeriodeDeviden() {
try {
setLoadingMasterPeriodeDeviden(true)
const response = await apiGetMasterInvestasi("?cat=periode-deviden")
if (response.success) {
setPeriodeDeviden(response.data)
}
} catch (error) {
console.log(error)
} finally {
setLoadingMasterPeriodeDeviden(false)
}
}
async function onGetMasterPembagianDeviden() {
try {
setLoadingMasterPembagianDeviden(true)
const response = await apiGetMasterInvestasi("?cat=pembagian-deviden")
if (response.success) {
setPembagianDeviden(response.data)
}
} catch (error) {
console.log(error)
} finally {
setLoadingMasterPembagianDeviden(false)
}
}
useShallowEffect(() => {
onGetOneInvestasiById()
onGetMasterInvestor()
onGetMasterPeriodeDeviden()
onGetMasterPembagianDeviden()
}, [])
async function onTotalLembar({ target, harga, }: { target?: number | any; harga?: number | any; }) {
if (target !== 0 && harga !== 0) {
const hasil: any = target / harga;
const result = _.floor(hasil === Infinity ? 0 : hasil);
setTotalLembar(result.toString());
}
}
return (
<>
<Stack px={"sm"}>
{
loading ?
<SkeletonEditInvestasi />
:
<>
<Stack spacing={0}>
<Box mb={"sm"}>
<ComponentGlobal_BoxInformation informasi="Gambar investasi bisa berupa ilustrasi, poster atau foto terkait investasi" />
</Box>
<ComponentGlobal_BoxUploadImage>
{img ? (
<AspectRatio ratio={1 / 1} mt={5} maw={300} mx={"auto"}>
<Image style={{ maxHeight: 250 }} alt="Avatar" src={img} />
</AspectRatio>
) : (
<ComponentGlobal_LoadImage maw={300} fileId={String(data?.imageId)} />
)}
</ComponentGlobal_BoxUploadImage>
{/* Upload Foto */}
<Group position="center">
<FileButton
onChange={async (files: any) => {
try {
const buffer = URL.createObjectURL(
new Blob([new Uint8Array(await files.arrayBuffer())])
);
setImg(buffer);
setFile(files);
} catch (error) {
console.log(error);
}
}}
accept="image/png,image/jpeg"
>
{(props) => (
<Button
{...props}
leftIcon={<IconCamera color="black" />}
radius={50}
bg={MainColor.yellow}
color="yellow"
c={"black"}
>
Upload Gambar
</Button>
)}
</FileButton>
</Group>
</Stack>
<TextInput
styles={{
label: {
color: MainColor.white,
},
input: {
backgroundColor: MainColor.white
},
required: {
color: MainColor.red
}
}}
withAsterisk
label="Judul Investasi"
placeholder="Judul investasi"
maxLength={100}
value={data?.title}
onChange={(val) => {
setData({
...data as any,
title: val.target.value,
});
}}
/>
<TextInput
styles={{
label: {
color: MainColor.white,
},
input: {
backgroundColor: MainColor.white
},
required: {
color: MainColor.red
}
}}
icon={<Text fw={"bold"}>Rp.</Text>}
min={0}
withAsterisk
label="Dana Dibutuhkan"
placeholder="0"
value={target ? target : data?.targetDana}
onChange={(val) => {
const match = val.currentTarget.value
.replace(/\./g, "")
.match(/^[0-9]+$/);
if (val.currentTarget.value === "") return setTarget(0 + "");
if (!match?.[0]) return null;
const nilai = val.currentTarget.value.replace(/\./g, "");
const targetNilai = Intl.NumberFormat("id-ID").format(+nilai);
onTotalLembar({
target: +nilai,
harga: +Number(data?.hargaLembar),
});
setTarget(targetNilai);
setData({
...data as any,
targetDana: nilai as string,
});
}}
/>
<TextInput
styles={{
label: {
color: MainColor.white,
},
input: {
backgroundColor: MainColor.white
},
required: {
color: MainColor.red
}
}}
icon={<Text fw={"bold"}>Rp.</Text>}
min={0}
withAsterisk
label="Harga Per Lembar"
placeholder="0"
value={harga ? harga : data?.hargaLembar}
onChange={(val) => {
try {
const match = val.currentTarget.value
.replace(/\./g, "")
.match(/^[0-9]+$/);
if (val.currentTarget.value === "") return setHarga(0 + "");
if (!match?.[0]) return null;
const nilai = val.currentTarget.value.replace(/\./g, "");
const targetNilai = Intl.NumberFormat("id-ID").format(+nilai);
onTotalLembar({
harga: +nilai,
target: +Number(data?.targetDana),
});
setHarga(targetNilai);
setData({
...data as any,
hargaLembar: nilai as string,
});
} catch (error) {
console.log(error);
}
}}
/>
<TextInput
description="*Total lembar dihitung dari, Target Dana / Harga Perlembar"
label="Total Lembar"
value={harga === "0" ? "0" : target === "0" ? "0" : totalLembar}
readOnly
styles={{
label: {
color: MainColor.white,
},
input: {
backgroundColor: MainColor.white
},
required: {
color: MainColor.red
}
}}
/>
<TextInput
styles={{
label: {
color: MainColor.white,
},
input: {
backgroundColor: MainColor.white
},
required: {
color: MainColor.red
}
}}
rightSection={
<Text fw={"bold"} c={"gray"}>
%
</Text>
}
withAsterisk
type="number"
label={"Rasio Keuntungan / ROI %"}
placeholder="Masukan rasio keuntungan"
value={data?.roi}
onChange={(val) => {
setData({
...data as any,
roi: val.target.value,
});
}}
/>
<Select
styles={{
label: {
color: MainColor.white,
},
input: {
backgroundColor: MainColor.white
},
required: {
color: MainColor.red
},
dropdown: {
backgroundColor: MainColor.white,
}
}}
withAsterisk
label="Pencarian Investor"
placeholder={loadingMasterInvestor ? "Loading..." : "Pilih batas waktu"}
data={pencarianInvestor.map((e) => ({
value: e.id,
label: e.name + " " + "hari",
}))}
value={data?.masterPencarianInvestorId}
onChange={(val) => {
setData({
...(data as any),
masterPencarianInvestorId: val,
});
}}
/>
<Select
styles={{
label: {
color: MainColor.white,
},
input: {
backgroundColor: MainColor.white
},
required: {
color: MainColor.red
},
dropdown: {
backgroundColor: MainColor.white,
}
}}
withAsterisk
label="Periode Deviden"
placeholder={loadingMasterPeriodeDeviden ? "Loading..." : "Pilih batas waktu"}
data={periodeDeviden.map((e) => ({ value: e.id, label: e.name }))}
value={data?.masterPeriodeDevidenId}
onChange={(val) => {
setData({
...(data as any),
masterPeriodeDevidenId: val,
});
}}
/>
<Select
styles={{
label: {
color: MainColor.white,
},
input: {
backgroundColor: MainColor.white
},
required: {
color: MainColor.red
},
dropdown: {
backgroundColor: MainColor.white,
}
}}
withAsterisk
label="Pembagian Deviden"
placeholder={loadingMasterPembagianDeviden ? "Loading..." : "Pilih batas waktu"}
data={pembagianDeviden.map((e) => ({
value: e.id,
label: e.name + " " + "bulan",
}))}
value={data?.masterPembagianDevidenId}
onChange={(val) => {
setData({
...(data as any),
masterPembagianDevidenId: val,
});
}}
/>
<Investasi_ComponentButtonUpdateDataInvestasi
data={data as any}
file={file as any}
totalLembar={totalLembar}
/>
</>
}
</Stack>
</>
);
}

View File

@@ -0,0 +1,462 @@
import { MainColor } from "@/app_modules/_global/color";
import {
ComponentGlobal_BoxInformation,
ComponentGlobal_BoxUploadImage,
ComponentGlobal_ButtonUploadFileImage,
ComponentGlobal_LoadImage,
} from "@/app_modules/_global/component";
import {
AspectRatio,
Box,
Button,
Center,
FileButton,
Group,
Image,
Select,
Stack,
Text,
TextInput,
} from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { IconCamera } from "@tabler/icons-react";
import _ from "lodash";
import { useState } from "react";
import { Investasi_ComponentButtonUpdateDataInvestasi } from "../../_component";
import {
apiGetMasterInvestasi,
apiGetOneInvestasiById,
} from "../../_lib/api_interface";
import { IDataInvestasi } from "../../_lib/type_investasi";
import { useParams } from "next/navigation";
import SkeletonEditInvestasi from "./skeleton_edit_investasi";
export function Investasi_ViewEditInvestasiNew() {
const param = useParams<{ id: string }>();
const [loading, setLoading] = useState(true);
const [loadingMasterInvestor, setLoadingMasterInvestor] = useState(true);
const [loadingMasterPeriodeDeviden, setLoadingMasterPeriodeDeviden] =
useState(true);
const [loadingMasterPembagianDeviden, setLoadingMasterPembagianDeviden] =
useState(true);
const [periodeDeviden, setPeriodeDeviden] = useState<any[]>([]);
const [pembagianDeviden, setPembagianDeviden] = useState<any[]>([]);
const [pencarianInvestor, setPencarianInvestor] = useState<any[]>([]);
const [data, setData] = useState<IDataInvestasi>();
const [file, setFile] = useState<File | null>(null);
const [img, setImg] = useState<any | null>();
const [target, setTarget] = useState("");
const [harga, setHarga] = useState("");
const [totalLembar, setTotalLembar] = useState<any>("");
async function onGetOneInvestasiById() {
try {
setLoading(true);
const response = await apiGetOneInvestasiById(param.id);
if (response.success) {
setData(response.data);
setTotalLembar(response.data.totalLembar);
}
} catch (error) {
console.error(error);
} finally {
setLoading(false);
}
}
async function onGetMasterInvestor() {
try {
setLoadingMasterInvestor(true);
const response = await apiGetMasterInvestasi("?cat=pencarian-investor");
if (response.success) {
setPencarianInvestor(response.data);
}
} catch (error) {
console.log(error);
} finally {
setLoadingMasterInvestor(false);
}
}
async function onGetMasterPeriodeDeviden() {
try {
setLoadingMasterPeriodeDeviden(true);
const response = await apiGetMasterInvestasi("?cat=periode-deviden");
if (response.success) {
setPeriodeDeviden(response.data);
}
} catch (error) {
console.log(error);
} finally {
setLoadingMasterPeriodeDeviden(false);
}
}
async function onGetMasterPembagianDeviden() {
try {
setLoadingMasterPembagianDeviden(true);
const response = await apiGetMasterInvestasi("?cat=pembagian-deviden");
if (response.success) {
setPembagianDeviden(response.data);
}
} catch (error) {
console.log(error);
} finally {
setLoadingMasterPembagianDeviden(false);
}
}
useShallowEffect(() => {
onGetOneInvestasiById();
onGetMasterInvestor();
onGetMasterPeriodeDeviden();
onGetMasterPembagianDeviden();
}, []);
async function onTotalLembar({
target,
harga,
}: {
target?: number | any;
harga?: number | any;
}) {
if (target !== 0 && harga !== 0) {
const hasil: any = target / harga;
const result = _.floor(hasil === Infinity ? 0 : hasil);
setTotalLembar(result.toString());
}
}
return (
<>
<Stack px={"sm"}>
{loading ? (
<SkeletonEditInvestasi />
) : (
<>
<Stack spacing={0}>
<Box mb={"sm"}>
<ComponentGlobal_BoxInformation informasi="Gambar investasi bisa berupa ilustrasi, poster atau foto terkait investasi" />
</Box>
<ComponentGlobal_BoxUploadImage>
{img ? (
<AspectRatio ratio={1 / 1} mt={5} maw={300} mx={"auto"}>
<Image style={{ maxHeight: 250 }} alt="Avatar" src={img} />
</AspectRatio>
) : (
<ComponentGlobal_LoadImage
maw={300}
fileId={String(data?.imageId)}
/>
)}
</ComponentGlobal_BoxUploadImage>
{/* Upload Foto */}
<Center>
<ComponentGlobal_ButtonUploadFileImage
onSetFile={setFile}
onSetImage={setImg}
/>
</Center>
{/* <Group position="center">
<FileButton
onChange={async (files: any) => {
try {
const buffer = URL.createObjectURL(
new Blob([new Uint8Array(await files.arrayBuffer())])
);
setImg(buffer);
setFile(files);
} catch (error) {
console.log(error);
}
}}
accept="image/png,image/jpeg"
>
{(props) => (
<Button
{...props}
leftIcon={<IconCamera color="black" />}
radius={50}
bg={MainColor.yellow}
color="yellow"
c={"black"}
>
Upload Gambar
</Button>
)}
</FileButton>
</Group> */}
</Stack>
<TextInput
styles={{
label: {
color: MainColor.white,
},
input: {
backgroundColor: MainColor.white,
},
required: {
color: MainColor.red,
},
}}
withAsterisk
label="Judul Investasi"
placeholder="Judul investasi"
maxLength={100}
value={data?.title}
onChange={(val) => {
setData({
...(data as any),
title: val.target.value,
});
}}
/>
<TextInput
styles={{
label: {
color: MainColor.white,
},
input: {
backgroundColor: MainColor.white,
},
required: {
color: MainColor.red,
},
}}
icon={<Text fw={"bold"}>Rp.</Text>}
min={0}
withAsterisk
label="Dana Dibutuhkan"
placeholder="0"
value={target ? target : data?.targetDana}
onChange={(val) => {
const match = val.currentTarget.value
.replace(/\./g, "")
.match(/^[0-9]+$/);
if (val.currentTarget.value === "") return setTarget(0 + "");
if (!match?.[0]) return null;
const nilai = val.currentTarget.value.replace(/\./g, "");
const targetNilai = Intl.NumberFormat("id-ID").format(+nilai);
onTotalLembar({
target: +nilai,
harga: +Number(data?.hargaLembar),
});
setTarget(targetNilai);
setData({
...(data as any),
targetDana: nilai as string,
});
}}
/>
<TextInput
styles={{
label: {
color: MainColor.white,
},
input: {
backgroundColor: MainColor.white,
},
required: {
color: MainColor.red,
},
}}
icon={<Text fw={"bold"}>Rp.</Text>}
min={0}
withAsterisk
label="Harga Per Lembar"
placeholder="0"
value={harga ? harga : data?.hargaLembar}
onChange={(val) => {
try {
const match = val.currentTarget.value
.replace(/\./g, "")
.match(/^[0-9]+$/);
if (val.currentTarget.value === "") return setHarga(0 + "");
if (!match?.[0]) return null;
const nilai = val.currentTarget.value.replace(/\./g, "");
const targetNilai = Intl.NumberFormat("id-ID").format(+nilai);
onTotalLembar({
harga: +nilai,
target: +Number(data?.targetDana),
});
setHarga(targetNilai);
setData({
...(data as any),
hargaLembar: nilai as string,
});
} catch (error) {
console.log(error);
}
}}
/>
<TextInput
description="*Total lembar dihitung dari, Target Dana / Harga Perlembar"
label="Total Lembar"
value={harga === "0" ? "0" : target === "0" ? "0" : totalLembar}
readOnly
styles={{
label: {
color: MainColor.white,
},
input: {
backgroundColor: MainColor.white,
},
required: {
color: MainColor.red,
},
}}
/>
<TextInput
styles={{
label: {
color: MainColor.white,
},
input: {
backgroundColor: MainColor.white,
},
required: {
color: MainColor.red,
},
}}
rightSection={
<Text fw={"bold"} c={"gray"}>
%
</Text>
}
withAsterisk
type="number"
label={"Rasio Keuntungan / ROI %"}
placeholder="Masukan rasio keuntungan"
value={data?.roi}
onChange={(val) => {
setData({
...(data as any),
roi: val.target.value,
});
}}
/>
<Select
styles={{
label: {
color: MainColor.white,
},
input: {
backgroundColor: MainColor.white,
},
required: {
color: MainColor.red,
},
dropdown: {
backgroundColor: MainColor.white,
},
}}
withAsterisk
label="Pencarian Investor"
placeholder={
loadingMasterInvestor ? "Loading..." : "Pilih batas waktu"
}
data={pencarianInvestor.map((e) => ({
value: e.id,
label: e.name + " " + "hari",
}))}
value={data?.masterPencarianInvestorId}
onChange={(val) => {
setData({
...(data as any),
masterPencarianInvestorId: val,
});
}}
/>
<Select
styles={{
label: {
color: MainColor.white,
},
input: {
backgroundColor: MainColor.white,
},
required: {
color: MainColor.red,
},
dropdown: {
backgroundColor: MainColor.white,
},
}}
withAsterisk
label="Periode Deviden"
placeholder={
loadingMasterPeriodeDeviden ? "Loading..." : "Pilih batas waktu"
}
data={periodeDeviden.map((e) => ({ value: e.id, label: e.name }))}
value={data?.masterPeriodeDevidenId}
onChange={(val) => {
setData({
...(data as any),
masterPeriodeDevidenId: val,
});
}}
/>
<Select
styles={{
label: {
color: MainColor.white,
},
input: {
backgroundColor: MainColor.white,
},
required: {
color: MainColor.red,
},
dropdown: {
backgroundColor: MainColor.white,
},
}}
withAsterisk
label="Pembagian Deviden"
placeholder={
loadingMasterPembagianDeviden
? "Loading..."
: "Pilih batas waktu"
}
data={pembagianDeviden.map((e) => ({
value: e.id,
label: e.name + " " + "bulan",
}))}
value={data?.masterPembagianDevidenId}
onChange={(val) => {
setData({
...(data as any),
masterPembagianDevidenId: val,
});
}}
/>
<Investasi_ComponentButtonUpdateDataInvestasi
data={data as any}
file={file as any}
totalLembar={totalLembar}
/>
</>
)}
</Stack>
</>
);
}

View File

@@ -1,82 +1,118 @@
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 { import {
Box,
Button, Button,
Center, Center,
FileButton,
Grid, Grid,
Group,
Stack, Stack,
Text Text
} from "@mantine/core"; } from "@mantine/core";
import { import {
IconCamera, IconCircleCheck,
IconCircleCheck IconFileTypePdf
} from "@tabler/icons-react"; } from "@tabler/icons-react";
import { DIRECTORY_ID } from "@/app/lib"; import { DIRECTORY_ID } from "@/app/lib";
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun"; import {
funGlobal_DeleteFileById,
funGlobal_UploadToStorage,
} from "@/app_modules/_global/fun";
import { import {
ComponentGlobal_NotifikasiBerhasil, ComponentGlobal_NotifikasiBerhasil,
ComponentGlobal_NotifikasiPeringatan, ComponentGlobal_NotifikasiPeringatan,
} from "@/app_modules/_global/notif_global"; } from "@/app_modules/_global/notif_global";
import { useRouter } from "next/navigation"; import { clientLogger } from "@/util/clientLogger";
import { useShallowEffect } from "@mantine/hooks";
import { useParams, useRouter } from "next/navigation";
import { useState } from "react"; import { useState } from "react";
import { Investasi_SkeletonEditProspektus } from "../../_component/skeleton_view";
import { investasi_funUpdateProspektus } from "../../_fun"; import { investasi_funUpdateProspektus } from "../../_fun";
import { apiGetOneInvestasiById } from "../../_lib/api_interface";
export function Investasi_ViewEditProspektus({ export function Investasi_ViewEditProspektus() {
investasiId, const params = useParams<{ id: string }>();
}: { const investasiId = params.id;
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 [fileRemoveId, setFileRemoveId] = useState<string | null>(null);
useShallowEffect(() => {
onLoadData();
}, []);
async function onLoadData() {
try {
const respone = await apiGetOneInvestasiById(investasiId);
if (respone.success) {
setFileRemoveId(respone.data.prospektusFileId);
}
} catch (error) {
clientLogger.error("Error get data investasi:", error);
}
}
async function onUpload() { async function onUpload() {
setIsLoading(true);
const uploadFilePdf = await funGlobal_UploadToStorage({
file: filePdf as any,
dirId: DIRECTORY_ID.investasi_prospektus,
});
if (!uploadFilePdf.success) {
setIsLoading(false);
return ComponentGlobal_NotifikasiPeringatan("Gagal upload file pdf");
}
try { try {
setIsLoading(true);
const uploadFilePdf = await funGlobal_UploadToStorage({
file: filePdf as any,
dirId: DIRECTORY_ID.investasi_prospektus,
});
if (!uploadFilePdf.success) {
setIsLoading(false);
ComponentGlobal_NotifikasiPeringatan("Gagal upload file pdf");
return;
}
const deleteFile = await funGlobal_DeleteFileById({
fileId: fileRemoveId as string,
dirId: DIRECTORY_ID.investasi_prospektus,
});
if (!deleteFile.success) {
setIsLoading(false);
clientLogger.error("Error delete file:", deleteFile.message);
}
const updte = await investasi_funUpdateProspektus({ const updte = await investasi_funUpdateProspektus({
fileId: uploadFilePdf.data.id, fileId: uploadFilePdf.data.id,
investasiId: investasiId, investasiId: investasiId,
}); });
if (updte.status !== 200) { if (updte.status !== 200) {
return ComponentGlobal_NotifikasiPeringatan("Gagal update prospektus"); setIsLoading(false);
ComponentGlobal_NotifikasiPeringatan("Gagal update prospektus");
return;
} }
ComponentGlobal_NotifikasiBerhasil(updte.message);
router.back(); router.back();
return ComponentGlobal_NotifikasiBerhasil(updte.message);
} catch (error) { } catch (error) {
console.log(error);
} finally {
setIsLoading(false); setIsLoading(false);
clientLogger.error("Error update prospektus:", error);
} }
} }
if (fileRemoveId == null) {
return <Investasi_SkeletonEditProspektus />;
}
return ( return (
<> <>
<Stack spacing={"sm"}> <Stack spacing={"sm"}>
<ComponentGlobal_BoxInformation informasi="File prospektus wajib untuk diupload, agar calon investor paham dengan prospek investasi yang akan anda jalankan kedepan !" /> <ComponentGlobal_BoxInformation informasi="File prospektus wajib untuk diupload, agar calon investor paham dengan prospek investasi yang akan anda jalankan kedepan." />
<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 File Prospektus <IconFileTypePdf size={50} color="gray" />
</Text> </Stack>
) : ( ) : (
<Grid align="center"> <Grid align="center">
<Grid.Col span={2}></Grid.Col> <Grid.Col span={2}></Grid.Col>
@@ -94,54 +130,43 @@ export function Investasi_ViewEditProspektus({
)} )}
</ComponentGlobal_CardStyles> </ComponentGlobal_CardStyles>
<Group position="center"> <Center>
<FileButton <ComponentGlobal_ButtonUploadFileImage
onSetFile={setFilePdf}
accept={"application/pdf"} accept={"application/pdf"}
onChange={async (files: any) => { text="Upload File"
try { />
const buffer = URL.createObjectURL( </Center>
new Blob([new Uint8Array(await files.arrayBuffer())])
);
setFilePdf(files); <Box
} catch (error) {
console.log(error);
}
}}
>
{(props) => (
<Button
leftIcon={<IconCamera />}
{...props}
radius={"xl"}
bg={MainColor.yellow}
color="yellow"
c={"black"}
>
Upload File
</Button>
)}
</FileButton>
</Group>
<Button
loaderPosition="center"
loading={isLoading}
disabled={filePdf === null}
mt={50}
radius={50}
bg={MainColor.yellow}
color="yellow"
c={"black"}
style={{ style={{
transition: "0.5s", display: "flex",
}} justifyContent: "center",
onClick={() => {
onUpload();
}} }}
> >
Update <Button
</Button> px={"sm"}
loaderPosition="center"
loading={isLoading}
disabled={filePdf === null}
mt={50}
radius={50}
bg={MainColor.yellow}
color="yellow"
c={"black"}
style={{
transition: "all 0.3s ease",
position: "absolute",
bottom: 20,
width: "90%",
}}
onClick={() => {
onUpload();
}}
>
Update
</Button>
</Box>
</Stack> </Stack>
</> </>
); );

View File

@@ -32,6 +32,7 @@ import { IRealtimeData } from "@/app/lib/global_state";
import { notifikasiToAdmin_funCreate } from "@/app_modules/notifikasi/fun"; import { notifikasiToAdmin_funCreate } from "@/app_modules/notifikasi/fun";
import { WibuRealtime } from "wibu-pkg"; import { WibuRealtime } from "wibu-pkg";
import { clientLogger } from "@/util/clientLogger"; import { clientLogger } from "@/util/clientLogger";
import { ComponentGlobal_ButtonUploadFileImage } from "@/app_modules/_global/component";
export function Investasi_ViewInvoice({ export function Investasi_ViewInvoice({
dataInvoice, dataInvoice,
@@ -42,6 +43,7 @@ export function Investasi_ViewInvoice({
const [isLoading, setLoading] = useState(false); const [isLoading, setLoading] = useState(false);
const [data, setData] = useState(dataInvoice); const [data, setData] = useState(dataInvoice);
const [file, setFile] = useState<File | null>(null); const [file, setFile] = useState<File | null>(null);
const [img, setImg] = useState<any | null>(null);
async function onUpload() { async function onUpload() {
try { try {
@@ -52,6 +54,7 @@ export function Investasi_ViewInvoice({
}); });
if (!uploadFileToStorage.success) { if (!uploadFileToStorage.success) {
setLoading(false);
ComponentGlobal_NotifikasiPeringatan("Gagal upload bukti transfer"); ComponentGlobal_NotifikasiPeringatan("Gagal upload bukti transfer");
return; return;
} }
@@ -62,6 +65,7 @@ export function Investasi_ViewInvoice({
}); });
if (res.status != 200) { if (res.status != 200) {
setLoading(false);
ComponentGlobal_NotifikasiGagal(res.message); ComponentGlobal_NotifikasiGagal(res.message);
return; return;
} }
@@ -93,9 +97,8 @@ export function Investasi_ViewInvoice({
}); });
} }
} catch (error) { } catch (error) {
clientLogger.error(" Error upload invoice", error);
} finally {
setLoading(false); setLoading(false);
clientLogger.error(" Error upload invoice", error);
} }
} }
@@ -245,29 +248,10 @@ export function Investasi_ViewInvoice({
> >
<Stack spacing={"sm"}> <Stack spacing={"sm"}>
<Center> <Center>
<FileButton <ComponentGlobal_ButtonUploadFileImage
onChange={async (files: any | null) => { onSetFile={setFile}
try { accept="image/png,image/png,image/jpeg,application/pdf"
setFile(files); />
} catch (error) {
console.log(error);
}
}}
accept="image/png,image/jpeg"
>
{(props) => (
<Button
{...props}
radius={"xl"}
leftIcon={<IconCamera />}
bg={MainColor.yellow}
color="yellow"
c={"black"}
>
Upload
</Button>
)}
</FileButton>
</Center> </Center>
{file ? ( {file ? (
<Center> <Center>

View File

@@ -3,6 +3,7 @@ import { MainColor } from "@/app_modules/_global/color/color_pallet";
import { import {
ComponentGlobal_BoxInformation, ComponentGlobal_BoxInformation,
ComponentGlobal_BoxUploadImage, ComponentGlobal_BoxUploadImage,
ComponentGlobal_ButtonUploadFileImage,
ComponentGlobal_CardStyles, ComponentGlobal_CardStyles,
} from "@/app_modules/_global/component"; } from "@/app_modules/_global/component";
import { MAX_SIZE } from "@/app_modules/_global/lib"; import { MAX_SIZE } from "@/app_modules/_global/lib";
@@ -131,7 +132,7 @@ export default function InvestasiCreateNew() {
{/* Upload Image */} {/* Upload Image */}
<Stack spacing={0}> <Stack spacing={0}>
<Box mb={"sm"}> <Box mb={"sm"}>
<ComponentGlobal_BoxInformation informasi="Gambar investasi bisa berupa ilustrasi, poster atau foto terkait investasi" /> <ComponentGlobal_BoxInformation informasi="Gambar investasi bisa berupa ilustrasi, poster atau foto terkait investasi." />
</Box> </Box>
<ComponentGlobal_BoxUploadImage> <ComponentGlobal_BoxUploadImage>
{isLoadingImg ? ( {isLoadingImg ? (
@@ -155,7 +156,13 @@ export default function InvestasiCreateNew() {
</ComponentGlobal_BoxUploadImage> </ComponentGlobal_BoxUploadImage>
{/* Upload Foto */} {/* Upload Foto */}
<Group position="center"> <Center>
<ComponentGlobal_ButtonUploadFileImage
onSetFile={setFileImage}
onSetImage={setImg}
/>
</Center>
{/* <Group position="center">
<FileButton <FileButton
onChange={async (files: any) => { onChange={async (files: any) => {
try { try {
@@ -196,12 +203,12 @@ export default function InvestasiCreateNew() {
</Button> </Button>
)} )}
</FileButton> </FileButton>
</Group> </Group> */}
</Stack> </Stack>
{/* Upload File */} {/* Upload File */}
<Stack spacing={"sm"}> <Stack spacing={"sm"}>
<ComponentGlobal_BoxInformation informasi="File prospektus wajib untuk diupload, agar calon investor paham dengan prospek investasi yang akan anda jalankan kedepan !" /> <ComponentGlobal_BoxInformation informasi="File prospektus wajib untuk diupload, agar calon investor paham dengan prospek investasi yang akan anda jalankan kedepannya." />
<ComponentGlobal_CardStyles marginBottom={"0px"}> <ComponentGlobal_CardStyles marginBottom={"0px"}>
{isLoadingPdf ? ( {isLoadingPdf ? (
<Stack justify="center" align="center" h={"100%"}> <Stack justify="center" align="center" h={"100%"}>
@@ -228,7 +235,16 @@ export default function InvestasiCreateNew() {
)} )}
</ComponentGlobal_CardStyles> </ComponentGlobal_CardStyles>
<Group position="center"> <Center>
<ComponentGlobal_ButtonUploadFileImage
onSetFile={setFilePdf}
onSetImage={setFPdf}
accept={"application/pdf"}
text="Upload File"
icon={<IconFileTypePdf size={20} />}
/>
</Center>
{/* <Group position="center">
<FileButton <FileButton
accept={"application/pdf"} accept={"application/pdf"}
onChange={async (files: any) => { onChange={async (files: any) => {
@@ -269,7 +285,7 @@ export default function InvestasiCreateNew() {
</Button> </Button>
)} )}
</FileButton> </FileButton>
</Group> </Group> */}
</Stack> </Stack>
<Stack> <Stack>
@@ -283,7 +299,7 @@ export default function InvestasiCreateNew() {
}, },
input: { input: {
backgroundColor: MainColor.white, backgroundColor: MainColor.white,
} },
}} }}
withAsterisk withAsterisk
label="Judul Investasi" label="Judul Investasi"
@@ -307,7 +323,7 @@ export default function InvestasiCreateNew() {
}, },
input: { input: {
backgroundColor: MainColor.white, backgroundColor: MainColor.white,
} },
}} }}
icon={<Text fw={"bold"}>Rp.</Text>} icon={<Text fw={"bold"}>Rp.</Text>}
min={0} min={0}
@@ -350,7 +366,7 @@ export default function InvestasiCreateNew() {
}, },
input: { input: {
backgroundColor: MainColor.white, backgroundColor: MainColor.white,
} },
}} }}
icon={<Text fw={"bold"}>Rp.</Text>} icon={<Text fw={"bold"}>Rp.</Text>}
min={0} min={0}
@@ -403,7 +419,7 @@ export default function InvestasiCreateNew() {
}, },
input: { input: {
backgroundColor: MainColor.white, backgroundColor: MainColor.white,
} },
}} }}
/> />
@@ -417,7 +433,7 @@ export default function InvestasiCreateNew() {
}, },
input: { input: {
backgroundColor: MainColor.white, backgroundColor: MainColor.white,
} },
}} }}
rightSection={ rightSection={
<Text fw={"bold"} c={"gray"}> <Text fw={"bold"} c={"gray"}>

View File

@@ -1,30 +0,0 @@
"use client";
import UIGlobal_LayoutHeaderTamplate from "@/app_modules/_global/ui/ui_header_tamplate";
import UIGlobal_LayoutTamplate from "@/app_modules/_global/ui/ui_layout_tamplate";
import React from "react";
import { MODEL_INVESTASI } from "../_lib/interface";
export default function LayoutEditProspektusInvestasi({
children,
dataInvestasi,
}: {
children: React.ReactNode;
dataInvestasi: MODEL_INVESTASI;
}) {
return (
<>
<UIGlobal_LayoutTamplate
header={
<UIGlobal_LayoutHeaderTamplate
title="Edit Prospektus"
// icon={<IconEdit />}
// route2={RouterInvestasi.upload_prospektus + `${dataInvestasi.id}`}
/>
}
>
{children}
</UIGlobal_LayoutTamplate>
</>
);
}

View File

@@ -1,75 +0,0 @@
"use client";
import {
Paper,
Grid,
Center,
Title,
Divider,
Button,
Text,
Group,
FileButton,
FileInput,
Image,
AspectRatio,
Flex,
Stack,
Box,
} from "@mantine/core";
import { IconChevronRight, IconFileTypePdf } from "@tabler/icons-react";
import Link from "next/link";
import { useState } from "react";
import { MODEL_INVESTASI } from "../_lib/interface";
import { RouterInvestasi_OLD } from "@/app/lib/router_hipmi/router_investasi";
export default function EditProspektusInvestasi({
dataInvestasi,
}: {
dataInvestasi: MODEL_INVESTASI;
}) {
const [prospek, setProspek] = useState<MODEL_INVESTASI>(dataInvestasi);
return (
<>
{/* <pre>{JSON.stringify(prospek, null, 2)}</pre> */}
<Stack>
{prospek.ProspektusInvestasi != null ? (
<Link
href={RouterInvestasi_OLD.api_file_prospektus + `${prospek.ProspektusInvestasi.id}`}
target="_blank"
style={{ textDecorationLine: "none" }}
>
<Paper w={"100%"} bg={"gray"} mb={"md"}>
<Grid
align="center"
justify="center"
h={50}
px={"sm"}
onClick={() => ""}
>
<Grid.Col span={11}>
<Group>
{/* <IconFileTypePdf /> */}
<Text lineClamp={1}>Prospektus_{prospek.title}</Text>
</Group>
</Grid.Col>
<Grid.Col span={1}>
<Center>
<IconChevronRight />
</Center>
</Grid.Col>
</Grid>
</Paper>
</Link>
) : (
<Center>
<Title order={4}>Tidak ada file</Title>
</Center>
)}
{/* <Divider my={"lg"} /> */}
</Stack>
</>
);
}

View File

@@ -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 EditProspektusInvestasi from "./edit_propektus/view";
import LayoutEditProspektusInvestasi from "./edit_propektus/layout";
import EditDokumenInvestasi from "./edit_dokumen/view"; import EditDokumenInvestasi from "./edit_dokumen/view";
import LayoutEditDokumenInvestasi from "./edit_dokumen/layout"; import LayoutEditDokumenInvestasi from "./edit_dokumen/layout";
import EditBeritaInvestasi from "./edit_berita/view"; import EditBeritaInvestasi from "./edit_berita/view";
@@ -58,8 +56,6 @@ export {
LayoutPortofolioInvestasi, LayoutPortofolioInvestasi,
EditIntroInvestasi, EditIntroInvestasi,
LayoutEditIntroInvestasi, LayoutEditIntroInvestasi,
EditProspektusInvestasi,
LayoutEditProspektusInvestasi,
EditDokumenInvestasi, EditDokumenInvestasi,
LayoutEditDokumenInvestasi, LayoutEditDokumenInvestasi,
EditBeritaInvestasi, EditBeritaInvestasi,

View File

@@ -2,22 +2,15 @@
import { import {
AspectRatio, AspectRatio,
Button,
Center, Center,
FileButton,
Image, Image,
Stack, Stack,
Text, Text,
TextInput, TextInput,
} from "@mantine/core"; } from "@mantine/core";
import { IconCamera } from "@tabler/icons-react";
import { useState } from "react"; import { useState } from "react";
import { MODEL_JOB } from "../model/interface"; import { MODEL_JOB } from "../model/interface";
import {
AccentColor,
MainColor,
} from "@/app_modules/_global/color/color_pallet";
import { import {
ComponentGlobal_BoxUploadImage, ComponentGlobal_BoxUploadImage,
ComponentGlobal_ButtonUploadFileImage, ComponentGlobal_ButtonUploadFileImage,

View File

@@ -3,13 +3,7 @@ import {
ComponentGlobal_BoxInformation, ComponentGlobal_BoxInformation,
ComponentGlobal_ButtonUploadFileImage, ComponentGlobal_ButtonUploadFileImage,
} from "@/app_modules/_global/component"; } from "@/app_modules/_global/component";
import { import { Avatar, Box, Center, Paper, Stack } from "@mantine/core";
Avatar,
Box,
Center,
Paper,
Stack
} from "@mantine/core";
import { useState } from "react"; import { useState } from "react";
export default function Profile_ViewUploadFoto({ export default function Profile_ViewUploadFoto({
@@ -68,125 +62,6 @@ export default function Profile_ViewUploadFoto({
onSetImage={onSetImgPP} onSetImage={onSetImgPP}
/> />
</Center> </Center>
{/* <Center>
<FileButton
onChange={async (files: any | null) => {
try {
setLoadingButton(true);
const buffer = URL.createObjectURL(
new Blob([new Uint8Array(await files.arrayBuffer())])
);
// if (files.size > MAX_SIZE) {
// ComponentGlobal_NotifikasiPeringatan(
// PemberitahuanMaksimalFile
// );
// onSetImgPP(null);
// return;
// }
if (fotoProfileId != "") {
try {
const deleteFotoProfile = await funGlobal_DeleteFileById({
fileId: fotoProfileId,
dirId: DIRECTORY_ID.profile_foto,
});
if (!deleteFotoProfile.success) {
clientLogger.error(
"Client failed delete photo profile:" +
deleteFotoProfile.message
);
return;
}
if (deleteFotoProfile.success) {
onSetFotoProfileId("");
onSetImgPP(null);
const uploadPhoto = await funGlobal_UploadToStorage({
file: files,
dirId: DIRECTORY_ID.profile_foto,
});
if (!uploadPhoto.success) {
clientLogger.error(
"Client failed upload photo profile::" +
uploadPhoto.message
);
return;
}
if (uploadPhoto.success) {
clientLogger.info(
"Client success upload foto profile"
);
onSetFotoProfileId(uploadPhoto.data.id);
onSetImgPP(buffer);
} else {
clientLogger.error(
"Client failed upload foto:",
uploadPhoto.message
);
ComponentGlobal_NotifikasiPeringatan(
"Gagal upload foto profile"
);
}
}
} catch (error) {
clientLogger.error("Client error upload foto:", error);
}
} else {
try {
const uploadPhoto = await funGlobal_UploadToStorage({
file: files,
dirId: DIRECTORY_ID.profile_foto,
});
if (uploadPhoto.success) {
clientLogger.info("Client success upload foto profile");
onSetFotoProfileId(uploadPhoto.data.id);
onSetImgPP(buffer);
} else {
clientLogger.error(
"Client failed upload foto:",
uploadPhoto.message
);
ComponentGlobal_NotifikasiPeringatan(
"Gagal upload foto profile"
);
}
} catch (error) {
clientLogger.error("Client error upload foto:", error);
}
}
} catch (error) {
clientLogger.error("Client error upload foto:", error);
} finally {
setLoadingButton(false);
}
}}
accept="image/png,image/jpeg"
>
{(props) => (
<Button
{...props}
loading={isLoadingButton}
loaderPosition="center"
radius={"xl"}
leftIcon={<IconCamera />}
bg={MainColor.yellow}
color="yellow"
c={"black"}
>
Upload
</Button>
)}
</FileButton>
</Center> */}
</Stack> </Stack>
</Box> </Box>
</> </>

View File

@@ -29,12 +29,13 @@ const middlewareConfig: MiddlewareConfig = {
"/api/collaboration/*", "/api/collaboration/*",
"/api/notifikasi/*", "/api/notifikasi/*",
"/api/logs/*", "/api/logs/*",
// "/api/image/*",
"/api/job/*", "/api/job/*",
"/api/auth/*", "/api/auth/*",
"/api/origin-url", "/api/origin-url",
// "/api/user",
"/api/event/*", "/api/event/*",
// "/api/image/*",
// "/api/user",
// "/api/new/*",
// Akses awal // Akses awal
"/api/get-cookie", "/api/get-cookie",
"/api/user/activation", "/api/user/activation",

44
xhtml/index.html Normal file
View File

@@ -0,0 +1,44 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<!-- <img
id="pdf"
src="https://wibu-storage.wibudev.com/api/pdf-to-image?url=https://pdfobject.com/pdf/sample.pdf"
alt="pdf"
/> -->
<div id="pdfs"></div>
</body>
<script type="module">
(async () => {
const imagePdf = document.getElementById("pdf");
const pdfs = document.getElementById("pdfs");
const token =
"eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjp7ImlkIjoiY20wdXIxeXh3MDAwMDU2bnNqbHI2MTg3cCIsIm5hbWUiOiJiYWdhcyIsImVtYWlsIjoiYmFnYXNAZ21haWwuY29tIn0sImlhdCI6MTcyNTg3MTAzNiwiZXhwIjo0ODgxNjMxMDM2fQ.wFQLcrJj66wFeqIMYk2esMx3ULaHK6RFxkiToaLCuko";
const res = await fetch(
"https://wibu-storage.wibudev.com/api/pdf-to-image?url=https://wibu-storage.wibudev.com/api/files/cm5jgzg7d001dxpugxseb2ua0",
{
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
}
);
const jsonData = await res.json();
// console.log(JSON.stringify(jsonData.pages, null, 2));
// imagePdf.src = jsonData.pages[0].imageUrl;
for (let index = 0; index < jsonData.pages.length; index++) {
const element = jsonData.pages[index];
const img = document.createElement("img");
img.src = element.imageUrl;
pdfs.appendChild(img);
}
})();
</script>
</html>