Fix: admin investasi
Deskripsi: - Fix image dari server wibu ## No Issue
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import { MODEL_INVESTASI } from "../../_lib/interface";
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import _ from "lodash";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { MODEL_INVESTASI } from "../../_lib/interface";
|
||||
|
||||
export async function investasi_funUpdateInvestasi({
|
||||
data,
|
||||
@@ -39,7 +39,8 @@ export async function investasi_funUpdateInvestasi({
|
||||
});
|
||||
|
||||
if (!updtWithImage) return { status: 400, message: "Gagal update data" };
|
||||
revalidatePath(NEW_RouterInvestasi.detail_draft);
|
||||
revalidatePath("/dev/investasi/detail/portofolio/");
|
||||
|
||||
return { status: 200, message: "Berhasil update" };
|
||||
} else {
|
||||
const updtNoImage = await prisma.investasi.update({
|
||||
@@ -61,7 +62,8 @@ export async function investasi_funUpdateInvestasi({
|
||||
});
|
||||
|
||||
if (!updtNoImage) return { status: 400, message: "Gagal update data" };
|
||||
revalidatePath(NEW_RouterInvestasi.detail_draft);
|
||||
revalidatePath("/dev/investasi/detail/portofolio/");
|
||||
|
||||
return { status: 200, message: "Berhasil update" };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import {
|
||||
UIGlobal_Drawer,
|
||||
UIGlobal_DrawerCustom,
|
||||
UIGlobal_LayoutHeaderTamplate,
|
||||
UIGlobal_LayoutTamplate,
|
||||
} from "@/app_modules/_global/ui";
|
||||
import { ActionIcon } from "@mantine/core";
|
||||
import { ActionIcon, Box, SimpleGrid, Stack, Text } from "@mantine/core";
|
||||
import {
|
||||
IconCategoryPlus,
|
||||
IconDotsVertical,
|
||||
@@ -21,16 +22,20 @@ import {
|
||||
Investasi_ViewDetailReject,
|
||||
Investasi_ViewDetailReview,
|
||||
} from "../../_view";
|
||||
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
|
||||
|
||||
export function Investasi_UiDetailPortofolio({
|
||||
data,
|
||||
dataInvestasi,
|
||||
userLoginId,
|
||||
}: {
|
||||
data: MODEL_INVESTASI;
|
||||
dataInvestasi: MODEL_INVESTASI;
|
||||
userLoginId: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
const [pageId, setPageId] = useState("");
|
||||
const [openDrawer, setOpenDrawer] = useState(false);
|
||||
const [data, setData] = useState<any>(dataInvestasi);
|
||||
const listPage = [
|
||||
{
|
||||
id: "1",
|
||||
@@ -70,13 +75,47 @@ export function Investasi_UiDetailPortofolio({
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Investasi_ViewDetailDraft dataInvestasi={data} />
|
||||
<Investasi_ViewDetailDraft dataInvestasi={dataInvestasi} />
|
||||
</UIGlobal_LayoutTamplate>
|
||||
|
||||
<UIGlobal_Drawer
|
||||
{/* <UIGlobal_Drawer
|
||||
opened={openDrawer}
|
||||
close={() => setOpenDrawer(false)}
|
||||
component={listPage}
|
||||
/> */}
|
||||
|
||||
<UIGlobal_DrawerCustom
|
||||
opened={openDrawer}
|
||||
close={() => setOpenDrawer(false)}
|
||||
component={
|
||||
<SimpleGrid cols={listPage.length}>
|
||||
{listPage.map((e, i) => (
|
||||
<Stack key={i} align="center" spacing={"xs"}>
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
c="white"
|
||||
onClick={() => {
|
||||
setPageId(e?.id);
|
||||
setLoading(true);
|
||||
if (e.id === "1") {
|
||||
setData({});
|
||||
}
|
||||
router.push(e?.path, { scroll: false });
|
||||
}}
|
||||
>
|
||||
{isLoading && e?.id === pageId ? (
|
||||
<ComponentGlobal_Loader />
|
||||
) : (
|
||||
e?.icon
|
||||
)}
|
||||
</ActionIcon>
|
||||
<Text fz={"sm"} align="center" color="white">
|
||||
{e?.name}
|
||||
</Text>
|
||||
</Stack>
|
||||
))}
|
||||
</SimpleGrid>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
@@ -85,23 +124,16 @@ export function Investasi_UiDetailPortofolio({
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={
|
||||
<UIGlobal_LayoutHeaderTamplate
|
||||
title={`Detail ${data.MasterStatusInvestasi.name}`}
|
||||
title={`Detail ${dataInvestasi.MasterStatusInvestasi.name}`}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{/* {data.masterStatusInvestasiId === "1" && (
|
||||
<Investasi_ViewDetailPublish
|
||||
dataInvestasi={data}
|
||||
userLoginId={userLoginId}
|
||||
/>
|
||||
)} */}
|
||||
|
||||
{data.masterStatusInvestasiId === "2" && (
|
||||
<Investasi_ViewDetailReview dataInvestasi={data} />
|
||||
{dataInvestasi.masterStatusInvestasiId === "2" && (
|
||||
<Investasi_ViewDetailReview dataInvestasi={dataInvestasi} />
|
||||
)}
|
||||
|
||||
{data.masterStatusInvestasiId === "4" && (
|
||||
<Investasi_ViewDetailReject dataInvestasi={data} />
|
||||
{dataInvestasi.masterStatusInvestasiId === "4" && (
|
||||
<Investasi_ViewDetailReject dataInvestasi={dataInvestasi} />
|
||||
)}
|
||||
</UIGlobal_LayoutTamplate>
|
||||
);
|
||||
|
||||
@@ -18,7 +18,6 @@ export function Investasi_UiPortofolio({
|
||||
}) {
|
||||
const [activeTab, setActiveTab] = useState<string | null>(statusId);
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState(dataPortofolio);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -61,7 +60,7 @@ export function Investasi_UiPortofolio({
|
||||
|
||||
<Investasi_ViewPortofolio
|
||||
statusId={statusId}
|
||||
dataPortofolio={data as any}
|
||||
dataPortofolio={dataPortofolio as any}
|
||||
/>
|
||||
</Stack>
|
||||
</Tabs>
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterAdminInvestasi_OLD } from "@/app/lib/router_hipmi/router_admin";
|
||||
import { RouterInvestasi_OLD } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import {
|
||||
NEW_RouterInvestasi
|
||||
} from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export default async function funDeleteInvestasi(id: string) {
|
||||
@@ -14,7 +15,8 @@ export default async function funDeleteInvestasi(id: string) {
|
||||
|
||||
if (!res) return { status: 400, message: "Gagal Hapus Data" };
|
||||
|
||||
revalidatePath(RouterInvestasi_OLD.portofolio);
|
||||
revalidatePath(NEW_RouterInvestasi.portofolio({ id: "3" }));
|
||||
revalidatePath(NEW_RouterInvestasi.portofolio({ id: "4" }));
|
||||
|
||||
return {
|
||||
status: 200,
|
||||
|
||||
@@ -47,6 +47,7 @@ export default async function getOneInvestasiById(id: string) {
|
||||
},
|
||||
},
|
||||
countDown: true,
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user