Merge pull request #214 from bipproduction/investasi/notifikasi
Fix investasi
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
||||
|
||||
## [1.2.33](https://github.com/bipproduction/hipmi/compare/v1.2.32...v1.2.33) (2024-12-22)
|
||||
|
||||
## [1.2.32](https://github.com/bipproduction/hipmi/compare/v1.2.31...v1.2.32) (2024-12-19)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hipmi",
|
||||
"version": "1.2.32",
|
||||
"version": "1.2.33",
|
||||
"private": true,
|
||||
"prisma": {
|
||||
"seed": "npx tsx prisma/seed.ts --yes"
|
||||
|
||||
@@ -1,19 +1,8 @@
|
||||
import { InvestasiCreateNew } from "@/app_modules/investasi";
|
||||
|
||||
export default async function Page() {
|
||||
|
||||
// const pencarianInvestor = await getPencarianInvestor();
|
||||
// const periodeDeviden = await getPeriodeDeviden();
|
||||
// const pembagianDeviden = await getPembagianDeviden();
|
||||
// const statusInvestasi = await getStatusInvestasi();
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* <InvestasiCreate
|
||||
pencarianInvestor={pencarianInvestor as any}
|
||||
periodeDeviden={periodeDeviden as any}
|
||||
pembagianDeviden={pembagianDeviden as any}
|
||||
/> */}
|
||||
<InvestasiCreateNew />
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -59,3 +59,7 @@ export const gs_votingTiggerBeranda = atom<boolean>(false);
|
||||
// donasi
|
||||
export const gs_adminDonasi_triggerReview = atom<boolean>(false);
|
||||
export const gs_donasiTriggerBeranda = atom<boolean>(false);
|
||||
|
||||
// investasi
|
||||
export const gs_adminInvestasi_triggerReview = atom<boolean>(false);
|
||||
export const gs_investasiTriggerBeranda = atom<boolean>(false);
|
||||
@@ -7,10 +7,12 @@ import {
|
||||
gs_admin_ntf,
|
||||
gs_adminDonasi_triggerReview,
|
||||
gs_adminEvent_triggerReview,
|
||||
gs_adminInvestasi_triggerReview,
|
||||
gs_adminJob_triggerReview,
|
||||
gs_adminVoting_triggerReview,
|
||||
gs_donasiTriggerBeranda,
|
||||
gs_eventTriggerBeranda,
|
||||
gs_investasiTriggerBeranda,
|
||||
gs_jobTiggerBeranda,
|
||||
gs_realtimeData,
|
||||
gs_user_ntf,
|
||||
@@ -71,6 +73,14 @@ export default function RealtimeProvider({
|
||||
gs_donasiTriggerBeranda
|
||||
);
|
||||
|
||||
// INVESTASI
|
||||
const [isAdminInvestasi_TriggerReview, setIsAdminInvestasi_TriggerReview] =
|
||||
useAtom(gs_adminInvestasi_triggerReview);
|
||||
|
||||
const [isTriggerInvestasiBeranda, setIsTriggerInvestasiBeranda] = useAtom(
|
||||
gs_investasiTriggerBeranda
|
||||
);
|
||||
|
||||
useShallowEffect(() => {
|
||||
try {
|
||||
WibuRealtime.init({
|
||||
@@ -195,12 +205,32 @@ export default function RealtimeProvider({
|
||||
// ) {
|
||||
|
||||
// }
|
||||
|
||||
// ---------------------- DONASI ------------------------- //
|
||||
|
||||
// ---------------------- INVESTASI ------------------------- //
|
||||
|
||||
if (
|
||||
data.type == "trigger" &&
|
||||
data.pushNotificationTo == "ADMIN" &&
|
||||
data.dataMessage?.kategoriApp == "INVESTASI"
|
||||
) {
|
||||
setIsAdminInvestasi_TriggerReview(true);
|
||||
}
|
||||
|
||||
if (
|
||||
data.type == "trigger" &&
|
||||
data.pushNotificationTo == "USER" &&
|
||||
data.dataMessage?.kategoriApp == "INVESTASI" &&
|
||||
data.dataMessage.status == "Publish"
|
||||
) {
|
||||
setIsTriggerInvestasiBeranda(true);
|
||||
}
|
||||
|
||||
// ---------------------- INVESTASI ------------------------- //
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("Error!:", error);
|
||||
console.log("Error Realtime:", error);
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { funGlobal_DeleteFileById } from "./delete/fun_delete_file_by_id";
|
||||
import { funGlobal_UploadToStorage } from "./upload/fun_upload_to_storage";
|
||||
import { funValidasiUploadCreatedFile } from "./upload/fun_validasi_upload_created_file";
|
||||
|
||||
export { funGlobal_UploadToStorage };
|
||||
export { funGlobal_DeleteFileById };
|
||||
export { funValidasiUploadCreatedFile };
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { MAX_SIZE } from "../../lib";
|
||||
import { PemberitahuanMaksimalFile } from "../../lib/max_size";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "../../notif_global";
|
||||
import { funGlobal_DeleteFileById } from "../delete/fun_delete_file_by_id";
|
||||
import { funGlobal_UploadToStorage } from "./fun_upload_to_storage";
|
||||
|
||||
export async function funValidasiUploadCreatedFile({
|
||||
files,
|
||||
dirId,
|
||||
fileId,
|
||||
onSetFileId,
|
||||
onSetImageBuffer,
|
||||
}: {
|
||||
files: any | null;
|
||||
dirId: string;
|
||||
fileId: string;
|
||||
onSetFileId: (val: string) => void;
|
||||
onSetImageBuffer: (val: any | null) => void;
|
||||
}) {
|
||||
try {
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
|
||||
if (files.size > MAX_SIZE) {
|
||||
ComponentGlobal_NotifikasiPeringatan(PemberitahuanMaksimalFile);
|
||||
onSetImageBuffer(null);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fileId != "") {
|
||||
const deleteFotoProfile = await funGlobal_DeleteFileById({
|
||||
fileId: fileId,
|
||||
dirId: dirId,
|
||||
});
|
||||
|
||||
if (!deleteFotoProfile.success) {
|
||||
console.log(
|
||||
`Client failed delete ${dirId}:` + deleteFotoProfile.message
|
||||
);
|
||||
onSetImageBuffer(null);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (deleteFotoProfile.success) {
|
||||
onSetFileId("");
|
||||
onSetImageBuffer(null);
|
||||
|
||||
const uploadPhoto = await funGlobal_UploadToStorage({
|
||||
file: files,
|
||||
dirId: dirId,
|
||||
});
|
||||
|
||||
if (!uploadPhoto.success) {
|
||||
clientLogger.error(
|
||||
`Client failed upload ${dirId}:` + uploadPhoto.message
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (uploadPhoto.success) {
|
||||
clientLogger.info(`Client success upload ${dirId}`);
|
||||
onSetFileId("");
|
||||
onSetImageBuffer(buffer);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
clientLogger.error("Client failed upload foto:", uploadPhoto.message);
|
||||
ComponentGlobal_NotifikasiPeringatan(`Gagal upload ${dirId}`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const uploadPhoto = await funGlobal_UploadToStorage({
|
||||
file: files,
|
||||
dirId: dirId,
|
||||
});
|
||||
|
||||
if (!uploadPhoto.success) {
|
||||
clientLogger.error(
|
||||
`Client failed upload ${dirId}:` + uploadPhoto.message
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (uploadPhoto.success) {
|
||||
clientLogger.info(`Client success upload ${dirId}`);
|
||||
onSetFileId("");
|
||||
onSetImageBuffer(buffer);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
clientLogger.error("Client failed upload foto:", uploadPhoto.message);
|
||||
ComponentGlobal_NotifikasiPeringatan(`Gagal upload ${dirId}`);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,14 @@
|
||||
"use client";
|
||||
|
||||
import { IRealtimeData } from "@/app/lib/global_state";
|
||||
import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||
import getOneInvestasiById from "@/app_modules/investasi/fun/get_one_investasi_by_id";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import {
|
||||
Button,
|
||||
Group,
|
||||
SimpleGrid,
|
||||
Stack
|
||||
} from "@mantine/core";
|
||||
import { Button, Group, SimpleGrid, Stack } from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
import { Admin_ComponentModalReport } from "../../_admin_global/_component";
|
||||
import { ComponentAdminGlobal_NotifikasiBerhasil } from "../../_admin_global/admin_notifikasi/notifikasi_berhasil";
|
||||
import { ComponentAdminGlobal_NotifikasiGagal } from "../../_admin_global/admin_notifikasi/notifikasi_gagal";
|
||||
@@ -60,24 +56,25 @@ export default function AdminInvestasi_DetailReview({
|
||||
if (res.status === 200) {
|
||||
setIsLoadingReject(true);
|
||||
|
||||
const dataNotif = {
|
||||
appId: res.data?.id,
|
||||
userId: res.data?.authorId,
|
||||
pesan: res.data?.title,
|
||||
status: res.data?.MasterStatusInvestasi?.name,
|
||||
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: dataNotif as any,
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
mqtt_client.publish(
|
||||
"USER",
|
||||
JSON.stringify({ userId: res?.data?.authorId, count: 1 })
|
||||
);
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
}
|
||||
|
||||
const loadData = await getOneInvestasiById(data.id);
|
||||
@@ -100,8 +97,8 @@ export default function AdminInvestasi_DetailReview({
|
||||
progesInvestasiId: "1",
|
||||
});
|
||||
if (res.status === 200) {
|
||||
const dataNotif = {
|
||||
appId: res.data?.id,
|
||||
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,
|
||||
@@ -110,19 +107,21 @@ export default function AdminInvestasi_DetailReview({
|
||||
};
|
||||
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotif as any,
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
mqtt_client.publish(
|
||||
"USER",
|
||||
JSON.stringify({ userId: res?.data?.authorId, count: 1 })
|
||||
);
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
mqtt_client.publish(
|
||||
"Beranda_Investasi",
|
||||
JSON.stringify({ update: true })
|
||||
);
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
const loadData = await getOneInvestasiById(data.id);
|
||||
setData(loadData as any);
|
||||
@@ -216,8 +215,6 @@ export default function AdminInvestasi_DetailReview({
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
"use client";
|
||||
import { RouterAdminInvestasi } from "@/app/lib/router_admin/router_admin_investasi";
|
||||
import { gs_adminInvestasi_triggerReview } from "@/app/lib/global_state";
|
||||
import { RouterAdminInvestasi_OLD } from "@/app/lib/router_hipmi/router_admin";
|
||||
import { AccentColor } from "@/app_modules/_global/color";
|
||||
import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||
import {
|
||||
Badge,
|
||||
ActionIcon,
|
||||
Box,
|
||||
ScrollArea,
|
||||
Table,
|
||||
Tooltip,
|
||||
Stack,
|
||||
Group,
|
||||
Avatar,
|
||||
Text,
|
||||
Center,
|
||||
Affix,
|
||||
Button,
|
||||
Center,
|
||||
Group,
|
||||
Pagination,
|
||||
Paper,
|
||||
rem,
|
||||
ScrollArea,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
TextInput,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { IconChevronLeft, IconEdit, IconSearch } from "@tabler/icons-react";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { IconRefresh, IconSearch } from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
|
||||
import { adminInvestasi_funGetAllReview } from "../fun/get/get_all_review";
|
||||
import _ from "lodash";
|
||||
import ComponentAdminGlobal_IsEmptyData from "../../_admin_global/is_empty_data";
|
||||
import ComponentAdminGlobal_TampilanRupiahDonasi from "../../_admin_global/tampilan_rupiah";
|
||||
import { adminInvestasi_funGetAllReview } from "../fun/get/get_all_review";
|
||||
|
||||
export default function Admin_TableReviewInvestasi({
|
||||
dataInvestsi,
|
||||
@@ -53,6 +53,33 @@ function TableView({ listData }: { listData: any }) {
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
const [idData, setIdData] = useState("");
|
||||
|
||||
// Realtime
|
||||
const [isAdminInvestasi_TriggerReview, setIsAdminInvestasi_TriggerReview] =
|
||||
useAtom(gs_adminInvestasi_triggerReview);
|
||||
const [isShowReload, setIsShowReload] = useState(false);
|
||||
const [isLoadingReload, setLoadingReload] = useState(false);
|
||||
|
||||
useShallowEffect(() => {
|
||||
if (isAdminInvestasi_TriggerReview) {
|
||||
setIsShowReload(false);
|
||||
}
|
||||
}, [isAdminInvestasi_TriggerReview]);
|
||||
|
||||
useShallowEffect(() => {
|
||||
if (isAdminInvestasi_TriggerReview) {
|
||||
setIsShowReload(true);
|
||||
}
|
||||
}, [isAdminInvestasi_TriggerReview]);
|
||||
|
||||
async function onLoadData() {
|
||||
const loadData = await adminInvestasi_funGetAllReview({ page: 1 });
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
setLoadingReload(false);
|
||||
setIsShowReload(false);
|
||||
setIsAdminInvestasi_TriggerReview(false);
|
||||
}
|
||||
|
||||
async function onSearch(s: string) {
|
||||
setSearch(s);
|
||||
setActivePage(1);
|
||||
@@ -151,6 +178,30 @@ function TableView({ listData }: { listData: any }) {
|
||||
<ComponentAdminGlobal_IsEmptyData />
|
||||
) : (
|
||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
||||
{isShowReload && (
|
||||
<Paper bg={"red"} w={"50%"}>
|
||||
<Affix position={{ top: rem(200) }} w={"100%"}>
|
||||
<Center>
|
||||
<Button
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
border: `1px solid ${AccentColor.skyblue}`,
|
||||
}}
|
||||
bg={AccentColor.blue}
|
||||
loaderPosition="center"
|
||||
loading={isLoadingReload}
|
||||
radius={"xl"}
|
||||
opacity={0.8}
|
||||
onClick={() => onLoadData()}
|
||||
leftIcon={<IconRefresh />}
|
||||
>
|
||||
Update Data
|
||||
</Button>
|
||||
</Center>
|
||||
</Affix>
|
||||
</Paper>
|
||||
)}
|
||||
|
||||
<ScrollArea w={"100%"} h={"90%"} offsetScrollbars>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import _ from "lodash";
|
||||
|
||||
export async function admin_funInvestasiCheckStatus({ id }: { id: string }) {
|
||||
const data = await prisma.investasi.findUnique({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
select: {
|
||||
MasterStatusInvestasi: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!data)
|
||||
return { status: 400, message: "Id tidak ditemukan", statusName: "" };
|
||||
return {
|
||||
status: 200,
|
||||
message: "Id ditemukan",
|
||||
statusName: _.lowerCase(data.MasterStatusInvestasi?.name),
|
||||
};
|
||||
}
|
||||
@@ -1,43 +1,100 @@
|
||||
import { RouterAdminDonasi } from "@/app/lib/router_admin/router_admin_donasi";
|
||||
import { RouterAdminInvestasi } from "@/app/lib/router_admin/router_admin_investasi";
|
||||
import { RouterAdminDonasi_OLD } from "@/app/lib/router_hipmi/router_admin";
|
||||
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
||||
import _ from "lodash";
|
||||
import { ITypeStatusNotifikasi } from "@/app/lib/global_state";
|
||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||
import { ComponentAdminGlobal_NotifikasiPeringatan } from "../../_admin_global/admin_notifikasi/notifikasi_peringatan";
|
||||
import adminNotifikasi_countNotifikasi from "../fun/count/count_is_read";
|
||||
import { admin_funInvestasiCheckStatus } from "../fun/get/fun_investasi_check_status";
|
||||
import adminNotifikasi_getByUserId from "../fun/get/get_notifikasi_by_user_id";
|
||||
import adminNotifikasi_funUpdateIsReadById from "../fun/update/fun_update_is_read_by_id";
|
||||
import { IAdmin_ActiveChildId, IAdmin_ActivePage } from "./type_of_select_page";
|
||||
|
||||
export default async function adminNotifikasi_findRouterInvestasi({
|
||||
data,
|
||||
appId,
|
||||
notifikasiId,
|
||||
status,
|
||||
router,
|
||||
onLoadCountNotif,
|
||||
onLoadDataNotifikasi,
|
||||
onChangeNavbar,
|
||||
onToggleNavbar,
|
||||
}: {
|
||||
data: MODEL_NOTIFIKASI;
|
||||
appId: string;
|
||||
notifikasiId: string;
|
||||
status: ITypeStatusNotifikasi;
|
||||
router: AppRouterInstance;
|
||||
onChangeNavbar: (val: any) => void;
|
||||
onToggleNavbar: (val: any) => void;
|
||||
onLoadCountNotif: (val: any) => void;
|
||||
onLoadDataNotifikasi: (val: any) => void;
|
||||
onChangeNavbar: (val: {
|
||||
id: IAdmin_ActivePage;
|
||||
childId: IAdmin_ActiveChildId;
|
||||
}) => void;
|
||||
}) {
|
||||
if (data.status === "Review") {
|
||||
const path = RouterAdminInvestasi.table_review;
|
||||
router.push(path);
|
||||
onChangeNavbar({
|
||||
id: 2,
|
||||
childId: 23,
|
||||
const check = await admin_funInvestasiCheckStatus({ id: appId });
|
||||
|
||||
if (check.status == 200) {
|
||||
const udpateReadNotifikasi = await adminNotifikasi_funUpdateIsReadById({
|
||||
notifId: notifikasiId,
|
||||
});
|
||||
|
||||
if (udpateReadNotifikasi.status == 200) {
|
||||
const loadCountNotif = await adminNotifikasi_countNotifikasi();
|
||||
onLoadCountNotif(loadCountNotif);
|
||||
|
||||
const loadListNotifikasi = await adminNotifikasi_getByUserId({
|
||||
page: 1,
|
||||
});
|
||||
onLoadDataNotifikasi(loadListNotifikasi);
|
||||
|
||||
const path = `/dev/admin/investasi/sub-menu/${check.statusName}`;
|
||||
|
||||
if (check.statusName == "draft") {
|
||||
ComponentAdminGlobal_NotifikasiPeringatan(
|
||||
"Status telah dirubah oleh user"
|
||||
);
|
||||
} else {
|
||||
if (check.statusName == "publish") {
|
||||
onChangeNavbar({
|
||||
id: "Investasi",
|
||||
childId: "Investasi_2",
|
||||
});
|
||||
}
|
||||
|
||||
if (check.statusName == "review") {
|
||||
onChangeNavbar({
|
||||
id: "Investasi",
|
||||
childId: "Investasi_3",
|
||||
});
|
||||
}
|
||||
|
||||
if (check.statusName == "reject") {
|
||||
onChangeNavbar({
|
||||
id: "Investasi",
|
||||
childId: "Investasi_4",
|
||||
});
|
||||
}
|
||||
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||
return false;
|
||||
}
|
||||
// if (
|
||||
// status == "Menunggu" ||
|
||||
// status == "Berhasil" ||
|
||||
// status == "Proses" ||
|
||||
// status == "Gagal"
|
||||
// ) {
|
||||
// const path = RouterAdminDonasi_OLD.detail_publish + appId;
|
||||
// router.push(path, { scroll: false });
|
||||
// onChangeNavbar({
|
||||
// id: "Donasi",
|
||||
// childId: "Donasi_2",
|
||||
// });
|
||||
|
||||
// if (
|
||||
// data.status === "Menunggu" ||
|
||||
// data.status === "Berhasil" ||
|
||||
// data.status === "Proses" ||
|
||||
// data.status === "Gagal"
|
||||
// ) {
|
||||
// const path = RouterAdminDonasi_OLD.detail_publish + data.appId;
|
||||
// router.push(path, { scroll: false });
|
||||
// onChangeNavbar({
|
||||
// id: 3,
|
||||
// childId: 32,
|
||||
// });
|
||||
// }
|
||||
// return true;
|
||||
// } else {
|
||||
|
||||
onToggleNavbar(true);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
} from "./route_setting/type_of_select_page";
|
||||
import { adminNotifikasi_findRouterVoting } from "./route_setting/voting";
|
||||
import adminNotifikasi_findRouterDonasi from "./route_setting/donasi";
|
||||
import adminNotifikasi_findRouterInvestasi from "./route_setting/investasi";
|
||||
|
||||
export default function AdminNotifikasi_ViewCardDrawer({
|
||||
data,
|
||||
@@ -166,6 +167,9 @@ export default function AdminNotifikasi_ViewCardDrawer({
|
||||
// ========================== DONASI ========================== //
|
||||
|
||||
if (data.kategoriApp == "DONASI") {
|
||||
setVisible(true);
|
||||
setDataId(data.id);
|
||||
|
||||
const checkDonasi = await adminNotifikasi_findRouterDonasi({
|
||||
appId: data.appId,
|
||||
notifikasiId: data.id,
|
||||
@@ -195,6 +199,39 @@ export default function AdminNotifikasi_ViewCardDrawer({
|
||||
|
||||
// ========================== DONASI ========================== //
|
||||
|
||||
// ========================== INVESTASI ========================== //
|
||||
|
||||
if (data.kategoriApp == "INVESTASI") {
|
||||
setVisible(true);
|
||||
setDataId(data.id);
|
||||
|
||||
const checkInvestasi = await adminNotifikasi_findRouterInvestasi({
|
||||
appId: data.appId,
|
||||
notifikasiId: data.id,
|
||||
status: data.status as ITypeStatusNotifikasi,
|
||||
router: router,
|
||||
onLoadCountNotif(val) {
|
||||
onLoadCountNotif(val);
|
||||
},
|
||||
onLoadDataNotifikasi(val) {
|
||||
onLoadDataNotifikasi(val);
|
||||
},
|
||||
onChangeNavbar(val) {
|
||||
onChangeNavbar({
|
||||
id: val.id,
|
||||
childId: val.childId,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
if (checkInvestasi) {
|
||||
setIsAdminDonasi_TriggerReview(false);
|
||||
setVisible(false);
|
||||
setDataId("");
|
||||
onToggleNavbar(false);
|
||||
}
|
||||
}
|
||||
|
||||
// // FORUM
|
||||
// e?.kategoriApp === "FORUM" &&
|
||||
// adminNotifikasi_findRouterForum({
|
||||
@@ -220,36 +257,6 @@ export default function AdminNotifikasi_ViewCardDrawer({
|
||||
// onToggleNavbar(val);
|
||||
// },
|
||||
// });
|
||||
|
||||
// // EVENT
|
||||
// e?.kategoriApp === "EVENT" &&
|
||||
//
|
||||
|
||||
// // DONASI
|
||||
// e.kategoriApp === "DONASI" &&
|
||||
// adminNotifikasi_findRouterDonasi({
|
||||
// data: e,
|
||||
// router: router,
|
||||
// onChangeNavbar(val) {
|
||||
// onChangeNavbar(val);
|
||||
// },
|
||||
// onToggleNavbar(val) {
|
||||
// onToggleNavbar(val);
|
||||
// },
|
||||
// });
|
||||
|
||||
// // INVESTASI
|
||||
// e.kategoriApp === "INVESTASI" &&
|
||||
// adminNotifikasi_findRouterInvestasi({
|
||||
// data: e,
|
||||
// router: router,
|
||||
// onChangeNavbar(val) {
|
||||
// onChangeNavbar(val);
|
||||
// },
|
||||
// onToggleNavbar(val) {
|
||||
// onToggleNavbar(val);
|
||||
// },
|
||||
// });
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -70,12 +70,12 @@ export default function HomeViewNew() {
|
||||
variant={"transparent"}
|
||||
onClick={() => {
|
||||
if (
|
||||
dataUser.profile === undefined ||
|
||||
dataUser?.profile === null
|
||||
dataUser.profile != undefined ||
|
||||
dataUser?.profile != null
|
||||
) {
|
||||
router.push(RouterProfile.create, { scroll: false });
|
||||
} else {
|
||||
router.push(RouterUserSearch.main, { scroll: false });
|
||||
} else {
|
||||
router.push(RouterProfile.create, { scroll: false });
|
||||
}
|
||||
}}
|
||||
>
|
||||
@@ -88,11 +88,9 @@ export default function HomeViewNew() {
|
||||
disabled={countNtf == null}
|
||||
onClick={() => {
|
||||
if (
|
||||
dataUser.profile === undefined ||
|
||||
dataUser?.profile === null
|
||||
dataUser.profile != undefined ||
|
||||
dataUser?.profile != null
|
||||
) {
|
||||
router.push(RouterProfile.create, { scroll: false });
|
||||
} else {
|
||||
setCategoryPage("Semua");
|
||||
router.push(
|
||||
RouterNotifikasi.categoryApp({ name: "semua" }),
|
||||
@@ -100,6 +98,8 @@ export default function HomeViewNew() {
|
||||
scroll: false,
|
||||
}
|
||||
);
|
||||
} else {
|
||||
router.push(RouterProfile.create, { scroll: false });
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -10,13 +10,15 @@ import {
|
||||
ComponentGlobal_NotifikasiPeringatan,
|
||||
} from "@/app_modules/_global/notif_global";
|
||||
import { notifikasiToAdmin_funCreate } from "@/app_modules/notifikasi/fun";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import { Button } from "@mantine/core";
|
||||
import { useAtom } from "jotai";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { investasi_funCreateNewInvestasi } from "../../_fun";
|
||||
import { gs_investas_menu, gs_investasi_status } from "../../g_state";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { IRealtimeData } from "@/app/lib/global_state";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
|
||||
export function Investasi_ComponentButtonCreateNewInvestasi({
|
||||
data,
|
||||
@@ -34,74 +36,84 @@ export function Investasi_ComponentButtonCreateNewInvestasi({
|
||||
const [activeTab, setActiveTab] = useAtom(gs_investasi_status);
|
||||
const [hotMenu, setHotMenu] = useAtom(gs_investas_menu);
|
||||
|
||||
async function onSubmit() {
|
||||
setIsLoading(true);
|
||||
const body = {
|
||||
title: data.title,
|
||||
targetDana: data.targetDana,
|
||||
hargaLembar: data.hargaLembar,
|
||||
totalLembar: totalLembar,
|
||||
roi: data.roi,
|
||||
masterPeriodeDevidenId: data.periodeDevidenId,
|
||||
masterPembagianDevidenId: data.pembagianDevidenId,
|
||||
masterPencarianInvestorId: data.pencarianInvestorId,
|
||||
};
|
||||
|
||||
const uploadImage = await funGlobal_UploadToStorage({
|
||||
file: fileImage,
|
||||
dirId: DIRECTORY_ID.investasi_image,
|
||||
});
|
||||
if (!uploadImage.success) {
|
||||
setIsLoading(false);
|
||||
return ComponentGlobal_NotifikasiPeringatan("Gagal upload file gambar");
|
||||
}
|
||||
|
||||
const uploadFilePdf = await funGlobal_UploadToStorage({
|
||||
file: filePdf,
|
||||
dirId: DIRECTORY_ID.investasi_prospektus,
|
||||
});
|
||||
if (!uploadFilePdf.success) {
|
||||
setIsLoading(false);
|
||||
return ComponentGlobal_NotifikasiPeringatan("Gagal upload file pdf");
|
||||
}
|
||||
|
||||
const res = await investasi_funCreateNewInvestasi({
|
||||
data: body as any,
|
||||
fileImageId: uploadImage.data.id,
|
||||
filePdfId: uploadFilePdf.data.id,
|
||||
});
|
||||
|
||||
if (res.status === 201) {
|
||||
const dataNotif = {
|
||||
appId: res.data?.id,
|
||||
status: res.data?.MasterStatusInvestasi?.name,
|
||||
userId: res.data?.authorId,
|
||||
pesan: res.data?.title,
|
||||
kategoriApp: "INVESTASI",
|
||||
title: "Investasi baru",
|
||||
async function onCreate() {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const body = {
|
||||
title: data.title,
|
||||
targetDana: data.targetDana,
|
||||
hargaLembar: data.hargaLembar,
|
||||
totalLembar: totalLembar,
|
||||
roi: data.roi,
|
||||
masterPeriodeDevidenId: data.periodeDevidenId,
|
||||
masterPembagianDevidenId: data.pembagianDevidenId,
|
||||
masterPencarianInvestorId: data.pencarianInvestorId,
|
||||
};
|
||||
|
||||
const notif = await notifikasiToAdmin_funCreate({
|
||||
data: dataNotif as any,
|
||||
const uploadImage = await funGlobal_UploadToStorage({
|
||||
file: fileImage,
|
||||
dirId: DIRECTORY_ID.investasi_image,
|
||||
});
|
||||
if (!uploadImage.success) {
|
||||
setIsLoading(false);
|
||||
ComponentGlobal_NotifikasiPeringatan("Gagal upload file gambar");
|
||||
return;
|
||||
}
|
||||
|
||||
const uploadFilePdf = await funGlobal_UploadToStorage({
|
||||
file: filePdf,
|
||||
dirId: DIRECTORY_ID.investasi_prospektus,
|
||||
});
|
||||
if (!uploadFilePdf.success) {
|
||||
ComponentGlobal_NotifikasiPeringatan("Gagal upload file pdf");
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await investasi_funCreateNewInvestasi({
|
||||
data: body as any,
|
||||
fileImageId: uploadImage.data.id,
|
||||
filePdfId: uploadFilePdf.data.id,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
mqtt_client.publish(
|
||||
"ADMIN",
|
||||
JSON.stringify({
|
||||
count: 1,
|
||||
})
|
||||
);
|
||||
setActiveTab("Review");
|
||||
setHotMenu(1);
|
||||
setIsLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
router.push(NEW_RouterInvestasi.portofolio({ id: "2" }));
|
||||
if (res.status === 201) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res.data?.id as string,
|
||||
status: res.data?.MasterStatusInvestasi?.name as any,
|
||||
userId: res.data?.authorId as string,
|
||||
pesan: res.data?.title as string,
|
||||
kategoriApp: "INVESTASI",
|
||||
title: "Investasi baru",
|
||||
};
|
||||
|
||||
const notif = await notifikasiToAdmin_funCreate({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "ADMIN",
|
||||
});
|
||||
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "ADMIN",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
router.push(NEW_RouterInvestasi.portofolio({ id: "2" }));
|
||||
setActiveTab("Review");
|
||||
setHotMenu(1);
|
||||
setIsLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error create new investasi", error);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
} else {
|
||||
setIsLoading(false);
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +143,7 @@ export function Investasi_ComponentButtonCreateNewInvestasi({
|
||||
bg={MainColor.yellow}
|
||||
color="yellow"
|
||||
c={"black"}
|
||||
onClick={() => onSubmit()}
|
||||
onClick={() => onCreate()}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
|
||||
@@ -3,29 +3,27 @@ import { Affix, Button, Center, rem } from "@mantine/core";
|
||||
import { useState } from "react";
|
||||
import { investasi_funGetAllPublish } from "../../fun/get_all_investasi";
|
||||
import { data } from "autoprefixer";
|
||||
import { apiGetAllInvestasi } from "../../_lib/api_interface";
|
||||
|
||||
export function Investasi_ComponentButtonUpdateBeranda({
|
||||
onLoadData,
|
||||
}: {
|
||||
onLoadData: (val: any) => void;
|
||||
}) {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
|
||||
async function onLoaded() {
|
||||
try {
|
||||
await investasi_funGetAllPublish({ page: 1 });
|
||||
setLoading(true);
|
||||
const response = await apiGetAllInvestasi(`?cat=bursa&page=1`);
|
||||
if (response.success) {
|
||||
onLoadData(response.data);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error(error);
|
||||
} finally {
|
||||
const loadData = await investasi_funGetAllPublish({ page: 1 });
|
||||
|
||||
onLoadData({
|
||||
data: loadData,
|
||||
isNewPost: false,
|
||||
});
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
setIsLoading(true);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use client'
|
||||
"use client";
|
||||
import { RouterInvestasi_OLD } from "@/app/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";
|
||||
@@ -14,84 +14,87 @@ 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 "@/app/lib/global_state";
|
||||
|
||||
export function Investasi_ViewBerandaNew() {
|
||||
const [data, setData] = useState<IDataInvestasiBursa[]>([]);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isNewPost, setIsNewPost] = useState(false);
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [data, setData] = useState<IDataInvestasiBursa[]>([]);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useShallowEffect(() => {
|
||||
mqtt_client.subscribe("Beranda_Investasi");
|
||||
// Realtime
|
||||
const [isShowUpdate, setIsShowUpdate] = useState(false);
|
||||
const [isTriggerReload, setIsTriggerReload] = useAtom(
|
||||
gs_investasiTriggerBeranda
|
||||
);
|
||||
|
||||
mqtt_client.on("message", (topic, message) => {
|
||||
const newPost = JSON.parse(message.toString());
|
||||
setIsNewPost(newPost);
|
||||
});
|
||||
}, []);
|
||||
useShallowEffect(() => {
|
||||
if (isTriggerReload) {
|
||||
setIsShowUpdate(true);
|
||||
}
|
||||
}, [isTriggerReload]);
|
||||
|
||||
|
||||
async function getDataInvestasi() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const response = await apiGetAllInvestasi(`?cat=bursa&page=1`)
|
||||
if (response.success) {
|
||||
setData(response.data);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
setLoading(false)
|
||||
async function getDataInvestasi() {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await apiGetAllInvestasi(`?cat=bursa&page=1`);
|
||||
if (response.success) {
|
||||
setData(response.data);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
useShallowEffect(() => {
|
||||
setIsTriggerReload(false);
|
||||
setIsShowUpdate(false);
|
||||
getDataInvestasi();
|
||||
}, []);
|
||||
|
||||
useShallowEffect(() => {
|
||||
getDataInvestasi()
|
||||
}, []);
|
||||
return (
|
||||
<>
|
||||
{isShowUpdate && (
|
||||
<Investasi_ComponentButtonUpdateBeranda
|
||||
onLoadData={(val) => {
|
||||
setData(val);
|
||||
setIsShowUpdate(false);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
return (
|
||||
<>
|
||||
{isNewPost && (
|
||||
<Investasi_ComponentButtonUpdateBeranda
|
||||
onLoadData={(val) => {
|
||||
setData(val.data);
|
||||
setIsNewPost(val.isNewPost);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<Box>
|
||||
<ComponentGlobal_CreateButton path={RouterInvestasi_OLD.create} />
|
||||
{loading ? (
|
||||
<SkeletonInvestasiBursa />
|
||||
) : _.isEmpty(data) ? (
|
||||
<ComponentGlobal_IsEmptyData />
|
||||
) : (
|
||||
<ScrollOnly
|
||||
height="82vh"
|
||||
renderLoading={() => (
|
||||
<Center>
|
||||
<ComponentGlobal_Loader size={25} />
|
||||
</Center>
|
||||
)}
|
||||
data={data}
|
||||
setData={setData}
|
||||
moreData={async () => {
|
||||
const pageNew = activePage + 1;
|
||||
const loadData = await apiGetAllInvestasi(
|
||||
`?cat=bursa&page=${pageNew}`
|
||||
);
|
||||
setActivePage((val) => val + 1);
|
||||
|
||||
<Box>
|
||||
<ComponentGlobal_CreateButton path={RouterInvestasi_OLD.create} />
|
||||
{
|
||||
loading ? <SkeletonInvestasiBursa />
|
||||
:
|
||||
_.isEmpty(data) ? (
|
||||
<ComponentGlobal_IsEmptyData />
|
||||
) : (
|
||||
<ScrollOnly
|
||||
height="82vh"
|
||||
renderLoading={() => (
|
||||
<Center>
|
||||
<ComponentGlobal_Loader size={25} />
|
||||
</Center>
|
||||
)}
|
||||
data={data}
|
||||
setData={setData}
|
||||
moreData={async () => {
|
||||
const pageNew = activePage + 1
|
||||
const loadData = await apiGetAllInvestasi(`?cat=bursa&page=${pageNew}`);
|
||||
setActivePage((val) => val + 1);
|
||||
|
||||
return loadData;
|
||||
}}
|
||||
>
|
||||
{(item) => <Investasi_ComponentCardBerandaNew data={item as any} />}
|
||||
</ScrollOnly>
|
||||
)
|
||||
|
||||
}
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
return loadData.data as any;
|
||||
}}
|
||||
>
|
||||
{(item) => <Investasi_ComponentCardBerandaNew data={item as any} />}
|
||||
</ScrollOnly>
|
||||
)}
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,413 +1,485 @@
|
||||
"use client";
|
||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { ComponentGlobal_BoxInformation, ComponentGlobal_BoxUploadImage, ComponentGlobal_CardStyles, } from "@/app_modules/_global/component";
|
||||
import { AspectRatio, Box, Button, Center, FileButton, Grid, Group, Image, Select, Stack, Text, TextInput, } from "@mantine/core";
|
||||
import {
|
||||
ComponentGlobal_BoxInformation,
|
||||
ComponentGlobal_BoxUploadImage,
|
||||
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,
|
||||
Stack,
|
||||
Text,
|
||||
TextInput,
|
||||
} from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { IconCamera, IconCircleCheck, IconFileTypePdf, IconUpload } from "@tabler/icons-react";
|
||||
import {
|
||||
IconCamera,
|
||||
IconCircleCheck,
|
||||
IconFileTypePdf,
|
||||
IconPhoto,
|
||||
} from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { useState } from "react";
|
||||
import { Investasi_ComponentButtonCreateNewInvestasi } from "../_component";
|
||||
import { apiGetMasterInvestasi } from "../_lib/api_interface";
|
||||
|
||||
export default function InvestasiCreateNew() {
|
||||
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 [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("");
|
||||
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 [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));
|
||||
const [isLoadingImg, setIsLoadingImg] = useState(false);
|
||||
const [isLoadingPdf, setIsLoadingPdf] = useState(false);
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
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 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 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(() => {
|
||||
onGetMasterInvestor();
|
||||
onGetMasterPeriodeDeviden();
|
||||
onGetMasterPembagianDeviden();
|
||||
}, []);
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
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>
|
||||
{isLoadingImg ? (
|
||||
<Stack justify="center" align="center" h={"100%"}>
|
||||
<Loader size={150} color="yellow" />
|
||||
</Stack>
|
||||
) : 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%"}>
|
||||
<IconPhoto size={150} color="gray" />
|
||||
</Stack>
|
||||
)}
|
||||
</ComponentGlobal_BoxUploadImage>
|
||||
|
||||
useShallowEffect(() => {
|
||||
onGetMasterInvestor()
|
||||
onGetMasterPeriodeDeviden()
|
||||
onGetMasterPembagianDeviden()
|
||||
}, [])
|
||||
{/* Upload Foto */}
|
||||
<Group position="center">
|
||||
<FileButton
|
||||
onChange={async (files: any) => {
|
||||
try {
|
||||
setIsLoadingImg(true);
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
|
||||
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>
|
||||
if (files.size > MAX_SIZE) {
|
||||
ComponentGlobal_NotifikasiPeringatan(
|
||||
PemberitahuanMaksimalFile
|
||||
);
|
||||
setImg(null);
|
||||
|
||||
{/* 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>
|
||||
return;
|
||||
}
|
||||
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={loadingMasterInvestor ? "Loading..." : "Pilih batas waktu"}
|
||||
data={pencarianInvestor.map((e) => ({
|
||||
value: e.id,
|
||||
label: e.name + " " + "hari",
|
||||
}))}
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
...(value as any),
|
||||
pencarianInvestorId: val,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
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>
|
||||
|
||||
<Select
|
||||
styles={{
|
||||
label: {
|
||||
color: "white",
|
||||
},
|
||||
}}
|
||||
withAsterisk
|
||||
label="Periode Deviden"
|
||||
placeholder={loadingMasterPeriodeDeviden ? "Loading..." : "Pilih batas waktu"}
|
||||
data={periodeDeviden.map((e) => ({ value: e.id, label: e.name }))}
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
...(value as any),
|
||||
periodeDevidenId: val,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
{/* 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"}>
|
||||
{isLoadingPdf ? (
|
||||
<Stack justify="center" align="center" h={"100%"}>
|
||||
<Loader size={50} color="yellow" />
|
||||
</Stack>
|
||||
) : !filePdf ? (
|
||||
<Stack justify="center" align="center" h={"100%"}>
|
||||
<IconFileTypePdf size={50} color="gray" />
|
||||
</Stack>
|
||||
) : (
|
||||
<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>
|
||||
|
||||
<Select
|
||||
styles={{
|
||||
label: {
|
||||
color: "white",
|
||||
},
|
||||
}}
|
||||
withAsterisk
|
||||
label="Pembagian Deviden"
|
||||
placeholder={loadingMasterPembagianDeviden ? "Loading..." : "Pilih batas waktu"}
|
||||
data={pembagianDeviden.map((e) => ({
|
||||
value: e.id,
|
||||
label: e.name + " " + "bulan",
|
||||
}))}
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
...(value as any),
|
||||
pembagianDevidenId: val,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
<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())])
|
||||
);
|
||||
|
||||
<Investasi_ComponentButtonCreateNewInvestasi
|
||||
data={value}
|
||||
totalLembar={totalLembar}
|
||||
fileImage={fileImage as any}
|
||||
filePdf={filePdf as any}
|
||||
/>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
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>
|
||||
<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={
|
||||
loadingMasterInvestor ? "Loading..." : "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={
|
||||
loadingMasterPeriodeDeviden ? "Loading..." : "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={
|
||||
loadingMasterPembagianDeviden ? "Loading..." : "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>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,9 @@ import {
|
||||
} from "@/app_modules/_global/component";
|
||||
import { Job_ComponentButtonSaveCreate } from "../component";
|
||||
import { defaultDeskripsi, defaultSyarat } from "../component/default_value";
|
||||
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";
|
||||
|
||||
export default function Job_Create() {
|
||||
const [value, setValue] = useState({
|
||||
@@ -80,6 +83,16 @@ export default function Job_Create() {
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
|
||||
if (files.size > MAX_SIZE) {
|
||||
ComponentGlobal_NotifikasiPeringatan(
|
||||
PemberitahuanMaksimalFile
|
||||
);
|
||||
setImg(null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
setImg(buffer);
|
||||
setFile(files);
|
||||
} catch (error) {
|
||||
|
||||
@@ -6,22 +6,24 @@ import {
|
||||
MainColor,
|
||||
} from "@/app_modules/_global/color/color_pallet";
|
||||
import { ComponentGlobal_CardLoadingOverlay } from "@/app_modules/_global/component";
|
||||
import { gs_donasi_hot_menu } from "@/app_modules/donasi/global_state";
|
||||
import { gs_event_hotMenu } from "@/app_modules/event/global_state";
|
||||
import { gs_investas_menu } from "@/app_modules/investasi/g_state";
|
||||
import { gs_job_hot_menu } from "@/app_modules/job/global_state";
|
||||
import { gs_vote_hotMenu } from "@/app_modules/vote/global_state";
|
||||
import { Badge, Card, Divider, Group, Stack, Text } from "@mantine/core";
|
||||
import { IconCheck, IconChecks } from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { ICategoryapp, MODEL_NOTIFIKASI } from "../model/interface";
|
||||
import { notifikasi_eventCheckStatus } from "./path/event";
|
||||
import { notifikasi_jobCheckStatus } from "./path/job";
|
||||
import { gs_vote_hotMenu } from "@/app_modules/vote/global_state";
|
||||
import { notifikasi_votingCheckStatus } from "./path/voting";
|
||||
import { redirectDonasiPage } from "./path/donasi";
|
||||
import { gs_donasi_hot_menu } from "@/app_modules/donasi/global_state";
|
||||
import moment from "moment";
|
||||
import "moment/locale/id";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { MODEL_NOTIFIKASI } from "../model/interface";
|
||||
import { redirectDonasiPage } from "./path/donasi";
|
||||
import { notifikasi_eventCheckStatus } from "./path/event";
|
||||
import { redirectInvestasiPage } from "./path/investasi";
|
||||
import { notifikasi_jobCheckStatus } from "./path/job";
|
||||
import { notifikasi_votingCheckStatus } from "./path/voting";
|
||||
|
||||
export function ComponentNotifiaksi_CardView({
|
||||
data,
|
||||
@@ -40,6 +42,7 @@ export function ComponentNotifiaksi_CardView({
|
||||
const [eventMenuId, setEventMenuId] = useAtom(gs_event_hotMenu);
|
||||
const [votingMenu, setVotingMenu] = useAtom(gs_vote_hotMenu);
|
||||
const [donasiMenu, setDonasiMenu] = useAtom(gs_donasi_hot_menu);
|
||||
const [investasiMenu, setInvestasiMenu] = useAtom(gs_investas_menu);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -76,6 +79,8 @@ export function ComponentNotifiaksi_CardView({
|
||||
setLoadCountNtf(val);
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// EVENT
|
||||
@@ -98,6 +103,8 @@ export function ComponentNotifiaksi_CardView({
|
||||
setLoadCountNtf(val);
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (data?.kategoriApp === "VOTING") {
|
||||
@@ -119,6 +126,8 @@ export function ComponentNotifiaksi_CardView({
|
||||
setLoadCountNtf(val);
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (data?.kategoriApp === "DONASI") {
|
||||
@@ -140,6 +149,31 @@ export function ComponentNotifiaksi_CardView({
|
||||
setLoadCountNtf(val);
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (data?.kategoriApp === "INVESTASI") {
|
||||
redirectInvestasiPage({
|
||||
appId: data.appId,
|
||||
dataId: data.id,
|
||||
categoryPage: categoryPage,
|
||||
router: router,
|
||||
onLoadDataEvent(val) {
|
||||
onLoadData(val);
|
||||
},
|
||||
onSetVisible(val) {
|
||||
setVisible(val);
|
||||
},
|
||||
onSetMenuId(val) {
|
||||
setInvestasiMenu(val);
|
||||
},
|
||||
onLoadCountNtf(val) {
|
||||
setLoadCountNtf(val);
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// data?.kategoriApp === "FORUM" &&
|
||||
@@ -148,38 +182,11 @@ export function ComponentNotifiaksi_CardView({
|
||||
// router: router,
|
||||
// });
|
||||
|
||||
// data?.kategoriApp === "VOTING" &&
|
||||
// redirectVotingPage({
|
||||
// data: data,
|
||||
// router: router,
|
||||
// onSetPage(val) {
|
||||
// // onSetMenu(val);
|
||||
// },
|
||||
// });
|
||||
|
||||
// data?.kategoriApp === "EVENT" &&
|
||||
// redirectEventPage({
|
||||
// data: data,
|
||||
// router: router,
|
||||
// onSetPage(val) {
|
||||
// // onSetMenu(val);
|
||||
// },
|
||||
// });
|
||||
|
||||
// data?.kategoriApp === "COLLABORATION" &&
|
||||
// redirectDetailCollaborationPage({
|
||||
// data: data,
|
||||
// router: router,
|
||||
// });
|
||||
|
||||
// data.kategoriApp === "INVESTASI" &&
|
||||
// redirectInvestasiPage({
|
||||
// data: data,
|
||||
// router: router,
|
||||
// onSetPage(val) {
|
||||
// // onSetMenu(val);
|
||||
// },
|
||||
// });
|
||||
}}
|
||||
>
|
||||
{/* <pre>{JSON.stringify(e, null, 2)}</pre> */}
|
||||
|
||||
@@ -1,37 +1,61 @@
|
||||
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||
import { MODEL_NOTIFIKASI } from "../../model/interface";
|
||||
import { RouterInvestasi_OLD } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { RouterDonasi } from "@/app/lib/router_hipmi/router_donasi";
|
||||
import { notifikasi_funDonasiCheckStatus } from "../../fun/check/fun_check_donasi_status";
|
||||
import notifikasi_getByUserId from "../../fun/get/get_notifiaksi_by_id";
|
||||
import notifikasi_countUserNotifikasi from "../../fun/count/fun_count_by_id";
|
||||
import notifikasi_funUpdateIsReadById from "../../fun/update/fun_update_is_read_by_user_id";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
import { notifikasi_funInvestasiCheckStatus } from "../../fun/check/fun_check_investasi_status";
|
||||
|
||||
export function redirectInvestasiPage({
|
||||
data,
|
||||
export async function redirectInvestasiPage({
|
||||
appId,
|
||||
dataId,
|
||||
categoryPage,
|
||||
router,
|
||||
onSetPage,
|
||||
onLoadDataEvent,
|
||||
onSetMenuId,
|
||||
onSetVisible,
|
||||
onLoadCountNtf,
|
||||
}: {
|
||||
data: MODEL_NOTIFIKASI;
|
||||
appId: string;
|
||||
dataId: string;
|
||||
categoryPage: string;
|
||||
router: AppRouterInstance;
|
||||
onSetPage: (val: any) => void;
|
||||
onLoadDataEvent: (val: any) => void;
|
||||
onSetMenuId(val: number): void;
|
||||
onSetVisible(val: boolean): void;
|
||||
onLoadCountNtf(val: number): void;
|
||||
}) {
|
||||
const path = RouterInvestasi_OLD.portofolio;
|
||||
const check = await notifikasi_funInvestasiCheckStatus({ id: appId });
|
||||
|
||||
if (data.status === "Publish") {
|
||||
onSetPage({
|
||||
menuId: 2,
|
||||
status: data.status,
|
||||
if (check.status == 200) {
|
||||
// const loadListNotifikasi = await notifikasi_getByUserId({
|
||||
// page: 1,
|
||||
// kategoriApp: categoryPage as any,
|
||||
// });
|
||||
// onLoadDataEvent(loadListNotifikasi);
|
||||
|
||||
// const loadCountNotifikasi = await notifikasi_countUserNotifikasi();
|
||||
// onLoadCountNtf(loadCountNotifikasi);
|
||||
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: dataId,
|
||||
});
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
// console.log(data)
|
||||
|
||||
if (data.status === "Reject") {
|
||||
onSetPage({
|
||||
menuId: 2,
|
||||
status: data.status,
|
||||
});
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
if (updateReadNotifikasi.status == 200) {
|
||||
onSetVisible(true);
|
||||
|
||||
// if (data.status === "Peserta Event") {
|
||||
// router.push(RouterEvent.detail_main + data.appId, { scroll: false });
|
||||
// }
|
||||
onSetMenuId(1);
|
||||
if (check.statusName == "publish") {
|
||||
router.push(`/dev/investasi/detail/${appId}`, { scroll: false });
|
||||
} else {
|
||||
const path = `/dev/investasi/detail/portofolio/${appId}`;
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import _ from "lodash";
|
||||
|
||||
export async function notifikasi_funInvestasiCheckStatus({
|
||||
id,
|
||||
}: {
|
||||
id: string;
|
||||
}) {
|
||||
const data = await prisma.investasi.findUnique({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
select: {
|
||||
MasterStatusInvestasi: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!data)
|
||||
return {
|
||||
status: 400,
|
||||
message: "Investasi tidak ditemukan",
|
||||
statusName: "",
|
||||
};
|
||||
return {
|
||||
status: 200,
|
||||
message: "Berhasil di cek",
|
||||
statusName: _.lowerCase(data.MasterStatusInvestasi?.name),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user