Merge branch 'join' into Nico/27-feb-25
This commit is contained in:
52
src/app_modules/_global/lib/api_fetch_global.ts
Normal file
52
src/app_modules/_global/lib/api_fetch_global.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
export { apiGetPdfToImage };
|
||||
|
||||
export interface PageData {
|
||||
imageUrl: string;
|
||||
pageNumber: number;
|
||||
}
|
||||
|
||||
interface PdfResponse {
|
||||
pages: PageData[];
|
||||
totalPages: number;
|
||||
}
|
||||
const apiGetPdfToImage = async ({ id }: { id: string }) => {
|
||||
try {
|
||||
// Fetch token from cookie
|
||||
// const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
// if (!token) {
|
||||
// console.error("No token found");
|
||||
// return null;
|
||||
// }
|
||||
|
||||
const token =
|
||||
"eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjp7ImlkIjoiY20wdXIxeXh3MDAwMDU2bnNqbHI2MTg3cCIsIm5hbWUiOiJiYWdhcyIsImVtYWlsIjoiYmFnYXNAZ21haWwuY29tIn0sImlhdCI6MTcyNTg3MTAzNiwiZXhwIjo0ODgxNjMxMDM2fQ.wFQLcrJj66wFeqIMYk2esMx3ULaHK6RFxkiToaLCuko";
|
||||
|
||||
// Anda bisa menggunakan prospektusId di URL jika diperlukan
|
||||
const pdfUrl = `https://wibu-storage.wibudev.com/api/pdf-to-image?url=https://wibu-storage.wibudev.com/api/files/${id}`;
|
||||
|
||||
const response = await fetch(pdfUrl, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
// Check if the response is OK
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => null);
|
||||
console.error(
|
||||
"Error get admin contact:",
|
||||
errorData?.message || "Unknown error"
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const jsonData: PdfResponse = await response.json();
|
||||
return jsonData;
|
||||
} catch (error) {
|
||||
console.error("Error get admin contact:", error);
|
||||
throw error; // Re-throw the error to handle it in the calling function
|
||||
}
|
||||
};
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
Group,
|
||||
Button,
|
||||
Text,
|
||||
Box,
|
||||
} from "@mantine/core";
|
||||
import { IconFileTypePdf } from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
@@ -73,7 +74,7 @@ export function ComponentAdminInvestasi_UIDetailFile({
|
||||
<Text>-</Text>
|
||||
) : (
|
||||
listDokumen.map((e: MODEL_INVESTASI_DOKUMEN) => (
|
||||
<Paper key={e.id}>
|
||||
<Box key={e.id}>
|
||||
<Group>
|
||||
<IconFileTypePdf />
|
||||
<Text>{e.title}</Text>
|
||||
@@ -84,7 +85,7 @@ export function ComponentAdminInvestasi_UIDetailFile({
|
||||
<Button radius={50}>Lihat</Button>
|
||||
</Link>
|
||||
</Group>
|
||||
</Paper>
|
||||
</Box>
|
||||
))
|
||||
)}
|
||||
</Stack>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import { IRealtimeData } from "@/lib/global_state";
|
||||
import { MainColor } from "@/app_modules/_global/color";
|
||||
import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||
import getOneInvestasiById from "@/app_modules/investasi/fun/get_one_investasi_by_id";
|
||||
import { Button, Group, SimpleGrid, Stack, Loader } from "@mantine/core";
|
||||
import { IRealtimeData } from "@/lib/global_state";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { Button, Group, SimpleGrid, Stack } from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import _ from "lodash";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
@@ -20,12 +20,11 @@ import adminNotifikasi_funCreateToUser from "../../notifikasi/fun/create/fun_cre
|
||||
import { ComponentAdminInvestasi_DetailDataAuthor } from "../_component/detail_data_author";
|
||||
import { ComponentAdminInvestasi_DetailData } from "../_component/detail_data_investasi";
|
||||
import { ComponentAdminInvestasi_DetailGambar } from "../_component/detail_gambar_investasi";
|
||||
import SkeletonAdminInvestasi from "../_component/skeleton_admin_investasi";
|
||||
import { ComponentAdminInvestasi_UIDetailFile } from "../_component/ui_detail_file";
|
||||
import { apiGetAdminInvestasiById } from "../_lib/api_fetch_admin_investasi";
|
||||
import { adminInvestasi_funEditStatusPublishById } from "../fun/edit/fun_status_publish_by_id";
|
||||
import Admin_funRejectInvestasi from "../fun/fun_reject_investasi";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { apiGetAdminInvestasiById } from "../_lib/api_fetch_admin_investasi";
|
||||
import SkeletonAdminInvestasi from "../_component/skeleton_admin_investasi";
|
||||
|
||||
export default function AdminInvestasi_DetailReview() {
|
||||
const params = useParams<{ id: string }>();
|
||||
@@ -45,19 +44,19 @@ export default function AdminInvestasi_DetailReview() {
|
||||
}, []);
|
||||
|
||||
const loadInitialData = async () => {
|
||||
try {
|
||||
const response = await apiGetAdminInvestasiById({
|
||||
id: params.id,
|
||||
})
|
||||
try {
|
||||
const response = await apiGetAdminInvestasiById({
|
||||
id: params.id,
|
||||
});
|
||||
|
||||
if (response?.success && response?.data) {
|
||||
setData(response.data);
|
||||
if (response?.success && response?.data) {
|
||||
setData(response.data);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Invalid data format recieved:", error);
|
||||
setData(null);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Invalid data format recieved:", error);
|
||||
setData(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function cekStatusPublish() {
|
||||
if (data?.MasterStatusInvestasi.id === "3") setPublish(false);
|
||||
@@ -72,98 +71,106 @@ export default function AdminInvestasi_DetailReview() {
|
||||
if (_.isEmpty(body.catatan))
|
||||
return ComponentAdminGlobal_NotifikasiPeringatan("Lengkapi alasan");
|
||||
|
||||
const res = await Admin_funRejectInvestasi(body);
|
||||
if (res.status === 200) {
|
||||
try {
|
||||
setIsLoadingReject(true);
|
||||
const res = await Admin_funRejectInvestasi(body);
|
||||
if (res.status === 200) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res.data?.id as string,
|
||||
userId: res.data?.authorId as string,
|
||||
pesan: res.data?.title as string,
|
||||
status: res.data?.MasterStatusInvestasi?.name as any,
|
||||
kategoriApp: "INVESTASI",
|
||||
title: "Investasi anda di tolak !",
|
||||
};
|
||||
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res.data?.id as string,
|
||||
userId: res.data?.authorId as string,
|
||||
pesan: res.data?.title as string,
|
||||
status: res.data?.MasterStatusInvestasi?.name as any,
|
||||
kategoriApp: "INVESTASI",
|
||||
title: "Investasi anda di tolak !",
|
||||
};
|
||||
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
}
|
||||
|
||||
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
||||
router.back();
|
||||
setOpenModalReject(false);
|
||||
setIsLoadingReject(false);
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||
setOpenModalReject(false);
|
||||
setIsLoadingReject(false);
|
||||
}
|
||||
|
||||
// const loadData = await getOneInvestasiById(data?.id);
|
||||
// setData(loadData as any);
|
||||
|
||||
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
||||
router.back();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
setOpenModalReject(false);
|
||||
setIsLoadingReject(false);
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||
setOpenModalReject(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function onPublish() {
|
||||
const res = await adminInvestasi_funEditStatusPublishById({
|
||||
investasiId: data?.id as any,
|
||||
statusId: "1",
|
||||
progesInvestasiId: "1",
|
||||
});
|
||||
if (res.status === 200) {
|
||||
try {
|
||||
setIsLoadingPublish(true);
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res.data?.id as string,
|
||||
userId: res.data?.authorId as any,
|
||||
pesan: res.data?.title as any,
|
||||
status: res.data?.MasterStatusInvestasi?.name as any,
|
||||
kategoriApp: "INVESTASI",
|
||||
title: "Investasi publish",
|
||||
};
|
||||
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotifikasi as any,
|
||||
const res = await adminInvestasi_funEditStatusPublishById({
|
||||
investasiId: data?.id as any,
|
||||
statusId: "1",
|
||||
progesInvestasiId: "1",
|
||||
});
|
||||
if (res.status === 200) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res.data?.id as string,
|
||||
userId: res.data?.authorId as any,
|
||||
pesan: res.data?.title as any,
|
||||
status: res.data?.MasterStatusInvestasi?.name as any,
|
||||
kategoriApp: "INVESTASI",
|
||||
title: "Investasi publish",
|
||||
};
|
||||
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
const loadData = await getOneInvestasiById(data?.id as any);
|
||||
setData(loadData as any);
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
ComponentAdminGlobal_NotifikasiBerhasil("Proyek Investasi Di Publish");
|
||||
ComponentAdminGlobal_NotifikasiBerhasil(
|
||||
"Proyek Investasi Di Publish"
|
||||
);
|
||||
setOpenModalPublish(false);
|
||||
setIsLoadingPublish(false);
|
||||
router.back();
|
||||
// router.push(RouterAdminInvestasi_OLD.table_status_review);
|
||||
}
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||
setOpenModalPublish(false);
|
||||
setIsLoadingPublish(false);
|
||||
router.back();
|
||||
// router.push(RouterAdminInvestasi_OLD.table_status_review);
|
||||
}
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
setOpenModalPublish(false);
|
||||
setIsLoadingPublish(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return <SkeletonAdminInvestasi/>
|
||||
return <SkeletonAdminInvestasi />;
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack px={"lg"}>
|
||||
@@ -173,8 +180,6 @@ export default function AdminInvestasi_DetailReview() {
|
||||
{data?.masterStatusInvestasiId === "2" ? (
|
||||
<Group>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoadingPublish}
|
||||
radius={"xl"}
|
||||
color="green"
|
||||
onClick={() => setOpenModalPublish(true)}
|
||||
@@ -204,7 +209,9 @@ export default function AdminInvestasi_DetailReview() {
|
||||
]}
|
||||
>
|
||||
{/* Data Author */}
|
||||
<ComponentAdminInvestasi_DetailDataAuthor data={data?.author as any} />
|
||||
<ComponentAdminInvestasi_DetailDataAuthor
|
||||
data={data?.author as any}
|
||||
/>
|
||||
|
||||
{/* Data Foto */}
|
||||
<ComponentAdminInvestasi_DetailGambar imagesId={data?.imageId} />
|
||||
@@ -257,8 +264,8 @@ export default function AdminInvestasi_DetailReview() {
|
||||
buttonKanan={
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
style={{ backgroundColor: MainColor.green }}
|
||||
loading={isLoadingPublish}
|
||||
style={{ backgroundColor: MainColor.green }}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
onPublish();
|
||||
|
||||
@@ -55,12 +55,8 @@ export default function MainCrowd() {
|
||||
}}
|
||||
onClick={() => {
|
||||
setLoadingInv(true);
|
||||
router.push(RouterCrowd.investasi);
|
||||
router.push(RouterCrowd.investasi, { scroll: false });
|
||||
setChangeColor(0);
|
||||
// ComponentGlobal_NotifikasiPeringatan(
|
||||
// "Sedang Perbaikan",
|
||||
// 3000
|
||||
// );
|
||||
}}
|
||||
>
|
||||
<Grid>
|
||||
@@ -99,7 +95,7 @@ export default function MainCrowd() {
|
||||
}}
|
||||
onClick={() => {
|
||||
setLoadingDon(true);
|
||||
router.push(RouterCrowd.donasi);
|
||||
router.push(RouterCrowd.donasi, { scroll: false });
|
||||
setDonasiHotMenu(0);
|
||||
// ComponentGlobal_NotifikasiPeringatan(
|
||||
// "Sementara ini sedang maintenance",
|
||||
|
||||
@@ -1,17 +1,73 @@
|
||||
export const apiGetDataHome = async ({ path }: { path?: string }) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
// Fetch token from cookie
|
||||
try {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) {
|
||||
console.error("No token found");
|
||||
return null;
|
||||
}
|
||||
|
||||
const response = await fetch(`/api/new/home${path ? path : ""}`, {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
const response = await fetch(`/api/new/home${path ? path : ""}`, {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) return null;
|
||||
const data: Record<string, any> = await response.json();
|
||||
return data;
|
||||
// if (!response.ok) return null;
|
||||
// const data: Record<string, any> = await response.json();
|
||||
// return data;
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => null);
|
||||
console.error(
|
||||
"Error get admin contact:",
|
||||
errorData?.message || "Unknown error"
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error("Error get admin contact:", error);
|
||||
throw error; // Re-throw the error to handle it in the calling function
|
||||
}
|
||||
};
|
||||
|
||||
export const apiGetNotifikasiHome = async () => {
|
||||
// Fetch token from cookie
|
||||
try {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) {
|
||||
console.error("No token found");
|
||||
return null;
|
||||
}
|
||||
|
||||
const response = await fetch(`/api/notifikasi/count`, {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => null);
|
||||
console.error(
|
||||
"Error get admin contact:",
|
||||
errorData?.message || "Unknown error"
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error("Error get admin contact:", error);
|
||||
throw error; // Re-throw the error to handle it in the calling function
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
"use client";
|
||||
import { API_RouteNotifikasi } from "@/lib/api_user_router/route_api_notifikasi";
|
||||
import { gs_count_ntf, gs_user_ntf } from "@/lib/global_state";
|
||||
import global_limit from "@/lib/limit";
|
||||
import { RouterProfile } from "@/lib/router_hipmi/router_katalog";
|
||||
@@ -18,7 +17,7 @@ import UIGlobal_LayoutTamplate from "../_global/ui/ui_layout_tamplate";
|
||||
import { gs_notifikasi_kategori_app } from "../notifikasi/lib";
|
||||
import BodyHome from "./component/body_home";
|
||||
import FooterHome from "./component/footer_home";
|
||||
import { apiGetDataHome } from "./fun/get/api_home";
|
||||
import { apiGetDataHome, apiGetNotifikasiHome } from "./fun/get/api_home";
|
||||
|
||||
export default function HomeViewNew() {
|
||||
const [countNtf, setCountNtf] = useAtom(gs_count_ntf);
|
||||
@@ -53,9 +52,10 @@ export default function HomeViewNew() {
|
||||
|
||||
async function onLoadNotifikasi() {
|
||||
try {
|
||||
const loadNotif = await fetch(API_RouteNotifikasi.get_count_by_id());
|
||||
const data = await loadNotif.json().then((res) => res.data);
|
||||
setCountNtf(data);
|
||||
const response = await apiGetNotifikasiHome();
|
||||
if (response && response.success) {
|
||||
setCountNtf(response.data);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error load notifikasi", error);
|
||||
}
|
||||
@@ -66,11 +66,14 @@ export default function HomeViewNew() {
|
||||
const response = await apiGetDataHome({
|
||||
path: "?cat=cek_profile",
|
||||
});
|
||||
if (response) {
|
||||
if (response && response.success) {
|
||||
setDataUser(response.data);
|
||||
} else {
|
||||
setDataUser(null);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get data home", error);
|
||||
setDataUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +86,7 @@ export default function HomeViewNew() {
|
||||
customButtonLeft={
|
||||
!dataUser || !countNtf ? (
|
||||
<ActionIcon radius={"xl"} variant={"transparent"}>
|
||||
<IconUserSearch color={MainColor.white} />
|
||||
<IconUserSearch color={"gray"} />
|
||||
</ActionIcon>
|
||||
) : dataUser?.profile === undefined ? (
|
||||
<ActionIcon
|
||||
@@ -110,7 +113,7 @@ export default function HomeViewNew() {
|
||||
customButtonRight={
|
||||
!dataUser || !countNtf ? (
|
||||
<ActionIcon radius={"xl"} variant={"transparent"}>
|
||||
<IconBell color={MainColor.white} />
|
||||
<IconBell color={"gray"} />
|
||||
</ActionIcon>
|
||||
) : dataUser?.profile === undefined ? (
|
||||
<ActionIcon
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import { DIRECTORY_ID } from "@/lib";
|
||||
import { NEW_RouterInvestasi } from "@/lib/router_hipmi/router_investasi";
|
||||
import { MainColor } from "@/app_modules/_global/color";
|
||||
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
||||
import {
|
||||
@@ -10,26 +8,30 @@ import {
|
||||
ComponentGlobal_NotifikasiPeringatan,
|
||||
} from "@/app_modules/_global/notif_global";
|
||||
import { notifikasiToAdmin_funCreate } from "@/app_modules/notifikasi/fun";
|
||||
import { DIRECTORY_ID } from "@/lib";
|
||||
import { IRealtimeData } from "@/lib/global_state";
|
||||
import { NEW_RouterInvestasi } from "@/lib/router_hipmi/router_investasi";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { Button } from "@mantine/core";
|
||||
import { useAtom } from "jotai";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
import { investasi_funCreateNewInvestasi } from "../../_fun";
|
||||
import { gs_investas_menu, gs_investasi_status } from "../../g_state";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { IRealtimeData } from "@/lib/global_state";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
|
||||
export function Investasi_ComponentButtonCreateNewInvestasi({
|
||||
data,
|
||||
totalLembar,
|
||||
fileImage,
|
||||
filePdf,
|
||||
isMinimalTarget,
|
||||
}: {
|
||||
data: any;
|
||||
totalLembar: number;
|
||||
fileImage: File;
|
||||
filePdf: File;
|
||||
isMinimalTarget: boolean;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
@@ -114,7 +116,7 @@ export function Investasi_ComponentButtonCreateNewInvestasi({
|
||||
} catch (error) {
|
||||
setIsLoading(false);
|
||||
clientLogger.error("Error create new investasi", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -135,9 +137,8 @@ export function Investasi_ComponentButtonCreateNewInvestasi({
|
||||
data.periodeDevidenId === "" ||
|
||||
data.pembagianDevidenId === "" ||
|
||||
fileImage === null ||
|
||||
filePdf === null
|
||||
? true
|
||||
: false
|
||||
filePdf === null ||
|
||||
isMinimalTarget
|
||||
}
|
||||
radius={50}
|
||||
bg={MainColor.yellow}
|
||||
|
||||
@@ -22,10 +22,9 @@ export function Investasi_ComponentCardDaftarDocument({
|
||||
justify="center"
|
||||
h={"100%"}
|
||||
onClick={() => {
|
||||
router.push(
|
||||
NEW_RouterInvestasi.file_prospektus({ id: data.fileId }),
|
||||
{ scroll: false }
|
||||
);
|
||||
router.push(NEW_RouterInvestasi.file_dokumen({ id: data.fileId }), {
|
||||
scroll: false,
|
||||
});
|
||||
setVisible(true);
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -97,7 +97,7 @@ export function Investasi_ComponentCardRekapDocument({
|
||||
span={"auto"}
|
||||
onClick={() => {
|
||||
router.push(
|
||||
NEW_RouterInvestasi.file_prospektus({ id: data.fileId }),
|
||||
NEW_RouterInvestasi.file_dokumen({ id: data.fileId }),
|
||||
{ scroll: false }
|
||||
);
|
||||
setVisible(true);
|
||||
|
||||
@@ -1,109 +1,141 @@
|
||||
import { NEW_RouterInvestasi } from "@/lib/router_hipmi/router_investasi";
|
||||
import { Warna } from "@/lib/warna";
|
||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { ComponentGlobal_CardStyles, ComponentGlobal_LoadImageCustom } from "@/app_modules/_global/component";
|
||||
import {
|
||||
ComponentGlobal_CardStyles,
|
||||
ComponentGlobal_LoadImageCustom,
|
||||
} from "@/app_modules/_global/component";
|
||||
import { Box, Grid, Group, Progress, Stack, Text } from "@mantine/core";
|
||||
import { IconCircleCheck, IconXboxX } from "@tabler/icons-react";
|
||||
import moment from "moment";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { IDataInvestasiBursa } from "../../_lib/type_investasi";
|
||||
|
||||
export function Investasi_ComponentCardBerandaNew({ data }: { data: IDataInvestasiBursa; }) {
|
||||
const router = useRouter()
|
||||
export function Investasi_ComponentCardBerandaNew({
|
||||
data,
|
||||
}: {
|
||||
data: IDataInvestasiBursa;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
|
||||
return (
|
||||
<>
|
||||
<ComponentGlobal_CardStyles
|
||||
onClickHandler={() => {
|
||||
router.push(NEW_RouterInvestasi.detail_main({ id: data.id }), {
|
||||
scroll: false,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Stack>
|
||||
<Grid>
|
||||
<Grid.Col span={6}>
|
||||
<ComponentGlobal_LoadImageCustom
|
||||
height={100}
|
||||
fileId={data.imageId}
|
||||
/>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Stack>
|
||||
<Text c={MainColor.white} fw={"bold"} align="center" lineClamp={2}>
|
||||
{data?.title}
|
||||
</Text>
|
||||
return (
|
||||
<>
|
||||
<ComponentGlobal_CardStyles
|
||||
onClickHandler={() => {
|
||||
router.push(NEW_RouterInvestasi.detail_main({ id: data.id }), {
|
||||
scroll: false,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Stack>
|
||||
<Grid>
|
||||
<Grid.Col span={6}>
|
||||
<ComponentGlobal_LoadImageCustom
|
||||
height={100}
|
||||
fileId={data.imageId}
|
||||
/>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Stack>
|
||||
<Text
|
||||
c={MainColor.white}
|
||||
fw={"bold"}
|
||||
align="center"
|
||||
lineClamp={2}
|
||||
>
|
||||
{data?.title}
|
||||
</Text>
|
||||
|
||||
<Progress
|
||||
label={(+data?.progress).toFixed(2) + " %"}
|
||||
value={+data?.progress}
|
||||
color={MainColor.yellow}
|
||||
size="xl"
|
||||
radius="xl"
|
||||
style={{ backgroundColor: MainColor.white }}
|
||||
styles={{
|
||||
label: { color: MainColor.black },
|
||||
}}
|
||||
/>
|
||||
<Group position="right">
|
||||
{data?.progress === "100" ? (
|
||||
<Group position="right" spacing={"xs"}>
|
||||
<IconCircleCheck color="green" />
|
||||
<Text
|
||||
truncate
|
||||
variant="text"
|
||||
c={Warna.hijau_tua}
|
||||
sx={{ fontFamily: "Greycliff CF, sans-serif" }}
|
||||
ta="center"
|
||||
fz="md"
|
||||
fw={700}
|
||||
>
|
||||
Selesai
|
||||
</Text>
|
||||
</Group>
|
||||
) : (
|
||||
<Box>
|
||||
{+data?.pencarianInvestor -
|
||||
moment(new Date()).diff(
|
||||
new Date(data?.countDown),
|
||||
"days"
|
||||
) <=
|
||||
0 ? (
|
||||
<Group position="right" spacing={"xs"}>
|
||||
<IconXboxX color="red" />
|
||||
<Text
|
||||
truncate
|
||||
variant="text"
|
||||
c={Warna.merah}
|
||||
sx={{ fontFamily: "Greycliff CF, sans-serif" }}
|
||||
ta="center"
|
||||
fz="md"
|
||||
fw={700}
|
||||
>
|
||||
Waktu Habis
|
||||
</Text>
|
||||
</Group>
|
||||
) : (
|
||||
<Group position="right" spacing={"xs"}>
|
||||
<Text c={MainColor.white} truncate>Sisa waktu:</Text>
|
||||
<Text c={MainColor.white} truncate>
|
||||
{Number(data?.pencarianInvestor) -
|
||||
moment(new Date()).diff(
|
||||
new Date(data?.countDown),
|
||||
"days"
|
||||
)}
|
||||
</Text>
|
||||
<Text c={MainColor.white} truncate>Hari</Text>
|
||||
</Group>
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
<Progress
|
||||
label={
|
||||
data?.progress === "0"
|
||||
? +data?.progress + " %"
|
||||
: (+data?.progress).toFixed(2) + " %"
|
||||
}
|
||||
value={+data?.progress}
|
||||
color={MainColor.yellow}
|
||||
size="xl"
|
||||
radius="xl"
|
||||
style={{ backgroundColor: MainColor.white }}
|
||||
styles={{
|
||||
root: {
|
||||
position: "relative",
|
||||
},
|
||||
label: {
|
||||
color: MainColor.black,
|
||||
position: "absolute",
|
||||
left: "50%",
|
||||
top: "50%",
|
||||
transform: "translate(-50%, -50%)",
|
||||
textAlign: "center",
|
||||
paddingLeft: "30px",
|
||||
},
|
||||
}}
|
||||
/>
|
||||
|
||||
<Group position="right">
|
||||
{data?.progress === "100" ? (
|
||||
<Group position="right" spacing={"xs"}>
|
||||
<IconCircleCheck color="green" />
|
||||
<Text
|
||||
truncate
|
||||
variant="text"
|
||||
c={Warna.hijau_tua}
|
||||
sx={{ fontFamily: "Greycliff CF, sans-serif" }}
|
||||
ta="center"
|
||||
fz="md"
|
||||
fw={700}
|
||||
>
|
||||
Selesai
|
||||
</Text>
|
||||
</Group>
|
||||
) : (
|
||||
<Box>
|
||||
{+data?.pencarianInvestor -
|
||||
moment(new Date()).diff(
|
||||
new Date(data?.countDown),
|
||||
"days"
|
||||
) <=
|
||||
0 ? (
|
||||
<Group position="right" spacing={"xs"}>
|
||||
<IconXboxX color="red" />
|
||||
<Text
|
||||
truncate
|
||||
variant="text"
|
||||
c={Warna.merah}
|
||||
sx={{ fontFamily: "Greycliff CF, sans-serif" }}
|
||||
ta="center"
|
||||
fz="md"
|
||||
fw={700}
|
||||
>
|
||||
Waktu Habis
|
||||
</Text>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Stack>
|
||||
</ComponentGlobal_CardStyles>
|
||||
</>
|
||||
);
|
||||
) : (
|
||||
<Group position="right" spacing={"xs"}>
|
||||
<Text c={MainColor.white} truncate>
|
||||
Sisa waktu:
|
||||
</Text>
|
||||
<Text c={MainColor.white} truncate>
|
||||
{Number(data?.pencarianInvestor) -
|
||||
moment(new Date()).diff(
|
||||
new Date(data?.countDown),
|
||||
"days"
|
||||
)}
|
||||
</Text>
|
||||
<Text c={MainColor.white} truncate>
|
||||
Hari
|
||||
</Text>
|
||||
</Group>
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
</Group>
|
||||
</Stack>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Stack>
|
||||
</ComponentGlobal_CardStyles>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,31 +1,141 @@
|
||||
"use client";
|
||||
|
||||
import { APIs } from "@/lib";
|
||||
import { MainColor } from "@/app_modules/_global/color";
|
||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||
import {
|
||||
apiGetPdfToImage,
|
||||
PageData,
|
||||
} from "@/app_modules/_global/lib/api_fetch_global";
|
||||
import { UIGlobal_DrawerCustom } from "@/app_modules/_global/ui";
|
||||
import UIGlobal_LayoutHeaderTamplate from "@/app_modules/_global/ui/ui_header_tamplate";
|
||||
import UIGlobal_LayoutTamplate from "@/app_modules/_global/ui/ui_layout_tamplate";
|
||||
import { Box } from "@mantine/core";
|
||||
import { IconX } from "@tabler/icons-react";
|
||||
import dynamic from "next/dynamic";
|
||||
const PdfToImage = dynamic(
|
||||
() =>
|
||||
import("../../_view/file_view/view_file_viewer").then((mod) => mod.default),
|
||||
{ ssr: false }
|
||||
);
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { ActionIcon, Box, Stack, Text } from "@mantine/core";
|
||||
import { IconDotsVertical, IconDownload, IconX } from "@tabler/icons-react";
|
||||
import Image from "next/image";
|
||||
import { useParams } from "next/navigation";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
export function Investasi_UiFileViewDokumen() {
|
||||
const param = useParams<{ id: string }>();
|
||||
const dokumenId = param.id;
|
||||
|
||||
const [pdfPages, setPdfPages] = useState<PageData[] | null>(null);
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const pdfsRef = useRef<HTMLDivElement>(null);
|
||||
const [isOpen, setOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchPdfData = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await apiGetPdfToImage({ id: dokumenId });
|
||||
|
||||
if (response) {
|
||||
setPdfPages(response.pages as any);
|
||||
setLoading(false);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Error fetching PDF:", err);
|
||||
setError(err instanceof Error ? err.message : "Unknown error occurred");
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchPdfData();
|
||||
}, [dokumenId]);
|
||||
|
||||
const handleDownloadFromAPI = async () => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`https://wibu-storage.wibudev.com/api/files/${dokumenId}`
|
||||
);
|
||||
const blob = await response.blob(); // Konversi respons ke Blob
|
||||
const url = window.URL.createObjectURL(blob); // Buat URL untuk Blob
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.download = `file-dokumen-${new Date()}.pdf`; // Nama file yang akan diunduh
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(url); // Bersihkan URL
|
||||
} catch (error) {
|
||||
console.error("Error downloading file:", error);
|
||||
}
|
||||
};
|
||||
|
||||
export function Investasi_UiFileViewDokumen({
|
||||
dokumenId,
|
||||
}: {
|
||||
dokumenId: string;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={<UIGlobal_LayoutHeaderTamplate title="" iconLeft={<IconX />} />}
|
||||
header={
|
||||
<UIGlobal_LayoutHeaderTamplate
|
||||
title="Pratinjau Dokumen"
|
||||
iconLeft={<IconX />}
|
||||
customButtonRight={
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => {
|
||||
setOpen(true);
|
||||
}}
|
||||
>
|
||||
<IconDotsVertical color="white" />
|
||||
</ActionIcon>
|
||||
}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Box mb={"lg"}>
|
||||
<PdfToImage id={dokumenId} path={APIs.GET_NO_PARAMS} />
|
||||
<Box mb="lg">
|
||||
{loading ? (
|
||||
<CustomSkeleton height={"80vh"} width={"100%"} />
|
||||
) : error ? (
|
||||
<Stack>
|
||||
<ComponentGlobal_IsEmptyData text="Maaf, PDF mengalami error" />
|
||||
<ComponentGlobal_IsEmptyData text={error} />
|
||||
</Stack>
|
||||
) : (
|
||||
<div
|
||||
ref={pdfsRef}
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
{pdfPages?.map((page, index) => (
|
||||
<Image
|
||||
key={`page-${index}`}
|
||||
src={page.imageUrl}
|
||||
alt={`Page ${page.pageNumber}`}
|
||||
className="pdf-page"
|
||||
width={500} // Adjust width as needed
|
||||
height={707} // Adjust height as needed
|
||||
style={{ width: "100%", marginBottom: "10px" }}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Box>
|
||||
</UIGlobal_LayoutTamplate>
|
||||
|
||||
<UIGlobal_DrawerCustom
|
||||
close={() => setOpen(false)}
|
||||
opened={isOpen}
|
||||
component={
|
||||
<Stack align="center" spacing={"xs"}>
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
c={MainColor.white}
|
||||
onClick={handleDownloadFromAPI}
|
||||
>
|
||||
<IconDownload />
|
||||
</ActionIcon>
|
||||
<Text fz={"sm"} align="center" color={MainColor.white}>
|
||||
Download
|
||||
</Text>
|
||||
</Stack>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,35 +1,141 @@
|
||||
"use client";
|
||||
|
||||
import { APIs } from "@/lib";
|
||||
import { RouterInvestasi_OLD } from "@/lib/router_hipmi/router_investasi";
|
||||
import { MainColor } from "@/app_modules/_global/color";
|
||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||
import {
|
||||
apiGetPdfToImage,
|
||||
PageData,
|
||||
} from "@/app_modules/_global/lib/api_fetch_global";
|
||||
import { UIGlobal_DrawerCustom } from "@/app_modules/_global/ui";
|
||||
import UIGlobal_LayoutHeaderTamplate from "@/app_modules/_global/ui/ui_header_tamplate";
|
||||
import UIGlobal_LayoutTamplate from "@/app_modules/_global/ui/ui_layout_tamplate";
|
||||
import { Box } from "@mantine/core";
|
||||
import { IconX } from "@tabler/icons-react";
|
||||
import dynamic from "next/dynamic";
|
||||
const PdfToImage = dynamic(
|
||||
() =>
|
||||
import("../../_view/file_view/view_file_viewer").then((mod) => mod.default),
|
||||
{ ssr: false }
|
||||
);
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { ActionIcon, Box, Stack, Text } from "@mantine/core";
|
||||
import { IconDotsVertical, IconDownload, IconX } from "@tabler/icons-react";
|
||||
import Image from "next/image";
|
||||
import { useParams } from "next/navigation";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
export function Investasi_UiFileViewProspektus() {
|
||||
const param = useParams<{ id: string }>();
|
||||
const prospektusId = param.id;
|
||||
|
||||
const [pdfPages, setPdfPages] = useState<PageData[] | null>(null);
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const pdfsRef = useRef<HTMLDivElement>(null);
|
||||
const [isOpen, setOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchPdfData = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await apiGetPdfToImage({ id: prospektusId });
|
||||
|
||||
if (response) {
|
||||
setPdfPages(response.pages as any);
|
||||
setLoading(false);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Error fetching PDF:", err);
|
||||
setError(err instanceof Error ? err.message : "Unknown error occurred");
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchPdfData();
|
||||
}, [prospektusId]);
|
||||
|
||||
const handleDownloadFromAPI = async () => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`https://wibu-storage.wibudev.com/api/files/${prospektusId}`
|
||||
);
|
||||
const blob = await response.blob(); // Konversi respons ke Blob
|
||||
const url = window.URL.createObjectURL(blob); // Buat URL untuk Blob
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.download = `file-portofolio-${new Date()}.pdf`; // Nama file yang akan diunduh
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(url); // Bersihkan URL
|
||||
} catch (error) {
|
||||
console.error("Error downloading file:", error);
|
||||
}
|
||||
};
|
||||
|
||||
export function Investasi_UiFileViewProspektus({
|
||||
pospektusId,
|
||||
}: {
|
||||
pospektusId: string;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={<UIGlobal_LayoutHeaderTamplate title="" iconLeft={<IconX />} />}
|
||||
>
|
||||
<Box mb={"lg"}>
|
||||
<PdfToImage
|
||||
id={pospektusId}
|
||||
path={APIs.GET_NO_PARAMS}
|
||||
header={
|
||||
<UIGlobal_LayoutHeaderTamplate
|
||||
title="Pratinjau Prospektus"
|
||||
iconLeft={<IconX />}
|
||||
customButtonRight={
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => {
|
||||
setOpen(true);
|
||||
}}
|
||||
>
|
||||
<IconDotsVertical color="white" />
|
||||
</ActionIcon>
|
||||
}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Box mb="lg">
|
||||
{loading ? (
|
||||
<CustomSkeleton height={"80vh"} width={"100%"} />
|
||||
) : error ? (
|
||||
<Stack>
|
||||
<ComponentGlobal_IsEmptyData text="Maaf, PDF mengalami error" />
|
||||
<ComponentGlobal_IsEmptyData text={error} />
|
||||
</Stack>
|
||||
) : (
|
||||
<div
|
||||
ref={pdfsRef}
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
{pdfPages?.map((page, index) => (
|
||||
<Image
|
||||
key={`page-${index}`}
|
||||
src={page.imageUrl}
|
||||
alt={`Page ${page.pageNumber}`}
|
||||
className="pdf-page"
|
||||
width={500} // Adjust width as needed
|
||||
height={707} // Adjust height as needed
|
||||
style={{ width: "100%", marginBottom: "10px" }}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Box>
|
||||
</UIGlobal_LayoutTamplate>
|
||||
|
||||
<UIGlobal_DrawerCustom
|
||||
close={() => setOpen(false)}
|
||||
opened={isOpen}
|
||||
component={
|
||||
<Stack align="center" spacing={"xs"}>
|
||||
<ActionIcon
|
||||
onClick={handleDownloadFromAPI}
|
||||
variant="transparent"
|
||||
c={MainColor.white}
|
||||
>
|
||||
<IconDownload />
|
||||
</ActionIcon>
|
||||
<Text fz={"sm"} align="center" color={MainColor.white}>
|
||||
Download
|
||||
</Text>
|
||||
</Stack>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
"use client";
|
||||
import { RouterInvestasi_OLD } from "@/lib/router_hipmi/router_investasi";
|
||||
import ComponentGlobal_CreateButton from "@/app_modules/_global/component/button_create";
|
||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import { gs_investasiTriggerBeranda } from "@/lib/global_state";
|
||||
import { RouterInvestasi_OLD } from "@/lib/router_hipmi/router_investasi";
|
||||
import { Box, Center } from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { useAtom } from "jotai";
|
||||
import _ from "lodash";
|
||||
import { ScrollOnly } from "next-scroll-loader";
|
||||
import { useState } from "react";
|
||||
@@ -14,8 +15,6 @@ import { Investasi_ComponentCardBerandaNew } from "../../_component/main/com_car
|
||||
import { apiGetAllInvestasi } from "../../_lib/api_interface";
|
||||
import { IDataInvestasiBursa } from "../../_lib/type_investasi";
|
||||
import SkeletonInvestasiBursa from "./skeleton_beranda";
|
||||
import { useAtom } from "jotai";
|
||||
import { gs_investasiTriggerBeranda } from "@/lib/global_state";
|
||||
|
||||
export function Investasi_ViewBerandaNew() {
|
||||
const [data, setData] = useState<IDataInvestasiBursa[]>([]);
|
||||
@@ -86,7 +85,7 @@ export function Investasi_ViewBerandaNew() {
|
||||
const loadData = await apiGetAllInvestasi(
|
||||
`?cat=bursa&page=${pageNew}`
|
||||
);
|
||||
setActivePage((val) => val + 1);
|
||||
setActivePage(pageNew);
|
||||
|
||||
return loadData.data as any;
|
||||
}}
|
||||
|
||||
@@ -1,396 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import {
|
||||
ComponentGlobal_BoxInformation,
|
||||
ComponentGlobal_BoxUploadImage,
|
||||
ComponentGlobal_CardStyles,
|
||||
} from "@/app_modules/_global/component";
|
||||
import { MODEL_DEFAULT_MASTER_OLD } from "@/app_modules/model_global/model_default_master";
|
||||
import {
|
||||
AspectRatio,
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
FileButton,
|
||||
Grid,
|
||||
Group,
|
||||
Image,
|
||||
Select,
|
||||
Stack,
|
||||
Text,
|
||||
TextInput,
|
||||
} from "@mantine/core";
|
||||
import {
|
||||
IconCamera,
|
||||
IconCircleCheck,
|
||||
IconFileTypePdf,
|
||||
IconPdf,
|
||||
IconUpload,
|
||||
} from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { useState } from "react";
|
||||
import { Investasi_ComponentButtonCreateNewInvestasi } from "../_component";
|
||||
|
||||
export default function InvestasiCreate({
|
||||
pencarianInvestor,
|
||||
periodeDeviden,
|
||||
pembagianDeviden,
|
||||
}: {
|
||||
pencarianInvestor: MODEL_DEFAULT_MASTER_OLD[];
|
||||
periodeDeviden: MODEL_DEFAULT_MASTER_OLD[];
|
||||
pembagianDeviden: MODEL_DEFAULT_MASTER_OLD[];
|
||||
}) {
|
||||
const [fileImage, setFileImage] = useState<File | null>(null);
|
||||
const [img, setImg] = useState<any | null>();
|
||||
const [filePdf, setFilePdf] = useState<File | null>(null);
|
||||
const [fPdf, setFPdf] = useState<any | null>(null);
|
||||
const [totalLembar, setTotalLembar] = useState(0);
|
||||
|
||||
const [value, setValue] = useState({
|
||||
title: "",
|
||||
targetDana: 0,
|
||||
hargaLembar: 0,
|
||||
roi: 0,
|
||||
pencarianInvestorId: "",
|
||||
periodeDevidenId: "",
|
||||
pembagianDevidenId: "",
|
||||
});
|
||||
const [target, setTarget] = useState("");
|
||||
const [harga, setHarga] = useState("");
|
||||
|
||||
async function onTotalLembar({
|
||||
target,
|
||||
harga,
|
||||
}: {
|
||||
target?: number | any;
|
||||
harga?: number | any;
|
||||
}) {
|
||||
if (target !== 0 && harga !== 0) {
|
||||
const hasil: any = target / harga;
|
||||
setTotalLembar(_.floor(hasil === Infinity ? 0 : hasil));
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack px={"xs"} spacing={40}>
|
||||
{/* Upload Image */}
|
||||
<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} mah={265} mx={"auto"}>
|
||||
<Image
|
||||
style={{ maxHeight: 250, margin: "auto", padding: "5px" }}
|
||||
alt="Foto"
|
||||
height={250}
|
||||
src={img}
|
||||
/>
|
||||
</AspectRatio>
|
||||
) : (
|
||||
<Stack justify="center" align="center" h={"100%"}>
|
||||
<IconUpload color="white" />
|
||||
<Text fz={10} fs={"italic"} c={"white"} fw={"bold"}>
|
||||
Upload Gambar
|
||||
</Text>
|
||||
</Stack>
|
||||
)}
|
||||
</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);
|
||||
setFileImage(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>
|
||||
|
||||
{/* Upload File */}
|
||||
<Stack spacing={"sm"}>
|
||||
<ComponentGlobal_BoxInformation informasi="File prospektus wajib untuk diupload, agar calon investor paham dengan prospek investasi yang akan anda jalankan kedepan !" />
|
||||
<ComponentGlobal_CardStyles marginBottom={"0px"}>
|
||||
{!filePdf ? (
|
||||
<Text lineClamp={1} align="center" c={"gray"}>
|
||||
Upload File Prospektus
|
||||
</Text>
|
||||
) : (
|
||||
<Grid align="center">
|
||||
<Grid.Col span={2}></Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text lineClamp={1} align="center">
|
||||
{filePdf.name}
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={2}>
|
||||
<Center>
|
||||
<IconCircleCheck color="green" />
|
||||
</Center>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
)}
|
||||
</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())])
|
||||
);
|
||||
setFPdf(buffer);
|
||||
setFilePdf(files);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{(props) => (
|
||||
<Button
|
||||
leftIcon={<IconFileTypePdf />}
|
||||
{...props}
|
||||
radius={"xl"}
|
||||
bg={MainColor.yellow}
|
||||
color="yellow"
|
||||
c={"black"}
|
||||
>
|
||||
Upload File
|
||||
</Button>
|
||||
)}
|
||||
</FileButton>
|
||||
</Group>
|
||||
</Stack>
|
||||
|
||||
<Stack>
|
||||
<TextInput
|
||||
styles={{
|
||||
label: {
|
||||
color: "white",
|
||||
},
|
||||
}}
|
||||
withAsterisk
|
||||
label="Judul Investasi"
|
||||
placeholder="Judul investasi"
|
||||
maxLength={100}
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
...value,
|
||||
title: val.target.value,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
styles={{
|
||||
label: {
|
||||
color: "white",
|
||||
},
|
||||
}}
|
||||
icon={<Text fw={"bold"}>Rp.</Text>}
|
||||
min={0}
|
||||
withAsterisk
|
||||
label="Dana Dibutuhkan"
|
||||
placeholder="0"
|
||||
value={target}
|
||||
onChange={(val) => {
|
||||
// console.log(typeof 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: +value.hargaLembar,
|
||||
});
|
||||
|
||||
setTarget(targetNilai);
|
||||
setValue({
|
||||
...value,
|
||||
targetDana: +nilai,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
styles={{
|
||||
label: {
|
||||
color: "white",
|
||||
},
|
||||
}}
|
||||
icon={<Text fw={"bold"}>Rp.</Text>}
|
||||
min={0}
|
||||
withAsterisk
|
||||
label="Harga Per Lembar"
|
||||
placeholder="0"
|
||||
value={harga}
|
||||
onChange={(val) => {
|
||||
try {
|
||||
// console.log(typeof +val.currentTarget.value);
|
||||
|
||||
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: +value.targetDana,
|
||||
});
|
||||
|
||||
setHarga(targetNilai);
|
||||
setValue({
|
||||
...value,
|
||||
hargaLembar: +nilai,
|
||||
});
|
||||
} 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: "white",
|
||||
},
|
||||
}}
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
styles={{
|
||||
label: {
|
||||
color: "white",
|
||||
},
|
||||
}}
|
||||
rightSection={
|
||||
<Text fw={"bold"} c={"gray"}>
|
||||
%
|
||||
</Text>
|
||||
}
|
||||
withAsterisk
|
||||
type="number"
|
||||
label={"Rasio Keuntungan / ROI %"}
|
||||
placeholder="Masukan rasio keuntungan"
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
...value,
|
||||
roi: _.toNumber(val.target.value),
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
<Select
|
||||
styles={{
|
||||
label: {
|
||||
color: "white",
|
||||
},
|
||||
}}
|
||||
withAsterisk
|
||||
label="Pencarian Investor"
|
||||
placeholder="Pilih batas waktu"
|
||||
data={pencarianInvestor.map((e) => ({
|
||||
value: e.id,
|
||||
label: e.name + " " + "hari",
|
||||
}))}
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
...(value as any),
|
||||
pencarianInvestorId: val,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
<Select
|
||||
styles={{
|
||||
label: {
|
||||
color: "white",
|
||||
},
|
||||
}}
|
||||
withAsterisk
|
||||
label="Periode Deviden"
|
||||
placeholder="Pilih batas waktu"
|
||||
data={periodeDeviden.map((e) => ({ value: e.id, label: e.name }))}
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
...(value as any),
|
||||
periodeDevidenId: val,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
<Select
|
||||
styles={{
|
||||
label: {
|
||||
color: "white",
|
||||
},
|
||||
}}
|
||||
withAsterisk
|
||||
label="Pembagian Deviden"
|
||||
placeholder="Pilih batas waktu"
|
||||
data={pembagianDeviden.map((e) => ({
|
||||
value: e.id,
|
||||
label: e.name + " " + "bulan",
|
||||
}))}
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
...(value as any),
|
||||
pembagianDevidenId: val,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
<Investasi_ComponentButtonCreateNewInvestasi
|
||||
data={value}
|
||||
totalLembar={totalLembar}
|
||||
fileImage={fileImage as any}
|
||||
filePdf={filePdf as any}
|
||||
/>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -6,17 +6,11 @@ import {
|
||||
ComponentGlobal_ButtonUploadFileImage,
|
||||
ComponentGlobal_CardStyles,
|
||||
} from "@/app_modules/_global/component";
|
||||
import { MAX_SIZE } from "@/app_modules/_global/lib";
|
||||
import { PemberitahuanMaksimalFile } from "@/app_modules/_global/lib/max_size";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
import {
|
||||
AspectRatio,
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
FileButton,
|
||||
Grid,
|
||||
Group,
|
||||
Image,
|
||||
Loader,
|
||||
Select,
|
||||
@@ -26,7 +20,6 @@ import {
|
||||
} from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import {
|
||||
IconCamera,
|
||||
IconCircleCheck,
|
||||
IconFileTypePdf,
|
||||
IconPhoto,
|
||||
@@ -64,6 +57,7 @@ export default function InvestasiCreateNew() {
|
||||
|
||||
const [isLoadingImg, setIsLoadingImg] = useState(false);
|
||||
const [isLoadingPdf, setIsLoadingPdf] = useState(false);
|
||||
const [isMinimalTarget, setMinimalTarget] = useState(false);
|
||||
|
||||
async function onTotalLembar({
|
||||
target,
|
||||
@@ -162,48 +156,6 @@ export default function InvestasiCreateNew() {
|
||||
onSetImage={setImg}
|
||||
/>
|
||||
</Center>
|
||||
{/* <Group position="center">
|
||||
<FileButton
|
||||
onChange={async (files: any) => {
|
||||
try {
|
||||
setIsLoadingImg(true);
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
|
||||
if (files.size > MAX_SIZE) {
|
||||
ComponentGlobal_NotifikasiPeringatan(
|
||||
PemberitahuanMaksimalFile
|
||||
);
|
||||
setImg(null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
setImg(buffer);
|
||||
setFileImage(files);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
setIsLoadingImg(false);
|
||||
}
|
||||
}}
|
||||
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>
|
||||
|
||||
{/* Upload File */}
|
||||
@@ -244,48 +196,6 @@ export default function InvestasiCreateNew() {
|
||||
icon={<IconFileTypePdf size={20} />}
|
||||
/>
|
||||
</Center>
|
||||
{/* <Group position="center">
|
||||
<FileButton
|
||||
accept={"application/pdf"}
|
||||
onChange={async (files: any) => {
|
||||
try {
|
||||
setIsLoadingPdf(true);
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
|
||||
if (files.size > MAX_SIZE) {
|
||||
ComponentGlobal_NotifikasiPeringatan(
|
||||
PemberitahuanMaksimalFile
|
||||
);
|
||||
setFilePdf(null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
setFPdf(buffer);
|
||||
setFilePdf(files);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
setIsLoadingPdf(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{(props) => (
|
||||
<Button
|
||||
leftIcon={<IconFileTypePdf />}
|
||||
{...props}
|
||||
radius={"xl"}
|
||||
bg={MainColor.yellow}
|
||||
color="yellow"
|
||||
c={"black"}
|
||||
>
|
||||
Upload File
|
||||
</Button>
|
||||
)}
|
||||
</FileButton>
|
||||
</Group> */}
|
||||
</Stack>
|
||||
|
||||
<Stack>
|
||||
@@ -313,48 +223,62 @@ export default function InvestasiCreateNew() {
|
||||
}}
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
styles={{
|
||||
label: {
|
||||
color: MainColor.white,
|
||||
},
|
||||
required: {
|
||||
color: MainColor.red,
|
||||
},
|
||||
input: {
|
||||
backgroundColor: MainColor.white,
|
||||
},
|
||||
}}
|
||||
icon={<Text fw={"bold"}>Rp.</Text>}
|
||||
min={0}
|
||||
withAsterisk
|
||||
label="Dana Dibutuhkan"
|
||||
placeholder="0"
|
||||
value={target}
|
||||
onChange={(val) => {
|
||||
// console.log(typeof val)
|
||||
const match = val.currentTarget.value
|
||||
.replace(/\./g, "")
|
||||
.match(/^[0-9]+$/);
|
||||
<Stack>
|
||||
<TextInput
|
||||
styles={{
|
||||
label: {
|
||||
color: MainColor.white,
|
||||
},
|
||||
required: {
|
||||
color: MainColor.red,
|
||||
},
|
||||
input: {
|
||||
backgroundColor: MainColor.white,
|
||||
},
|
||||
}}
|
||||
icon={<Text fw={"bold"}>Rp.</Text>}
|
||||
min={0}
|
||||
withAsterisk
|
||||
label="Dana Dibutuhkan"
|
||||
placeholder="0"
|
||||
value={target}
|
||||
error={isMinimalTarget ? "Minimal target 10.000.000" : ""}
|
||||
onChange={(val) => {
|
||||
// console.log(typeof val)
|
||||
const match = val.currentTarget.value
|
||||
.replace(/\./g, "")
|
||||
.match(/^[0-9]+$/);
|
||||
|
||||
if (val.currentTarget.value === "") return setTarget(0 + "");
|
||||
if (!match?.[0]) return null;
|
||||
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);
|
||||
const nilai = val.currentTarget.value.replace(/\./g, "");
|
||||
const targetNilai = Intl.NumberFormat("id-ID").format(+nilai);
|
||||
|
||||
onTotalLembar({
|
||||
target: +nilai,
|
||||
harga: +value.hargaLembar,
|
||||
});
|
||||
// console.log("type nilai", typeof nilai);
|
||||
// console.log("nilai", nilai);
|
||||
// console.log("targetNilai", targetNilai);
|
||||
// console.log("type targetNilai", typeof targetNilai);
|
||||
|
||||
setTarget(targetNilai);
|
||||
setValue({
|
||||
...value,
|
||||
targetDana: +nilai,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
if (+nilai < 10000000) {
|
||||
setMinimalTarget(true);
|
||||
} else {
|
||||
setMinimalTarget(false);
|
||||
}
|
||||
|
||||
onTotalLembar({
|
||||
target: +nilai,
|
||||
harga: +value.hargaLembar,
|
||||
});
|
||||
|
||||
setTarget(targetNilai);
|
||||
setValue({
|
||||
...value,
|
||||
targetDana: +nilai,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
<TextInput
|
||||
styles={{
|
||||
@@ -551,6 +475,7 @@ export default function InvestasiCreateNew() {
|
||||
totalLembar={totalLembar}
|
||||
fileImage={fileImage as any}
|
||||
filePdf={filePdf as any}
|
||||
isMinimalTarget={isMinimalTarget}
|
||||
/>
|
||||
</Stack>
|
||||
</>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import InvestasiCreate from "./create/view";
|
||||
import InvestasiCreateNew from "./create/view_new";
|
||||
import InvestasiCreateLayout from "./create/layout";
|
||||
import DetailInvestasi from "./detail/view";
|
||||
@@ -46,7 +45,6 @@ import StatusPesananInvetsatsi from "./status_pesanan/view";
|
||||
import LayoutStatusPesananInvestasi from "./status_pesanan/layout";
|
||||
|
||||
export {
|
||||
InvestasiCreate,
|
||||
InvestasiCreateLayout,
|
||||
DetailInvestasi,
|
||||
LayoutDetailInvestasi,
|
||||
|
||||
@@ -118,18 +118,13 @@ export default function ComponentPortofolio_ButtonMoreNew({
|
||||
|
||||
return (
|
||||
<>
|
||||
{
|
||||
userLoginId === authorId && (
|
||||
<ActionIcon variant="transparent" onClick={() => setOpenDrawer(true)}>
|
||||
<IconDotsVertical color={MainColor.white} />
|
||||
</ActionIcon>
|
||||
)
|
||||
// : (
|
||||
// <ActionIcon disabled variant="transparent">
|
||||
// <CustomSkeleton h={20} w={20} radius={"100%"} />
|
||||
// </ActionIcon>
|
||||
// )
|
||||
}
|
||||
{userLoginId === authorId ? (
|
||||
<ActionIcon variant="transparent" onClick={() => setOpenDrawer(true)}>
|
||||
<IconDotsVertical color={MainColor.white} />
|
||||
</ActionIcon>
|
||||
) : (
|
||||
<ActionIcon disabled variant="transparent"></ActionIcon>
|
||||
)}
|
||||
|
||||
<UIGlobal_Drawer
|
||||
opened={openDrawer}
|
||||
|
||||
@@ -9,6 +9,5 @@ export async function Profile_getOneById(profileId: string) {
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -9,16 +9,39 @@ import { AspectRatio, Center, Image, Stack } from "@mantine/core";
|
||||
import { useState } from "react";
|
||||
import { Profile_ComponentButtonUpdateBackgroundProfile } from "../../_component";
|
||||
import { MODEL_PROFILE } from "../../model/interface";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { apiGetOneProfileById } from "../../lib/api_fetch_profile";
|
||||
import { useParams } from "next/navigation";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
|
||||
export default function Profile_UpdateFotoBackground({
|
||||
dataProfile,
|
||||
}: {
|
||||
dataProfile: MODEL_PROFILE;
|
||||
}) {
|
||||
const [profile, setProfile] = useState(dataProfile);
|
||||
export default function Profile_UpdateFotoBackground() {
|
||||
const param = useParams<{ id: string }>();
|
||||
const profileId = param.id;
|
||||
const [profile, setProfile] = useState<MODEL_PROFILE | null>(null);
|
||||
const [file, setFile] = useState<File | null>(null);
|
||||
const [image, setImage] = useState<any | null>(null);
|
||||
|
||||
useShallowEffect(() => {
|
||||
handleLoadData();
|
||||
}, []);
|
||||
|
||||
const handleLoadData = async () => {
|
||||
try {
|
||||
const response = await apiGetOneProfileById({ id: profileId });
|
||||
if (response && response.success) {
|
||||
setProfile(response.data);
|
||||
} else {
|
||||
setProfile(null);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("Error get profile", error);
|
||||
setProfile(null);
|
||||
}
|
||||
};
|
||||
|
||||
if (!profile)
|
||||
return <CustomSkeleton height={300} width={"100%"} radius={"md"} />;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack px={"xs"}>
|
||||
|
||||
@@ -9,16 +9,39 @@ import { AspectRatio, Center, Image, Stack } from "@mantine/core";
|
||||
import { useState } from "react";
|
||||
import { Profile_ComponentButtonUpdatePhotoProfile } from "../../_component";
|
||||
import { MODEL_PROFILE } from "../../model/interface";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { useParams } from "next/navigation";
|
||||
import { apiGetOneProfileById } from "../../lib/api_fetch_profile";
|
||||
|
||||
export default function UploadFotoProfile({
|
||||
dataProfile,
|
||||
}: {
|
||||
dataProfile: MODEL_PROFILE;
|
||||
}) {
|
||||
const [profile, setProfile] = useState(dataProfile);
|
||||
export default function UploadFotoProfile() {
|
||||
const param = useParams<{ id: string }>();
|
||||
const profileId = param.id;
|
||||
const [profile, setProfile] = useState<MODEL_PROFILE | null>(null);
|
||||
const [file, setFile] = useState<File | null>(null);
|
||||
const [image, setImage] = useState<any | null>(null);
|
||||
|
||||
useShallowEffect(() => {
|
||||
handleLoadData();
|
||||
}, []);
|
||||
|
||||
const handleLoadData = async () => {
|
||||
try {
|
||||
const response = await apiGetOneProfileById({ id: profileId });
|
||||
if (response && response.success) {
|
||||
setProfile(response.data);
|
||||
} else {
|
||||
setProfile(null);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("Error get profile", error);
|
||||
setProfile(null);
|
||||
}
|
||||
};
|
||||
|
||||
if (!profile)
|
||||
return <CustomSkeleton height={300} width={"100%"} radius={"md"} />;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack px={"xs"}>
|
||||
|
||||
Reference in New Issue
Block a user