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.
|
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.2.32](https://github.com/bipproduction/hipmi/compare/v1.2.31...v1.2.32) (2024-12-19)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hipmi",
|
"name": "hipmi",
|
||||||
"version": "1.2.32",
|
"version": "1.2.33",
|
||||||
"private": true,
|
"private": true,
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "npx tsx prisma/seed.ts --yes"
|
"seed": "npx tsx prisma/seed.ts --yes"
|
||||||
|
|||||||
@@ -1,19 +1,8 @@
|
|||||||
import { InvestasiCreateNew } from "@/app_modules/investasi";
|
import { InvestasiCreateNew } from "@/app_modules/investasi";
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
|
|
||||||
// const pencarianInvestor = await getPencarianInvestor();
|
|
||||||
// const periodeDeviden = await getPeriodeDeviden();
|
|
||||||
// const pembagianDeviden = await getPembagianDeviden();
|
|
||||||
// const statusInvestasi = await getStatusInvestasi();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <InvestasiCreate
|
|
||||||
pencarianInvestor={pencarianInvestor as any}
|
|
||||||
periodeDeviden={periodeDeviden as any}
|
|
||||||
pembagianDeviden={pembagianDeviden as any}
|
|
||||||
/> */}
|
|
||||||
<InvestasiCreateNew />
|
<InvestasiCreateNew />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -59,3 +59,7 @@ export const gs_votingTiggerBeranda = atom<boolean>(false);
|
|||||||
// donasi
|
// donasi
|
||||||
export const gs_adminDonasi_triggerReview = atom<boolean>(false);
|
export const gs_adminDonasi_triggerReview = atom<boolean>(false);
|
||||||
export const gs_donasiTriggerBeranda = 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_admin_ntf,
|
||||||
gs_adminDonasi_triggerReview,
|
gs_adminDonasi_triggerReview,
|
||||||
gs_adminEvent_triggerReview,
|
gs_adminEvent_triggerReview,
|
||||||
|
gs_adminInvestasi_triggerReview,
|
||||||
gs_adminJob_triggerReview,
|
gs_adminJob_triggerReview,
|
||||||
gs_adminVoting_triggerReview,
|
gs_adminVoting_triggerReview,
|
||||||
gs_donasiTriggerBeranda,
|
gs_donasiTriggerBeranda,
|
||||||
gs_eventTriggerBeranda,
|
gs_eventTriggerBeranda,
|
||||||
|
gs_investasiTriggerBeranda,
|
||||||
gs_jobTiggerBeranda,
|
gs_jobTiggerBeranda,
|
||||||
gs_realtimeData,
|
gs_realtimeData,
|
||||||
gs_user_ntf,
|
gs_user_ntf,
|
||||||
@@ -71,6 +73,14 @@ export default function RealtimeProvider({
|
|||||||
gs_donasiTriggerBeranda
|
gs_donasiTriggerBeranda
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// INVESTASI
|
||||||
|
const [isAdminInvestasi_TriggerReview, setIsAdminInvestasi_TriggerReview] =
|
||||||
|
useAtom(gs_adminInvestasi_triggerReview);
|
||||||
|
|
||||||
|
const [isTriggerInvestasiBeranda, setIsTriggerInvestasiBeranda] = useAtom(
|
||||||
|
gs_investasiTriggerBeranda
|
||||||
|
);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
try {
|
try {
|
||||||
WibuRealtime.init({
|
WibuRealtime.init({
|
||||||
@@ -195,12 +205,32 @@ export default function RealtimeProvider({
|
|||||||
// ) {
|
// ) {
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// ---------------------- DONASI ------------------------- //
|
// ---------------------- 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) {
|
} 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_DeleteFileById } from "./delete/fun_delete_file_by_id";
|
||||||
import { funGlobal_UploadToStorage } from "./upload/fun_upload_to_storage";
|
import { funGlobal_UploadToStorage } from "./upload/fun_upload_to_storage";
|
||||||
|
import { funValidasiUploadCreatedFile } from "./upload/fun_validasi_upload_created_file";
|
||||||
|
|
||||||
export { funGlobal_UploadToStorage };
|
export { funGlobal_UploadToStorage };
|
||||||
export { funGlobal_DeleteFileById };
|
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";
|
"use client";
|
||||||
|
|
||||||
|
import { IRealtimeData } from "@/app/lib/global_state";
|
||||||
import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||||
import getOneInvestasiById from "@/app_modules/investasi/fun/get_one_investasi_by_id";
|
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 { useShallowEffect } from "@mantine/hooks";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
import { Admin_ComponentModalReport } from "../../_admin_global/_component";
|
import { Admin_ComponentModalReport } from "../../_admin_global/_component";
|
||||||
import { ComponentAdminGlobal_NotifikasiBerhasil } from "../../_admin_global/admin_notifikasi/notifikasi_berhasil";
|
import { ComponentAdminGlobal_NotifikasiBerhasil } from "../../_admin_global/admin_notifikasi/notifikasi_berhasil";
|
||||||
import { ComponentAdminGlobal_NotifikasiGagal } from "../../_admin_global/admin_notifikasi/notifikasi_gagal";
|
import { ComponentAdminGlobal_NotifikasiGagal } from "../../_admin_global/admin_notifikasi/notifikasi_gagal";
|
||||||
@@ -60,24 +56,25 @@ export default function AdminInvestasi_DetailReview({
|
|||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
setIsLoadingReject(true);
|
setIsLoadingReject(true);
|
||||||
|
|
||||||
const dataNotif = {
|
const dataNotifikasi: IRealtimeData = {
|
||||||
appId: res.data?.id,
|
appId: res.data?.id as string,
|
||||||
userId: res.data?.authorId,
|
userId: res.data?.authorId as string,
|
||||||
pesan: res.data?.title,
|
pesan: res.data?.title as string,
|
||||||
status: res.data?.MasterStatusInvestasi?.name,
|
status: res.data?.MasterStatusInvestasi?.name as any,
|
||||||
kategoriApp: "INVESTASI",
|
kategoriApp: "INVESTASI",
|
||||||
title: "Investasi anda di tolak !",
|
title: "Investasi anda di tolak !",
|
||||||
};
|
};
|
||||||
|
|
||||||
const notif = await adminNotifikasi_funCreateToUser({
|
const notif = await adminNotifikasi_funCreateToUser({
|
||||||
data: dataNotif as any,
|
data: dataNotifikasi as any,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (notif.status === 201) {
|
if (notif.status === 201) {
|
||||||
mqtt_client.publish(
|
WibuRealtime.setData({
|
||||||
"USER",
|
type: "notification",
|
||||||
JSON.stringify({ userId: res?.data?.authorId, count: 1 })
|
pushNotificationTo: "USER",
|
||||||
);
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadData = await getOneInvestasiById(data.id);
|
const loadData = await getOneInvestasiById(data.id);
|
||||||
@@ -100,8 +97,8 @@ export default function AdminInvestasi_DetailReview({
|
|||||||
progesInvestasiId: "1",
|
progesInvestasiId: "1",
|
||||||
});
|
});
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const dataNotif = {
|
const dataNotifikasi: IRealtimeData = {
|
||||||
appId: res.data?.id,
|
appId: res.data?.id as string,
|
||||||
userId: res.data?.authorId as any,
|
userId: res.data?.authorId as any,
|
||||||
pesan: res.data?.title as any,
|
pesan: res.data?.title as any,
|
||||||
status: res.data?.MasterStatusInvestasi?.name as any,
|
status: res.data?.MasterStatusInvestasi?.name as any,
|
||||||
@@ -110,19 +107,21 @@ export default function AdminInvestasi_DetailReview({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const notif = await adminNotifikasi_funCreateToUser({
|
const notif = await adminNotifikasi_funCreateToUser({
|
||||||
data: dataNotif as any,
|
data: dataNotifikasi as any,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (notif.status === 201) {
|
if (notif.status === 201) {
|
||||||
mqtt_client.publish(
|
WibuRealtime.setData({
|
||||||
"USER",
|
type: "notification",
|
||||||
JSON.stringify({ userId: res?.data?.authorId, count: 1 })
|
pushNotificationTo: "USER",
|
||||||
);
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
|
||||||
mqtt_client.publish(
|
WibuRealtime.setData({
|
||||||
"Beranda_Investasi",
|
type: "trigger",
|
||||||
JSON.stringify({ update: true })
|
pushNotificationTo: "USER",
|
||||||
);
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
|
||||||
const loadData = await getOneInvestasiById(data.id);
|
const loadData = await getOneInvestasiById(data.id);
|
||||||
setData(loadData as any);
|
setData(loadData as any);
|
||||||
@@ -216,8 +215,6 @@ export default function AdminInvestasi_DetailReview({
|
|||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +1,33 @@
|
|||||||
"use client";
|
"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 { 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 { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||||
import {
|
import {
|
||||||
Badge,
|
Affix,
|
||||||
ActionIcon,
|
|
||||||
Box,
|
|
||||||
ScrollArea,
|
|
||||||
Table,
|
|
||||||
Tooltip,
|
|
||||||
Stack,
|
|
||||||
Group,
|
|
||||||
Avatar,
|
|
||||||
Text,
|
|
||||||
Center,
|
|
||||||
Button,
|
Button,
|
||||||
|
Center,
|
||||||
|
Group,
|
||||||
Pagination,
|
Pagination,
|
||||||
Paper,
|
Paper,
|
||||||
|
rem,
|
||||||
|
ScrollArea,
|
||||||
|
Stack,
|
||||||
|
Table,
|
||||||
|
Text,
|
||||||
TextInput,
|
TextInput,
|
||||||
Title,
|
Title,
|
||||||
} from "@mantine/core";
|
} 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 { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
|
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_IsEmptyData from "../../_admin_global/is_empty_data";
|
||||||
import ComponentAdminGlobal_TampilanRupiahDonasi from "../../_admin_global/tampilan_rupiah";
|
import ComponentAdminGlobal_TampilanRupiahDonasi from "../../_admin_global/tampilan_rupiah";
|
||||||
|
import { adminInvestasi_funGetAllReview } from "../fun/get/get_all_review";
|
||||||
|
|
||||||
export default function Admin_TableReviewInvestasi({
|
export default function Admin_TableReviewInvestasi({
|
||||||
dataInvestsi,
|
dataInvestsi,
|
||||||
@@ -53,6 +53,33 @@ function TableView({ listData }: { listData: any }) {
|
|||||||
const [isLoading, setLoading] = useState(false);
|
const [isLoading, setLoading] = useState(false);
|
||||||
const [idData, setIdData] = useState("");
|
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) {
|
async function onSearch(s: string) {
|
||||||
setSearch(s);
|
setSearch(s);
|
||||||
setActivePage(1);
|
setActivePage(1);
|
||||||
@@ -151,6 +178,30 @@ function TableView({ listData }: { listData: any }) {
|
|||||||
<ComponentAdminGlobal_IsEmptyData />
|
<ComponentAdminGlobal_IsEmptyData />
|
||||||
) : (
|
) : (
|
||||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
<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>
|
<ScrollArea w={"100%"} h={"90%"} offsetScrollbars>
|
||||||
<Table
|
<Table
|
||||||
verticalSpacing={"md"}
|
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 { ITypeStatusNotifikasi } from "@/app/lib/global_state";
|
||||||
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 { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
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({
|
export default async function adminNotifikasi_findRouterInvestasi({
|
||||||
data,
|
appId,
|
||||||
|
notifikasiId,
|
||||||
|
status,
|
||||||
router,
|
router,
|
||||||
|
onLoadCountNotif,
|
||||||
|
onLoadDataNotifikasi,
|
||||||
onChangeNavbar,
|
onChangeNavbar,
|
||||||
onToggleNavbar,
|
|
||||||
}: {
|
}: {
|
||||||
data: MODEL_NOTIFIKASI;
|
appId: string;
|
||||||
|
notifikasiId: string;
|
||||||
|
status: ITypeStatusNotifikasi;
|
||||||
router: AppRouterInstance;
|
router: AppRouterInstance;
|
||||||
onChangeNavbar: (val: any) => void;
|
onLoadCountNotif: (val: any) => void;
|
||||||
onToggleNavbar: (val: any) => void;
|
onLoadDataNotifikasi: (val: any) => void;
|
||||||
|
onChangeNavbar: (val: {
|
||||||
|
id: IAdmin_ActivePage;
|
||||||
|
childId: IAdmin_ActiveChildId;
|
||||||
|
}) => void;
|
||||||
}) {
|
}) {
|
||||||
if (data.status === "Review") {
|
const check = await admin_funInvestasiCheckStatus({ id: appId });
|
||||||
const path = RouterAdminInvestasi.table_review;
|
|
||||||
router.push(path);
|
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({
|
onChangeNavbar({
|
||||||
id: 2,
|
id: "Investasi",
|
||||||
childId: 23,
|
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 (
|
// if (
|
||||||
// data.status === "Menunggu" ||
|
// status == "Menunggu" ||
|
||||||
// data.status === "Berhasil" ||
|
// status == "Berhasil" ||
|
||||||
// data.status === "Proses" ||
|
// status == "Proses" ||
|
||||||
// data.status === "Gagal"
|
// status == "Gagal"
|
||||||
// ) {
|
// ) {
|
||||||
// const path = RouterAdminDonasi_OLD.detail_publish + data.appId;
|
// const path = RouterAdminDonasi_OLD.detail_publish + appId;
|
||||||
// router.push(path, { scroll: false });
|
// router.push(path, { scroll: false });
|
||||||
// onChangeNavbar({
|
// onChangeNavbar({
|
||||||
// id: 3,
|
// id: "Donasi",
|
||||||
// childId: 32,
|
// childId: "Donasi_2",
|
||||||
// });
|
// });
|
||||||
// }
|
|
||||||
|
|
||||||
onToggleNavbar(true);
|
// return true;
|
||||||
|
// } else {
|
||||||
|
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
} from "./route_setting/type_of_select_page";
|
} from "./route_setting/type_of_select_page";
|
||||||
import { adminNotifikasi_findRouterVoting } from "./route_setting/voting";
|
import { adminNotifikasi_findRouterVoting } from "./route_setting/voting";
|
||||||
import adminNotifikasi_findRouterDonasi from "./route_setting/donasi";
|
import adminNotifikasi_findRouterDonasi from "./route_setting/donasi";
|
||||||
|
import adminNotifikasi_findRouterInvestasi from "./route_setting/investasi";
|
||||||
|
|
||||||
export default function AdminNotifikasi_ViewCardDrawer({
|
export default function AdminNotifikasi_ViewCardDrawer({
|
||||||
data,
|
data,
|
||||||
@@ -166,6 +167,9 @@ export default function AdminNotifikasi_ViewCardDrawer({
|
|||||||
// ========================== DONASI ========================== //
|
// ========================== DONASI ========================== //
|
||||||
|
|
||||||
if (data.kategoriApp == "DONASI") {
|
if (data.kategoriApp == "DONASI") {
|
||||||
|
setVisible(true);
|
||||||
|
setDataId(data.id);
|
||||||
|
|
||||||
const checkDonasi = await adminNotifikasi_findRouterDonasi({
|
const checkDonasi = await adminNotifikasi_findRouterDonasi({
|
||||||
appId: data.appId,
|
appId: data.appId,
|
||||||
notifikasiId: data.id,
|
notifikasiId: data.id,
|
||||||
@@ -195,6 +199,39 @@ export default function AdminNotifikasi_ViewCardDrawer({
|
|||||||
|
|
||||||
// ========================== DONASI ========================== //
|
// ========================== 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
|
// // FORUM
|
||||||
// e?.kategoriApp === "FORUM" &&
|
// e?.kategoriApp === "FORUM" &&
|
||||||
// adminNotifikasi_findRouterForum({
|
// adminNotifikasi_findRouterForum({
|
||||||
@@ -220,36 +257,6 @@ export default function AdminNotifikasi_ViewCardDrawer({
|
|||||||
// onToggleNavbar(val);
|
// 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 (
|
return (
|
||||||
|
|||||||
@@ -70,12 +70,12 @@ export default function HomeViewNew() {
|
|||||||
variant={"transparent"}
|
variant={"transparent"}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (
|
if (
|
||||||
dataUser.profile === undefined ||
|
dataUser.profile != undefined ||
|
||||||
dataUser?.profile === null
|
dataUser?.profile != null
|
||||||
) {
|
) {
|
||||||
router.push(RouterProfile.create, { scroll: false });
|
|
||||||
} else {
|
|
||||||
router.push(RouterUserSearch.main, { scroll: false });
|
router.push(RouterUserSearch.main, { scroll: false });
|
||||||
|
} else {
|
||||||
|
router.push(RouterProfile.create, { scroll: false });
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -88,11 +88,9 @@ export default function HomeViewNew() {
|
|||||||
disabled={countNtf == null}
|
disabled={countNtf == null}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (
|
if (
|
||||||
dataUser.profile === undefined ||
|
dataUser.profile != undefined ||
|
||||||
dataUser?.profile === null
|
dataUser?.profile != null
|
||||||
) {
|
) {
|
||||||
router.push(RouterProfile.create, { scroll: false });
|
|
||||||
} else {
|
|
||||||
setCategoryPage("Semua");
|
setCategoryPage("Semua");
|
||||||
router.push(
|
router.push(
|
||||||
RouterNotifikasi.categoryApp({ name: "semua" }),
|
RouterNotifikasi.categoryApp({ name: "semua" }),
|
||||||
@@ -100,6 +98,8 @@ export default function HomeViewNew() {
|
|||||||
scroll: false,
|
scroll: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
router.push(RouterProfile.create, { scroll: false });
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -10,13 +10,15 @@ import {
|
|||||||
ComponentGlobal_NotifikasiPeringatan,
|
ComponentGlobal_NotifikasiPeringatan,
|
||||||
} from "@/app_modules/_global/notif_global";
|
} from "@/app_modules/_global/notif_global";
|
||||||
import { notifikasiToAdmin_funCreate } from "@/app_modules/notifikasi/fun";
|
import { notifikasiToAdmin_funCreate } from "@/app_modules/notifikasi/fun";
|
||||||
import mqtt_client from "@/util/mqtt_client";
|
|
||||||
import { Button } from "@mantine/core";
|
import { Button } from "@mantine/core";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { investasi_funCreateNewInvestasi } from "../../_fun";
|
import { investasi_funCreateNewInvestasi } from "../../_fun";
|
||||||
import { gs_investas_menu, gs_investasi_status } from "../../g_state";
|
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({
|
export function Investasi_ComponentButtonCreateNewInvestasi({
|
||||||
data,
|
data,
|
||||||
@@ -34,7 +36,8 @@ export function Investasi_ComponentButtonCreateNewInvestasi({
|
|||||||
const [activeTab, setActiveTab] = useAtom(gs_investasi_status);
|
const [activeTab, setActiveTab] = useAtom(gs_investasi_status);
|
||||||
const [hotMenu, setHotMenu] = useAtom(gs_investas_menu);
|
const [hotMenu, setHotMenu] = useAtom(gs_investas_menu);
|
||||||
|
|
||||||
async function onSubmit() {
|
async function onCreate() {
|
||||||
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const body = {
|
const body = {
|
||||||
title: data.title,
|
title: data.title,
|
||||||
@@ -53,7 +56,8 @@ export function Investasi_ComponentButtonCreateNewInvestasi({
|
|||||||
});
|
});
|
||||||
if (!uploadImage.success) {
|
if (!uploadImage.success) {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
return ComponentGlobal_NotifikasiPeringatan("Gagal upload file gambar");
|
ComponentGlobal_NotifikasiPeringatan("Gagal upload file gambar");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uploadFilePdf = await funGlobal_UploadToStorage({
|
const uploadFilePdf = await funGlobal_UploadToStorage({
|
||||||
@@ -61,8 +65,8 @@ export function Investasi_ComponentButtonCreateNewInvestasi({
|
|||||||
dirId: DIRECTORY_ID.investasi_prospektus,
|
dirId: DIRECTORY_ID.investasi_prospektus,
|
||||||
});
|
});
|
||||||
if (!uploadFilePdf.success) {
|
if (!uploadFilePdf.success) {
|
||||||
setIsLoading(false);
|
ComponentGlobal_NotifikasiPeringatan("Gagal upload file pdf");
|
||||||
return ComponentGlobal_NotifikasiPeringatan("Gagal upload file pdf");
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await investasi_funCreateNewInvestasi({
|
const res = await investasi_funCreateNewInvestasi({
|
||||||
@@ -72,37 +76,45 @@ export function Investasi_ComponentButtonCreateNewInvestasi({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (res.status === 201) {
|
if (res.status === 201) {
|
||||||
const dataNotif = {
|
const dataNotifikasi: IRealtimeData = {
|
||||||
appId: res.data?.id,
|
appId: res.data?.id as string,
|
||||||
status: res.data?.MasterStatusInvestasi?.name,
|
status: res.data?.MasterStatusInvestasi?.name as any,
|
||||||
userId: res.data?.authorId,
|
userId: res.data?.authorId as string,
|
||||||
pesan: res.data?.title,
|
pesan: res.data?.title as string,
|
||||||
kategoriApp: "INVESTASI",
|
kategoriApp: "INVESTASI",
|
||||||
title: "Investasi baru",
|
title: "Investasi baru",
|
||||||
};
|
};
|
||||||
|
|
||||||
const notif = await notifikasiToAdmin_funCreate({
|
const notif = await notifikasiToAdmin_funCreate({
|
||||||
data: dataNotif as any,
|
data: dataNotifikasi as any,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (notif.status === 201) {
|
if (notif.status === 201) {
|
||||||
mqtt_client.publish(
|
WibuRealtime.setData({
|
||||||
"ADMIN",
|
type: "notification",
|
||||||
JSON.stringify({
|
pushNotificationTo: "ADMIN",
|
||||||
count: 1,
|
});
|
||||||
})
|
|
||||||
);
|
WibuRealtime.setData({
|
||||||
|
type: "trigger",
|
||||||
|
pushNotificationTo: "ADMIN",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
|
||||||
|
router.push(NEW_RouterInvestasi.portofolio({ id: "2" }));
|
||||||
setActiveTab("Review");
|
setActiveTab("Review");
|
||||||
setHotMenu(1);
|
setHotMenu(1);
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
router.push(NEW_RouterInvestasi.portofolio({ id: "2" }));
|
|
||||||
}
|
}
|
||||||
setIsLoading(false);
|
|
||||||
} else {
|
} else {
|
||||||
setIsLoading(false);
|
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
clientLogger.error("Error create new investasi", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -131,7 +143,7 @@ export function Investasi_ComponentButtonCreateNewInvestasi({
|
|||||||
bg={MainColor.yellow}
|
bg={MainColor.yellow}
|
||||||
color="yellow"
|
color="yellow"
|
||||||
c={"black"}
|
c={"black"}
|
||||||
onClick={() => onSubmit()}
|
onClick={() => onCreate()}
|
||||||
>
|
>
|
||||||
Simpan
|
Simpan
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -3,29 +3,27 @@ import { Affix, Button, Center, rem } from "@mantine/core";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { investasi_funGetAllPublish } from "../../fun/get_all_investasi";
|
import { investasi_funGetAllPublish } from "../../fun/get_all_investasi";
|
||||||
import { data } from "autoprefixer";
|
import { data } from "autoprefixer";
|
||||||
|
import { apiGetAllInvestasi } from "../../_lib/api_interface";
|
||||||
|
|
||||||
export function Investasi_ComponentButtonUpdateBeranda({
|
export function Investasi_ComponentButtonUpdateBeranda({
|
||||||
onLoadData,
|
onLoadData,
|
||||||
}: {
|
}: {
|
||||||
onLoadData: (val: any) => void;
|
onLoadData: (val: any) => void;
|
||||||
}) {
|
}) {
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
async function onLoaded() {
|
async function onLoaded() {
|
||||||
try {
|
try {
|
||||||
await investasi_funGetAllPublish({ page: 1 });
|
setLoading(true);
|
||||||
} catch (error) {
|
const response = await apiGetAllInvestasi(`?cat=bursa&page=1`);
|
||||||
console.log(error);
|
if (response.success) {
|
||||||
} finally {
|
onLoadData(response.data);
|
||||||
const loadData = await investasi_funGetAllPublish({ page: 1 });
|
}
|
||||||
|
} catch (error) {
|
||||||
onLoadData({
|
console.error(error);
|
||||||
data: loadData,
|
} finally {
|
||||||
isNewPost: false,
|
setLoading(false);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsLoading(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
'use client'
|
"use client";
|
||||||
import { RouterInvestasi_OLD } from "@/app/lib/router_hipmi/router_investasi";
|
import { RouterInvestasi_OLD } from "@/app/lib/router_hipmi/router_investasi";
|
||||||
import ComponentGlobal_CreateButton from "@/app_modules/_global/component/button_create";
|
import ComponentGlobal_CreateButton from "@/app_modules/_global/component/button_create";
|
||||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||||
@@ -14,59 +14,62 @@ import { Investasi_ComponentCardBerandaNew } from "../../_component/main/com_car
|
|||||||
import { apiGetAllInvestasi } from "../../_lib/api_interface";
|
import { apiGetAllInvestasi } from "../../_lib/api_interface";
|
||||||
import { IDataInvestasiBursa } from "../../_lib/type_investasi";
|
import { IDataInvestasiBursa } from "../../_lib/type_investasi";
|
||||||
import SkeletonInvestasiBursa from "./skeleton_beranda";
|
import SkeletonInvestasiBursa from "./skeleton_beranda";
|
||||||
|
import { useAtom } from "jotai";
|
||||||
|
import { gs_investasiTriggerBeranda } from "@/app/lib/global_state";
|
||||||
|
|
||||||
export function Investasi_ViewBerandaNew() {
|
export function Investasi_ViewBerandaNew() {
|
||||||
const [data, setData] = useState<IDataInvestasiBursa[]>([]);
|
const [data, setData] = useState<IDataInvestasiBursa[]>([]);
|
||||||
const [activePage, setActivePage] = useState(1);
|
const [activePage, setActivePage] = useState(1);
|
||||||
const [isNewPost, setIsNewPost] = useState(false);
|
const [loading, setLoading] = useState(true);
|
||||||
const [loading, setLoading] = useState(true)
|
|
||||||
|
// Realtime
|
||||||
|
const [isShowUpdate, setIsShowUpdate] = useState(false);
|
||||||
|
const [isTriggerReload, setIsTriggerReload] = useAtom(
|
||||||
|
gs_investasiTriggerBeranda
|
||||||
|
);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
mqtt_client.subscribe("Beranda_Investasi");
|
if (isTriggerReload) {
|
||||||
|
setIsShowUpdate(true);
|
||||||
mqtt_client.on("message", (topic, message) => {
|
}
|
||||||
const newPost = JSON.parse(message.toString());
|
}, [isTriggerReload]);
|
||||||
setIsNewPost(newPost);
|
|
||||||
});
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
|
|
||||||
async function getDataInvestasi() {
|
async function getDataInvestasi() {
|
||||||
try {
|
try {
|
||||||
setLoading(true)
|
setLoading(true);
|
||||||
const response = await apiGetAllInvestasi(`?cat=bursa&page=1`)
|
const response = await apiGetAllInvestasi(`?cat=bursa&page=1`);
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setData(response.data);
|
setData(response.data);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
getDataInvestasi()
|
setIsTriggerReload(false);
|
||||||
|
setIsShowUpdate(false);
|
||||||
|
getDataInvestasi();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{isNewPost && (
|
{isShowUpdate && (
|
||||||
<Investasi_ComponentButtonUpdateBeranda
|
<Investasi_ComponentButtonUpdateBeranda
|
||||||
onLoadData={(val) => {
|
onLoadData={(val) => {
|
||||||
setData(val.data);
|
setData(val);
|
||||||
setIsNewPost(val.isNewPost);
|
setIsShowUpdate(false);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Box>
|
<Box>
|
||||||
<ComponentGlobal_CreateButton path={RouterInvestasi_OLD.create} />
|
<ComponentGlobal_CreateButton path={RouterInvestasi_OLD.create} />
|
||||||
{
|
{loading ? (
|
||||||
loading ? <SkeletonInvestasiBursa />
|
<SkeletonInvestasiBursa />
|
||||||
:
|
) : _.isEmpty(data) ? (
|
||||||
_.isEmpty(data) ? (
|
|
||||||
<ComponentGlobal_IsEmptyData />
|
<ComponentGlobal_IsEmptyData />
|
||||||
) : (
|
) : (
|
||||||
<ScrollOnly
|
<ScrollOnly
|
||||||
@@ -79,18 +82,18 @@ export function Investasi_ViewBerandaNew() {
|
|||||||
data={data}
|
data={data}
|
||||||
setData={setData}
|
setData={setData}
|
||||||
moreData={async () => {
|
moreData={async () => {
|
||||||
const pageNew = activePage + 1
|
const pageNew = activePage + 1;
|
||||||
const loadData = await apiGetAllInvestasi(`?cat=bursa&page=${pageNew}`);
|
const loadData = await apiGetAllInvestasi(
|
||||||
|
`?cat=bursa&page=${pageNew}`
|
||||||
|
);
|
||||||
setActivePage((val) => val + 1);
|
setActivePage((val) => val + 1);
|
||||||
|
|
||||||
return loadData;
|
return loadData.data as any;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{(item) => <Investasi_ComponentCardBerandaNew data={item as any} />}
|
{(item) => <Investasi_ComponentCardBerandaNew data={item as any} />}
|
||||||
</ScrollOnly>
|
</ScrollOnly>
|
||||||
)
|
)}
|
||||||
|
|
||||||
}
|
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,18 +1,46 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
import { ComponentGlobal_BoxInformation, ComponentGlobal_BoxUploadImage, ComponentGlobal_CardStyles, } from "@/app_modules/_global/component";
|
import {
|
||||||
import { AspectRatio, Box, Button, Center, FileButton, Grid, Group, Image, Select, Stack, Text, TextInput, } from "@mantine/core";
|
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 { 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 _ from "lodash";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Investasi_ComponentButtonCreateNewInvestasi } from "../_component";
|
import { Investasi_ComponentButtonCreateNewInvestasi } from "../_component";
|
||||||
import { apiGetMasterInvestasi } from "../_lib/api_interface";
|
import { apiGetMasterInvestasi } from "../_lib/api_interface";
|
||||||
|
|
||||||
export default function InvestasiCreateNew() {
|
export default function InvestasiCreateNew() {
|
||||||
const [loadingMasterInvestor, setLoadingMasterInvestor] = useState(true)
|
const [loadingMasterInvestor, setLoadingMasterInvestor] = useState(true);
|
||||||
const [loadingMasterPeriodeDeviden, setLoadingMasterPeriodeDeviden] = useState(true)
|
const [loadingMasterPeriodeDeviden, setLoadingMasterPeriodeDeviden] =
|
||||||
const [loadingMasterPembagianDeviden, setLoadingMasterPembagianDeviden] = useState(true)
|
useState(true);
|
||||||
|
const [loadingMasterPembagianDeviden, setLoadingMasterPembagianDeviden] =
|
||||||
|
useState(true);
|
||||||
const [periodeDeviden, setPeriodeDeviden] = useState<any[]>([]);
|
const [periodeDeviden, setPeriodeDeviden] = useState<any[]>([]);
|
||||||
const [pembagianDeviden, setPembagianDeviden] = useState<any[]>([]);
|
const [pembagianDeviden, setPembagianDeviden] = useState<any[]>([]);
|
||||||
const [pencarianInvestor, setPencarianInvestor] = useState<any[]>([]);
|
const [pencarianInvestor, setPencarianInvestor] = useState<any[]>([]);
|
||||||
@@ -33,7 +61,16 @@ export default function InvestasiCreateNew() {
|
|||||||
const [target, setTarget] = useState("");
|
const [target, setTarget] = useState("");
|
||||||
const [harga, setHarga] = useState("");
|
const [harga, setHarga] = useState("");
|
||||||
|
|
||||||
async function onTotalLembar({ target, harga, }: { target?: number | any; harga?: number | any; }) {
|
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) {
|
if (target !== 0 && harga !== 0) {
|
||||||
const hasil: any = target / harga;
|
const hasil: any = target / harga;
|
||||||
setTotalLembar(_.floor(hasil === Infinity ? 0 : hasil));
|
setTotalLembar(_.floor(hasil === Infinity ? 0 : hasil));
|
||||||
@@ -42,52 +79,51 @@ export default function InvestasiCreateNew() {
|
|||||||
|
|
||||||
async function onGetMasterInvestor() {
|
async function onGetMasterInvestor() {
|
||||||
try {
|
try {
|
||||||
setLoadingMasterInvestor(true)
|
setLoadingMasterInvestor(true);
|
||||||
const response = await apiGetMasterInvestasi("?cat=pencarian-investor")
|
const response = await apiGetMasterInvestasi("?cat=pencarian-investor");
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setPencarianInvestor(response.data)
|
setPencarianInvestor(response.data);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
} finally {
|
} finally {
|
||||||
setLoadingMasterInvestor(false)
|
setLoadingMasterInvestor(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onGetMasterPeriodeDeviden() {
|
async function onGetMasterPeriodeDeviden() {
|
||||||
try {
|
try {
|
||||||
setLoadingMasterPeriodeDeviden(true)
|
setLoadingMasterPeriodeDeviden(true);
|
||||||
const response = await apiGetMasterInvestasi("?cat=periode-deviden")
|
const response = await apiGetMasterInvestasi("?cat=periode-deviden");
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setPeriodeDeviden(response.data)
|
setPeriodeDeviden(response.data);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
} finally {
|
} finally {
|
||||||
setLoadingMasterPeriodeDeviden(false)
|
setLoadingMasterPeriodeDeviden(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function onGetMasterPembagianDeviden() {
|
async function onGetMasterPembagianDeviden() {
|
||||||
try {
|
try {
|
||||||
setLoadingMasterPembagianDeviden(true)
|
setLoadingMasterPembagianDeviden(true);
|
||||||
const response = await apiGetMasterInvestasi("?cat=pembagian-deviden")
|
const response = await apiGetMasterInvestasi("?cat=pembagian-deviden");
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setPembagianDeviden(response.data)
|
setPembagianDeviden(response.data);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
} finally {
|
} finally {
|
||||||
setLoadingMasterPembagianDeviden(false)
|
setLoadingMasterPembagianDeviden(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
onGetMasterInvestor()
|
onGetMasterInvestor();
|
||||||
onGetMasterPeriodeDeviden()
|
onGetMasterPeriodeDeviden();
|
||||||
onGetMasterPembagianDeviden()
|
onGetMasterPembagianDeviden();
|
||||||
}, [])
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -98,7 +134,11 @@ export default function InvestasiCreateNew() {
|
|||||||
<ComponentGlobal_BoxInformation informasi="Gambar investasi bisa berupa ilustrasi, poster atau foto terkait investasi" />
|
<ComponentGlobal_BoxInformation informasi="Gambar investasi bisa berupa ilustrasi, poster atau foto terkait investasi" />
|
||||||
</Box>
|
</Box>
|
||||||
<ComponentGlobal_BoxUploadImage>
|
<ComponentGlobal_BoxUploadImage>
|
||||||
{img ? (
|
{isLoadingImg ? (
|
||||||
|
<Stack justify="center" align="center" h={"100%"}>
|
||||||
|
<Loader size={150} color="yellow" />
|
||||||
|
</Stack>
|
||||||
|
) : img ? (
|
||||||
<AspectRatio ratio={1 / 1} mah={265} mx={"auto"}>
|
<AspectRatio ratio={1 / 1} mah={265} mx={"auto"}>
|
||||||
<Image
|
<Image
|
||||||
style={{ maxHeight: 250, margin: "auto", padding: "5px" }}
|
style={{ maxHeight: 250, margin: "auto", padding: "5px" }}
|
||||||
@@ -109,10 +149,7 @@ export default function InvestasiCreateNew() {
|
|||||||
</AspectRatio>
|
</AspectRatio>
|
||||||
) : (
|
) : (
|
||||||
<Stack justify="center" align="center" h={"100%"}>
|
<Stack justify="center" align="center" h={"100%"}>
|
||||||
<IconUpload color="white" />
|
<IconPhoto size={150} color="gray" />
|
||||||
<Text fz={10} fs={"italic"} c={"white"} fw={"bold"}>
|
|
||||||
Upload Gambar
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
</ComponentGlobal_BoxUploadImage>
|
</ComponentGlobal_BoxUploadImage>
|
||||||
@@ -122,14 +159,26 @@ export default function InvestasiCreateNew() {
|
|||||||
<FileButton
|
<FileButton
|
||||||
onChange={async (files: any) => {
|
onChange={async (files: any) => {
|
||||||
try {
|
try {
|
||||||
|
setIsLoadingImg(true);
|
||||||
const buffer = URL.createObjectURL(
|
const buffer = URL.createObjectURL(
|
||||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (files.size > MAX_SIZE) {
|
||||||
|
ComponentGlobal_NotifikasiPeringatan(
|
||||||
|
PemberitahuanMaksimalFile
|
||||||
|
);
|
||||||
|
setImg(null);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setImg(buffer);
|
setImg(buffer);
|
||||||
setFileImage(files);
|
setFileImage(files);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
} finally {
|
||||||
|
setIsLoadingImg(false);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
accept="image/png,image/jpeg"
|
accept="image/png,image/jpeg"
|
||||||
@@ -154,10 +203,14 @@ export default function InvestasiCreateNew() {
|
|||||||
<Stack spacing={"sm"}>
|
<Stack spacing={"sm"}>
|
||||||
<ComponentGlobal_BoxInformation informasi="File prospektus wajib untuk diupload, agar calon investor paham dengan prospek investasi yang akan anda jalankan kedepan !" />
|
<ComponentGlobal_BoxInformation informasi="File prospektus wajib untuk diupload, agar calon investor paham dengan prospek investasi yang akan anda jalankan kedepan !" />
|
||||||
<ComponentGlobal_CardStyles marginBottom={"0px"}>
|
<ComponentGlobal_CardStyles marginBottom={"0px"}>
|
||||||
{!filePdf ? (
|
{isLoadingPdf ? (
|
||||||
<Text lineClamp={1} align="center" c={"gray"}>
|
<Stack justify="center" align="center" h={"100%"}>
|
||||||
Upload File Prospektus
|
<Loader size={50} color="yellow" />
|
||||||
</Text>
|
</Stack>
|
||||||
|
) : !filePdf ? (
|
||||||
|
<Stack justify="center" align="center" h={"100%"}>
|
||||||
|
<IconFileTypePdf size={50} color="gray" />
|
||||||
|
</Stack>
|
||||||
) : (
|
) : (
|
||||||
<Grid align="center">
|
<Grid align="center">
|
||||||
<Grid.Col span={2}></Grid.Col>
|
<Grid.Col span={2}></Grid.Col>
|
||||||
@@ -180,13 +233,26 @@ export default function InvestasiCreateNew() {
|
|||||||
accept={"application/pdf"}
|
accept={"application/pdf"}
|
||||||
onChange={async (files: any) => {
|
onChange={async (files: any) => {
|
||||||
try {
|
try {
|
||||||
|
setIsLoadingPdf(true);
|
||||||
const buffer = URL.createObjectURL(
|
const buffer = URL.createObjectURL(
|
||||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (files.size > MAX_SIZE) {
|
||||||
|
ComponentGlobal_NotifikasiPeringatan(
|
||||||
|
PemberitahuanMaksimalFile
|
||||||
|
);
|
||||||
|
setFilePdf(null);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setFPdf(buffer);
|
setFPdf(buffer);
|
||||||
setFilePdf(files);
|
setFilePdf(files);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
} finally {
|
||||||
|
setIsLoadingPdf(false);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -348,7 +414,9 @@ export default function InvestasiCreateNew() {
|
|||||||
}}
|
}}
|
||||||
withAsterisk
|
withAsterisk
|
||||||
label="Pencarian Investor"
|
label="Pencarian Investor"
|
||||||
placeholder={loadingMasterInvestor ? "Loading..." : "Pilih batas waktu"}
|
placeholder={
|
||||||
|
loadingMasterInvestor ? "Loading..." : "Pilih batas waktu"
|
||||||
|
}
|
||||||
data={pencarianInvestor.map((e) => ({
|
data={pencarianInvestor.map((e) => ({
|
||||||
value: e.id,
|
value: e.id,
|
||||||
label: e.name + " " + "hari",
|
label: e.name + " " + "hari",
|
||||||
@@ -369,7 +437,9 @@ export default function InvestasiCreateNew() {
|
|||||||
}}
|
}}
|
||||||
withAsterisk
|
withAsterisk
|
||||||
label="Periode Deviden"
|
label="Periode Deviden"
|
||||||
placeholder={loadingMasterPeriodeDeviden ? "Loading..." : "Pilih batas waktu"}
|
placeholder={
|
||||||
|
loadingMasterPeriodeDeviden ? "Loading..." : "Pilih batas waktu"
|
||||||
|
}
|
||||||
data={periodeDeviden.map((e) => ({ value: e.id, label: e.name }))}
|
data={periodeDeviden.map((e) => ({ value: e.id, label: e.name }))}
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
setValue({
|
setValue({
|
||||||
@@ -387,7 +457,9 @@ export default function InvestasiCreateNew() {
|
|||||||
}}
|
}}
|
||||||
withAsterisk
|
withAsterisk
|
||||||
label="Pembagian Deviden"
|
label="Pembagian Deviden"
|
||||||
placeholder={loadingMasterPembagianDeviden ? "Loading..." : "Pilih batas waktu"}
|
placeholder={
|
||||||
|
loadingMasterPembagianDeviden ? "Loading..." : "Pilih batas waktu"
|
||||||
|
}
|
||||||
data={pembagianDeviden.map((e) => ({
|
data={pembagianDeviden.map((e) => ({
|
||||||
value: e.id,
|
value: e.id,
|
||||||
label: e.name + " " + "bulan",
|
label: e.name + " " + "bulan",
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ import {
|
|||||||
} from "@/app_modules/_global/component";
|
} from "@/app_modules/_global/component";
|
||||||
import { Job_ComponentButtonSaveCreate } from "../component";
|
import { Job_ComponentButtonSaveCreate } from "../component";
|
||||||
import { defaultDeskripsi, defaultSyarat } from "../component/default_value";
|
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() {
|
export default function Job_Create() {
|
||||||
const [value, setValue] = useState({
|
const [value, setValue] = useState({
|
||||||
@@ -80,6 +83,16 @@ export default function Job_Create() {
|
|||||||
const buffer = URL.createObjectURL(
|
const buffer = URL.createObjectURL(
|
||||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (files.size > MAX_SIZE) {
|
||||||
|
ComponentGlobal_NotifikasiPeringatan(
|
||||||
|
PemberitahuanMaksimalFile
|
||||||
|
);
|
||||||
|
setImg(null);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setImg(buffer);
|
setImg(buffer);
|
||||||
setFile(files);
|
setFile(files);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -6,22 +6,24 @@ import {
|
|||||||
MainColor,
|
MainColor,
|
||||||
} from "@/app_modules/_global/color/color_pallet";
|
} from "@/app_modules/_global/color/color_pallet";
|
||||||
import { ComponentGlobal_CardLoadingOverlay } from "@/app_modules/_global/component";
|
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_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_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 { Badge, Card, Divider, Group, Stack, Text } from "@mantine/core";
|
||||||
import { IconCheck, IconChecks } from "@tabler/icons-react";
|
import { IconCheck, IconChecks } from "@tabler/icons-react";
|
||||||
import { useAtom } from "jotai";
|
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 from "moment";
|
||||||
import "moment/locale/id";
|
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({
|
export function ComponentNotifiaksi_CardView({
|
||||||
data,
|
data,
|
||||||
@@ -40,6 +42,7 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
const [eventMenuId, setEventMenuId] = useAtom(gs_event_hotMenu);
|
const [eventMenuId, setEventMenuId] = useAtom(gs_event_hotMenu);
|
||||||
const [votingMenu, setVotingMenu] = useAtom(gs_vote_hotMenu);
|
const [votingMenu, setVotingMenu] = useAtom(gs_vote_hotMenu);
|
||||||
const [donasiMenu, setDonasiMenu] = useAtom(gs_donasi_hot_menu);
|
const [donasiMenu, setDonasiMenu] = useAtom(gs_donasi_hot_menu);
|
||||||
|
const [investasiMenu, setInvestasiMenu] = useAtom(gs_investas_menu);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -76,6 +79,8 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
setLoadCountNtf(val);
|
setLoadCountNtf(val);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// EVENT
|
// EVENT
|
||||||
@@ -98,6 +103,8 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
setLoadCountNtf(val);
|
setLoadCountNtf(val);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data?.kategoriApp === "VOTING") {
|
if (data?.kategoriApp === "VOTING") {
|
||||||
@@ -119,6 +126,8 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
setLoadCountNtf(val);
|
setLoadCountNtf(val);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data?.kategoriApp === "DONASI") {
|
if (data?.kategoriApp === "DONASI") {
|
||||||
@@ -140,6 +149,31 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
setLoadCountNtf(val);
|
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" &&
|
// data?.kategoriApp === "FORUM" &&
|
||||||
@@ -148,38 +182,11 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
// router: router,
|
// 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" &&
|
// data?.kategoriApp === "COLLABORATION" &&
|
||||||
// redirectDetailCollaborationPage({
|
// redirectDetailCollaborationPage({
|
||||||
// data: data,
|
// data: data,
|
||||||
// router: router,
|
// router: router,
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// data.kategoriApp === "INVESTASI" &&
|
|
||||||
// redirectInvestasiPage({
|
|
||||||
// data: data,
|
|
||||||
// router: router,
|
|
||||||
// onSetPage(val) {
|
|
||||||
// // onSetMenu(val);
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{/* <pre>{JSON.stringify(e, null, 2)}</pre> */}
|
{/* <pre>{JSON.stringify(e, null, 2)}</pre> */}
|
||||||
|
|||||||
@@ -1,37 +1,61 @@
|
|||||||
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||||
import { MODEL_NOTIFIKASI } from "../../model/interface";
|
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({
|
export async function redirectInvestasiPage({
|
||||||
data,
|
appId,
|
||||||
|
dataId,
|
||||||
|
categoryPage,
|
||||||
router,
|
router,
|
||||||
onSetPage,
|
onLoadDataEvent,
|
||||||
|
onSetMenuId,
|
||||||
|
onSetVisible,
|
||||||
|
onLoadCountNtf,
|
||||||
}: {
|
}: {
|
||||||
data: MODEL_NOTIFIKASI;
|
appId: string;
|
||||||
|
dataId: string;
|
||||||
|
categoryPage: string;
|
||||||
router: AppRouterInstance;
|
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") {
|
if (check.status == 200) {
|
||||||
onSetPage({
|
// const loadListNotifikasi = await notifikasi_getByUserId({
|
||||||
menuId: 2,
|
// page: 1,
|
||||||
status: data.status,
|
// kategoriApp: categoryPage as any,
|
||||||
|
// });
|
||||||
|
// onLoadDataEvent(loadListNotifikasi);
|
||||||
|
|
||||||
|
// const loadCountNotifikasi = await notifikasi_countUserNotifikasi();
|
||||||
|
// onLoadCountNtf(loadCountNotifikasi);
|
||||||
|
|
||||||
|
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||||
|
notifId: dataId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (updateReadNotifikasi.status == 200) {
|
||||||
|
onSetVisible(true);
|
||||||
|
|
||||||
|
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 });
|
router.push(path, { scroll: false });
|
||||||
}
|
}
|
||||||
// console.log(data)
|
|
||||||
|
|
||||||
if (data.status === "Reject") {
|
|
||||||
onSetPage({
|
|
||||||
menuId: 2,
|
|
||||||
status: data.status,
|
|
||||||
});
|
|
||||||
router.push(path, { scroll: false });
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
// if (data.status === "Peserta Event") {
|
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||||
// router.push(RouterEvent.detail_main + data.appId, { scroll: false });
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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