Fix: admin investasi
Deskripsi: - Fix image dari server wibu ## No Issue
This commit is contained in:
@@ -69,7 +69,7 @@ export function Investasi_ViewCreateDocument({
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xl"}>
|
||||
<ComponentGlobal_BoxInformation informasi="File dokumen bersifat opsional, jika memang ada file yang bisa membantu meyakinkan investor. Anda bisa mengupload nya disini !" />
|
||||
<ComponentGlobal_BoxInformation informasi="File dokumen bersifat opsional, jika memang ada file yang bisa membantu meyakinkan investor. Anda bisa mengupload nya !" />
|
||||
|
||||
<Stack>
|
||||
<TextInput
|
||||
|
||||
@@ -3,34 +3,47 @@
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
||||
import { funGlobal_DeleteFileById } from "@/app_modules/_global/fun";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import { UIGlobal_Modal } from "@/app_modules/_global/ui";
|
||||
import { ComponentAdminGlobal_NotifikasiPeringatan } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_peringatan";
|
||||
import { Investasi_ComponentDetailDataNonPublish } from "@/app_modules/investasi/_component";
|
||||
import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||
import { investasi_funEditStatusById } from "@/app_modules/investasi/fun/edit/fun_edit_status_by_id";
|
||||
import { gs_investasi_status } from "@/app_modules/investasi/g_state";
|
||||
import funDeleteInvestasi from "@/app_modules/investasi/fun/fun_delete_investasi";
|
||||
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import { Button, Stack } from "@mantine/core";
|
||||
import { useAtom } from "jotai";
|
||||
import { Button, Group, Stack } from "@mantine/core";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function Investasi_ViewDetailDraft({
|
||||
dataInvestasi,
|
||||
}: {
|
||||
dataInvestasi: MODEL_INVESTASI;
|
||||
dataInvestasi: any;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [data, setData] = useState<MODEL_INVESTASI>(dataInvestasi);
|
||||
const [openModal, setOpenModal] = useState(false);
|
||||
|
||||
async function onAjukanReview() {
|
||||
// Delete
|
||||
const [isLoadingDelete, setIsLoadingDelete] = useState(false);
|
||||
const [openModalDelete, setOpenModalDelete] = useState(false);
|
||||
|
||||
async function onChangeStatus() {
|
||||
const res = await investasi_funEditStatusById({
|
||||
investasiId: dataInvestasi.id,
|
||||
investasiId: data.id,
|
||||
statusId: "2",
|
||||
});
|
||||
|
||||
if (res.status === 200) {
|
||||
setIsLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil("Review Berhasil Diajukan");
|
||||
router.replace(NEW_RouterInvestasi.portofolio({ id: "2" }));
|
||||
|
||||
const dataNotif = {
|
||||
appId: res.data?.id,
|
||||
userId: res.data?.authorId,
|
||||
@@ -46,41 +59,138 @@ export default function Investasi_ViewDetailDraft({
|
||||
|
||||
if (notif.status === 201) {
|
||||
mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 }));
|
||||
|
||||
setIsLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil("Review Berhasil Diajukan");
|
||||
router.push(NEW_RouterInvestasi.portofolio({ id: "2" }));
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function onDelete() {
|
||||
const res = await funDeleteInvestasi(data.id);
|
||||
if (res.status === 200) {
|
||||
setIsLoadingDelete(true);
|
||||
|
||||
const delImage = await funGlobal_DeleteFileById({
|
||||
fileId: data.imageId,
|
||||
});
|
||||
if (!delImage.success) {
|
||||
ComponentAdminGlobal_NotifikasiPeringatan("Gagal hapus image ");
|
||||
}
|
||||
|
||||
const delFileProspektus = await funGlobal_DeleteFileById({
|
||||
fileId: data.prospektusFileId,
|
||||
});
|
||||
if (!delFileProspektus.success) {
|
||||
ComponentAdminGlobal_NotifikasiPeringatan("Gagal hapus prospektus ");
|
||||
}
|
||||
|
||||
if (!_.isEmpty(data.DokumenInvestasi)) {
|
||||
for (let i of data.DokumenInvestasi) {
|
||||
const delFileDokumen = await funGlobal_DeleteFileById({
|
||||
fileId: i.fileId,
|
||||
});
|
||||
|
||||
if (!delFileDokumen.success) {
|
||||
ComponentAdminGlobal_NotifikasiPeringatan(
|
||||
"Gagal hapus prospektus "
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setOpenModal(false);
|
||||
router.replace(NEW_RouterInvestasi.portofolio({ id: "3" }));
|
||||
setIsLoadingDelete(false);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
setIsLoadingDelete(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack mb={"lg"}>
|
||||
{dataInvestasi.catatan && (
|
||||
<ComponentGlobal_BoxInformation
|
||||
informasi={dataInvestasi.catatan}
|
||||
isReport
|
||||
/>
|
||||
{data.catatan && (
|
||||
<ComponentGlobal_BoxInformation informasi={data.catatan} isReport />
|
||||
)}
|
||||
<Investasi_ComponentDetailDataNonPublish data={dataInvestasi} />
|
||||
<Investasi_ComponentDetailDataNonPublish data={data} />
|
||||
|
||||
<Stack>
|
||||
<Group position="apart" grow>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoading}
|
||||
radius={50}
|
||||
bg={MainColor.yellow}
|
||||
color="yellow"
|
||||
c={"black"}
|
||||
onClick={() => onAjukanReview()}
|
||||
onClick={() => setOpenModal(true)}
|
||||
>
|
||||
Ajukan Review
|
||||
</Button>
|
||||
</Stack>
|
||||
|
||||
<Button
|
||||
radius={50}
|
||||
color="red"
|
||||
c={"black"}
|
||||
onClick={() => setOpenModalDelete(true)}
|
||||
>
|
||||
Hapus
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
|
||||
{/* Ajukan Kembali */}
|
||||
<UIGlobal_Modal
|
||||
opened={openModal}
|
||||
close={() => setOpenModal(false)}
|
||||
title={"Anda yakin ingin mengajukan review ?"}
|
||||
buttonKiri={
|
||||
<Button radius={"xl"} onClick={() => setOpenModal(false)}>
|
||||
Batal
|
||||
</Button>
|
||||
}
|
||||
buttonKanan={
|
||||
<Button
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
}}
|
||||
loaderPosition="center"
|
||||
loading={isLoading}
|
||||
radius={"xl"}
|
||||
color={"orange"}
|
||||
onClick={() => onChangeStatus()}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
|
||||
{/* Hapus */}
|
||||
<UIGlobal_Modal
|
||||
opened={openModalDelete}
|
||||
close={() => setOpenModalDelete(false)}
|
||||
title={"Anda yakin ingin menghapus ?"}
|
||||
buttonKiri={
|
||||
<Button radius={"xl"} onClick={() => setOpenModalDelete(false)}>
|
||||
Batal
|
||||
</Button>
|
||||
}
|
||||
buttonKanan={
|
||||
<Button
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
}}
|
||||
loaderPosition="center"
|
||||
loading={isLoadingDelete}
|
||||
radius={"xl"}
|
||||
color={"red"}
|
||||
onClick={() => {
|
||||
onDelete();
|
||||
}}
|
||||
>
|
||||
Hapus
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
NEW_RouterInvestasi,
|
||||
RouterInvestasi_OLD,
|
||||
} from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
||||
import { funGlobal_DeleteFileById } from "@/app_modules/_global/fun";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal";
|
||||
import { ComponentAdminGlobal_NotifikasiPeringatan } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_peringatan";
|
||||
import { Investasi_ComponentDetailDataNonPublish } from "@/app_modules/investasi/_component";
|
||||
import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||
import { investasi_funEditStatusById } from "@/app_modules/investasi/fun/edit/fun_edit_status_by_id";
|
||||
import funDeleteInvestasi from "@/app_modules/investasi/fun/fun_delete_investasi";
|
||||
import { gs_investasi_status } from "@/app_modules/investasi/g_state";
|
||||
import { Button, Group, Stack } from "@mantine/core";
|
||||
import { useAtom } from "jotai";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
@@ -24,36 +22,65 @@ export default function Investasi_ViewDetailReject({
|
||||
dataInvestasi: MODEL_INVESTASI;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [investasi, setInvestasi] = useState(dataInvestasi);
|
||||
const [activeTab, setActiveTab] = useAtom(gs_investasi_status);
|
||||
const [data, setData] = useState(dataInvestasi);
|
||||
const [openModal, setOpenModal] = useState(false);
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
|
||||
async function onAjukan() {
|
||||
const res = await investasi_funEditStatusById({
|
||||
investasiId: dataInvestasi.id,
|
||||
investasiId: data.id,
|
||||
statusId: "3",
|
||||
});
|
||||
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil("Project Diajukan Kembali");
|
||||
setActiveTab("Draft");
|
||||
router.push(RouterInvestasi_OLD.portofolio);
|
||||
router.replace(NEW_RouterInvestasi.portofolio({ id: "3" }));
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal("Gagal Pengajuan");
|
||||
}
|
||||
}
|
||||
|
||||
async function onDelete() {
|
||||
await funDeleteInvestasi(investasi.id).then((res) => {
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setOpenModal(false);
|
||||
router.push(NEW_RouterInvestasi.portofolio({ id: "3" }));
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
const res = await funDeleteInvestasi(data.id);
|
||||
if (res.status === 200) {
|
||||
setLoading(true);
|
||||
|
||||
const delImage = await funGlobal_DeleteFileById({
|
||||
fileId: data.imageId,
|
||||
});
|
||||
if (!delImage.success) {
|
||||
ComponentAdminGlobal_NotifikasiPeringatan("Gagal hapus image ");
|
||||
}
|
||||
});
|
||||
// setActiveTab("Reject");
|
||||
|
||||
const delFileProspektus = await funGlobal_DeleteFileById({
|
||||
fileId: data.prospektusFileId,
|
||||
});
|
||||
if (!delFileProspektus.success) {
|
||||
ComponentAdminGlobal_NotifikasiPeringatan("Gagal hapus prospektus ");
|
||||
}
|
||||
|
||||
if (!_.isEmpty(data.DokumenInvestasi)) {
|
||||
for (let i of data.DokumenInvestasi) {
|
||||
const delFileDokumen = await funGlobal_DeleteFileById({
|
||||
fileId: i.fileId,
|
||||
});
|
||||
|
||||
if (!delFileDokumen.success) {
|
||||
ComponentAdminGlobal_NotifikasiPeringatan(
|
||||
"Gagal hapus prospektus "
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setOpenModal(false);
|
||||
router.replace(NEW_RouterInvestasi.portofolio({ id: "4" }));
|
||||
setLoading(false);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -69,7 +96,14 @@ export default function Investasi_ViewDetailReject({
|
||||
</Button>
|
||||
}
|
||||
buttonKanan={
|
||||
<Button bg={"red"} radius={"xl"} onClick={() => onDelete()}>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoading}
|
||||
color="red"
|
||||
bg={"red"}
|
||||
radius={"xl"}
|
||||
onClick={() => onDelete()}
|
||||
>
|
||||
Hapus
|
||||
</Button>
|
||||
}
|
||||
@@ -77,18 +111,14 @@ export default function Investasi_ViewDetailReject({
|
||||
|
||||
<Stack>
|
||||
{/* Alasan */}
|
||||
<ComponentGlobal_BoxInformation
|
||||
informasi={investasi.catatan}
|
||||
isReport
|
||||
/>
|
||||
<ComponentGlobal_BoxInformation informasi={data.catatan} isReport />
|
||||
|
||||
<Investasi_ComponentDetailDataNonPublish data={dataInvestasi} />
|
||||
|
||||
<Group position="apart" grow>
|
||||
<Group position="apart" grow mb={"xl"}>
|
||||
{/* Tombol Ajukan */}
|
||||
<Button
|
||||
mb={"xl"}
|
||||
radius={50}
|
||||
radius={"xl"}
|
||||
bg={"orange.7"}
|
||||
color="yellow"
|
||||
onClick={() => onAjukan()}
|
||||
@@ -98,10 +128,9 @@ export default function Investasi_ViewDetailReject({
|
||||
|
||||
{/* Tombol Hapus */}
|
||||
<Button
|
||||
mb={"xl"}
|
||||
radius={50}
|
||||
radius={"xl"}
|
||||
bg={"red.7"}
|
||||
color="yellow"
|
||||
color="red"
|
||||
onClick={() => setOpenModal(true)}
|
||||
>
|
||||
Hapus
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
NEW_RouterInvestasi,
|
||||
RouterInvestasi_OLD,
|
||||
} from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||
import { UIGlobal_Modal } from "@/app_modules/_global/ui";
|
||||
import { Investasi_ComponentDetailDataNonPublish } from "@/app_modules/investasi/_component";
|
||||
import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||
import { investasi_funEditStatusById } from "@/app_modules/investasi/fun/edit/fun_edit_status_by_id";
|
||||
import { gs_investasi_status } from "@/app_modules/investasi/g_state";
|
||||
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import { Button, Stack } from "@mantine/core";
|
||||
import { useAtom } from "jotai";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
@@ -25,13 +21,18 @@ export default function Investasi_ViewDetailReview({
|
||||
const router = useRouter();
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
const [data, setData] = useState<MODEL_INVESTASI>(dataInvestasi);
|
||||
const [openModal, setOpenModal] = useState(false);
|
||||
|
||||
async function onCancleReview() {
|
||||
async function onChangeStatus() {
|
||||
const res = await investasi_funEditStatusById({
|
||||
investasiId: data.id,
|
||||
statusId: "3",
|
||||
});
|
||||
if (res.status === 200) {
|
||||
setLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil("Review Dibatalkan");
|
||||
router.replace(NEW_RouterInvestasi.portofolio({ id: "3" }));
|
||||
|
||||
const dataNotif = {
|
||||
appId: res.data?.id,
|
||||
userId: res.data?.authorId,
|
||||
@@ -47,13 +48,11 @@ export default function Investasi_ViewDetailReview({
|
||||
|
||||
if (notif.status === 201) {
|
||||
mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 }));
|
||||
|
||||
setLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil("Review Dibatalkan");
|
||||
router.push(NEW_RouterInvestasi.portofolio({ id: "3" }));
|
||||
}
|
||||
setLoading(false);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,20 +64,41 @@ export default function Investasi_ViewDetailReview({
|
||||
<Stack>
|
||||
<Button
|
||||
mb={"xl"}
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
}}
|
||||
loaderPosition="center"
|
||||
loading={isLoading ? true : false}
|
||||
radius={50}
|
||||
bg={"orange"}
|
||||
color="yellow"
|
||||
onClick={() => onCancleReview()}
|
||||
c={"black"}
|
||||
onClick={() => setOpenModal(true)}
|
||||
>
|
||||
Batalkan Review
|
||||
</Button>
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
<UIGlobal_Modal
|
||||
opened={openModal}
|
||||
close={() => setOpenModal(false)}
|
||||
title={"Anda yakin ingin batalkan review?"}
|
||||
buttonKiri={
|
||||
<Button radius={"xl"} onClick={() => setOpenModal(false)}>
|
||||
Batal
|
||||
</Button>
|
||||
}
|
||||
buttonKanan={
|
||||
<Button
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
}}
|
||||
loaderPosition="center"
|
||||
loading={isLoading}
|
||||
radius={"xl"}
|
||||
color={"orange"}
|
||||
onClick={() => onChangeStatus()}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { APIs, DIRECTORY_ID } from "@/app/lib";
|
||||
import { MainColor } from "@/app_modules/_global/color";
|
||||
import {
|
||||
ComponentGlobal_BoxInformation,
|
||||
ComponentGlobal_BoxUploadImage,
|
||||
ComponentGlobal_LoadImage,
|
||||
} from "@/app_modules/_global/component";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
import { MODEL_DEFAULT_MASTER_OLD } from "@/app_modules/model_global/interface";
|
||||
import {
|
||||
AspectRatio,
|
||||
@@ -22,11 +20,8 @@ import {
|
||||
import { IconCamera } from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { useState } from "react";
|
||||
import { MODEL_INVESTASI } from "../../_lib/interface";
|
||||
import { investasi_funUpdateInvestasi } from "../../_fun";
|
||||
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
||||
import { Investasi_ComponentButtonUpdateDataInvestasi } from "../../_component";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { MODEL_INVESTASI } from "../../_lib/interface";
|
||||
|
||||
export function Investasi_ViewEditInvestasi({
|
||||
dataInvestasi,
|
||||
|
||||
Reference in New Issue
Block a user