Fix: Upload image
- Upload image berita ke server wibu - Tampilan detail image di ambil dari server wibu ## No issue
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import {
|
||||
NEW_RouterInvestasi,
|
||||
RouterInvestasi_OLD,
|
||||
} from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { AccentColor } from "@/app_modules/_global/color";
|
||||
import { ActionIcon, Flex, Loader, Paper, Text } from "@mantine/core";
|
||||
import { IconFileDescription } from "@tabler/icons-react";
|
||||
@@ -25,14 +28,13 @@ export function Investasi_ComponentBoxDaftarBerita({
|
||||
}}
|
||||
onClick={() => {
|
||||
setLoading(true);
|
||||
router.push(
|
||||
NEW_RouterInvestasi.detail_prospektus({ id: investasiId }),
|
||||
{ scroll: false }
|
||||
);
|
||||
router.push(NEW_RouterInvestasi.daftar_berita({ id: investasiId }), {
|
||||
scroll: false,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Flex direction={"column"} align={"center"} justify={"center"}>
|
||||
<Text fz={12}>Berita</Text>
|
||||
<Text fz={12}>Berita </Text>
|
||||
<ActionIcon radius={"xl"} variant="transparent" size={60}>
|
||||
{isLoading ? (
|
||||
<Loader color="yellow" />
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { RouterInvestasi_OLD } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import {
|
||||
ComponentGlobal_AvatarAndUsername,
|
||||
ComponentGlobal_CardStyles,
|
||||
@@ -6,16 +5,13 @@ import {
|
||||
} from "@/app_modules/_global/component";
|
||||
import { MODEL_INVOICE_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||
import {
|
||||
AspectRatio,
|
||||
Box,
|
||||
Grid,
|
||||
Image,
|
||||
SimpleGrid,
|
||||
Stack,
|
||||
Text,
|
||||
Title,
|
||||
Title
|
||||
} from "@mantine/core";
|
||||
import { Investasi_ComponentStylesCard } from "../../comp_card_border_and_background";
|
||||
import { Investasi_ComponentBoxDaftarBerita } from "../comp_box_daftar_berita";
|
||||
import { Investasi_ComponentBoxDaftarDokumen } from "../comp_box_daftar_dokumen";
|
||||
import { Investasi_ComponentBoxProspektus } from "../comp_box_prospektus";
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { RouterInvestasi_OLD } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import {
|
||||
NEW_RouterInvestasi,
|
||||
RouterInvestasi_OLD,
|
||||
} from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { Warna } from "@/app/lib/warna";
|
||||
import {
|
||||
AccentColor,
|
||||
@@ -46,7 +49,9 @@ export function Investasi_ComponentCardBeranda({
|
||||
onClickHandler={() => {
|
||||
setLoadingDetail(true);
|
||||
setVisible(true);
|
||||
router.push(RouterInvestasi_OLD.detail + `${data?.id}`);
|
||||
router.push(NEW_RouterInvestasi.detail_main({ id: data.id }), {
|
||||
scroll: false,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Stack>
|
||||
@@ -59,7 +64,9 @@ export function Investasi_ComponentCardBeranda({
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Stack>
|
||||
<Text fw={"bold"} align="center" lineClamp={2}>{data?.title}</Text>
|
||||
<Text fw={"bold"} align="center" lineClamp={2}>
|
||||
{data?.title}
|
||||
</Text>
|
||||
|
||||
<Progress
|
||||
label={(+data?.progress).toFixed(2) + " %"}
|
||||
|
||||
@@ -19,7 +19,10 @@ import { MODEL_INVESTASI } from "../../_lib/interface";
|
||||
import { Investasi_ComponentStylesCard } from "../comp_card_border_and_background";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { ComponentGlobal_CardLoadingOverlay } from "@/app_modules/_global/component";
|
||||
import {
|
||||
ComponentGlobal_CardLoadingOverlay,
|
||||
ComponentGlobal_LoadImageCustom,
|
||||
} from "@/app_modules/_global/component";
|
||||
|
||||
export function Investasi_ComponentCardPortofolioPublish({
|
||||
data,
|
||||
@@ -34,7 +37,9 @@ export function Investasi_ComponentCardPortofolioPublish({
|
||||
<Investasi_ComponentStylesCard
|
||||
marginBottom={"15px"}
|
||||
onClickHandler={() => {
|
||||
router.push(NEW_RouterInvestasi.detail_portofolio({ id: data?.id }));
|
||||
router.push(NEW_RouterInvestasi.detail_main({ id: data?.id }), {
|
||||
scroll: false,
|
||||
});
|
||||
setVisible(true);
|
||||
}}
|
||||
>
|
||||
@@ -53,14 +58,10 @@ export function Investasi_ComponentCardPortofolioPublish({
|
||||
</Grid.Col>
|
||||
|
||||
<Grid.Col span={4}>
|
||||
<AspectRatio ratio={16 / 9}>
|
||||
<Paper radius={"md"}>
|
||||
<Image
|
||||
alt=""
|
||||
src={NEW_RouterInvestasi.api_gambar + `${data?.imagesId}`}
|
||||
/>
|
||||
</Paper>
|
||||
</AspectRatio>
|
||||
<ComponentGlobal_LoadImageCustom
|
||||
height={80}
|
||||
fileId={data.imageId}
|
||||
/>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
|
||||
@@ -87,18 +87,6 @@ export function Investasi_ComponentSahamSaya({
|
||||
</SimpleGrid>
|
||||
{visible && <ComponentGlobal_CardLoadingOverlay />}
|
||||
</Investasi_ComponentStylesCard>
|
||||
|
||||
{/* <Card
|
||||
style={{
|
||||
padding: "15px",
|
||||
backgroundColor: AccentColor.darkblue,
|
||||
border: `2px solid ${AccentColor.blue}`,
|
||||
borderRadius: "10px",
|
||||
color: "white",
|
||||
marginBottom: "15px",
|
||||
}}
|
||||
onClick={}
|
||||
></Card> */}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
45
src/app_modules/investasi/_fun/create/fun_create_berita.tsx
Normal file
45
src/app_modules/investasi/_fun/create/fun_create_berita.tsx
Normal file
@@ -0,0 +1,45 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import _ from "lodash";
|
||||
import { Model_Berita_Investasi } from "../../_lib/interface";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
|
||||
export async function investasi_funCreateBerita({
|
||||
data,
|
||||
fileId,
|
||||
}: {
|
||||
data: Model_Berita_Investasi | any;
|
||||
fileId?: string;
|
||||
}) {
|
||||
if (fileId != undefined) {
|
||||
const createWithFile = await prisma.beritaInvestasi.create({
|
||||
data: {
|
||||
title: _.startCase(data.title),
|
||||
deskripsi: data.deskripsi,
|
||||
investasiId: data.investasiId,
|
||||
imageId: fileId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!createWithFile)
|
||||
return { status: 400, message: "Gagal menambah berita" };
|
||||
|
||||
revalidatePath(NEW_RouterInvestasi.rekap_berita({ id: data.investasiId }));
|
||||
return { status: 201, message: "Berhasil menambah berita" };
|
||||
} else {
|
||||
const createNoFile = await prisma.beritaInvestasi.create({
|
||||
data: {
|
||||
title: _.startCase(data.title),
|
||||
deskripsi: data.deskripsi,
|
||||
investasiId: data.investasiId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!createNoFile) return { status: 400, message: "Gagal menambah berita" };
|
||||
|
||||
revalidatePath(NEW_RouterInvestasi.rekap_berita({ id: data.investasiId }));
|
||||
return { status: 201, message: "Berhasil menambah berita " };
|
||||
}
|
||||
}
|
||||
23
src/app_modules/investasi/_fun/delete/fun_delete_berita.tsx
Normal file
23
src/app_modules/investasi/_fun/delete/fun_delete_berita.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function investasi_funDeleteBerita({
|
||||
beritaId,
|
||||
}: {
|
||||
beritaId: string;
|
||||
}) {
|
||||
const del = await prisma.beritaInvestasi.delete({
|
||||
where: {
|
||||
id: beritaId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!del) return { status: 400, message: "Gagal hapus data" };
|
||||
revalidatePath(
|
||||
NEW_RouterInvestasi.rekap_berita({ id: del.investasiId as any })
|
||||
);
|
||||
return { status: 200, message: "Berhasil hapus data" };
|
||||
}
|
||||
24
src/app_modules/investasi/_fun/get/fun_get_berita_by_id.tsx
Normal file
24
src/app_modules/investasi/_fun/get/fun_get_berita_by_id.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function investasi_funGetBeritaById({
|
||||
investasiId,
|
||||
}: {
|
||||
investasiId: string;
|
||||
}) {
|
||||
const data = prisma.beritaInvestasi.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
investasiId: investasiId,
|
||||
active: true,
|
||||
},
|
||||
});
|
||||
|
||||
revalidatePath(NEW_RouterInvestasi.rekap_berita({ id: investasiId }));
|
||||
return data;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
|
||||
export async function investasi_funGetOneBeritaById({
|
||||
beritaId,
|
||||
}: {
|
||||
beritaId: any;
|
||||
}) {
|
||||
const data = await prisma.beritaInvestasi.findFirst({
|
||||
where: {
|
||||
id: beritaId,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -16,6 +16,7 @@ export async function investasi_funGetOneInvestasiById({
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
Investasi_Invoice: true,
|
||||
MasterStatusInvestasi: true,
|
||||
BeritaInvestasi: true,
|
||||
DokumenInvestasi: true,
|
||||
@@ -24,7 +25,6 @@ export async function investasi_funGetOneInvestasiById({
|
||||
MasterPencarianInvestor: true,
|
||||
MasterPeriodeDeviden: true,
|
||||
MasterProgresInvestasi: true,
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -14,10 +14,15 @@ import { investasi_funCreateDocument } from "./create/fun_create_document";
|
||||
import { investasi_funGetOneDocumentById } from "./get/fun_get_one_document_by_id";
|
||||
import { investasi_funUpdateDocument } from "./edit/fun_edit_document";
|
||||
import { investasi_funDeleteDokumenById } from "./delete/fun_delete_dokumen";
|
||||
import { investasi_funCreateBerita } from "./create/fun_create_berita";
|
||||
import { investasi_funGetBeritaById } from "./get/fun_get_berita_by_id";
|
||||
import { investasi_funGetOneBeritaById } from "./get/fun_get_one_berita_by_id";
|
||||
import { investasi_funDeleteBerita } from "./delete/fun_delete_berita";
|
||||
|
||||
// Create
|
||||
export { investasi_funCreateNewInvestasi };
|
||||
export { investasi_funCreateDocument };
|
||||
export { investasi_funCreateBerita };
|
||||
|
||||
// Get
|
||||
export { investasi_funGetOneInvestasiById };
|
||||
@@ -29,6 +34,8 @@ export { investasi_funGetAllInvestasiNonPublishByUserId };
|
||||
export { investasi_funGetPortofolioByStatusId };
|
||||
export { investasi_funGetAllDocumentById };
|
||||
export { investasi_funGetOneDocumentById };
|
||||
export { investasi_funGetBeritaById };
|
||||
export { investasi_funGetOneBeritaById };
|
||||
|
||||
// Update
|
||||
export { investasi_funUpdateInvestasi };
|
||||
@@ -40,3 +47,4 @@ export { investasi_funUploadBuktiTransferById };
|
||||
|
||||
// Delete
|
||||
export { investasi_funDeleteDokumenById };
|
||||
export { investasi_funDeleteBerita };
|
||||
|
||||
23
src/app_modules/investasi/_ui/create/ui_create_berita.tsx
Normal file
23
src/app_modules/investasi/_ui/create/ui_create_berita.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
UIGlobal_LayoutHeaderTamplate,
|
||||
UIGlobal_LayoutTamplate,
|
||||
} from "@/app_modules/_global/ui";
|
||||
import { Investasi_ViewCreateBerita } from "../../_view";
|
||||
|
||||
export function Investasi_UiCreateBerita({
|
||||
investasiId,
|
||||
}: {
|
||||
investasiId: string;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={<UIGlobal_LayoutHeaderTamplate title="Tambah Berita" />}
|
||||
>
|
||||
<Investasi_ViewCreateBerita investasiId={investasiId} />
|
||||
</UIGlobal_LayoutTamplate>
|
||||
</>
|
||||
);
|
||||
}
|
||||
115
src/app_modules/investasi/_ui/detail/ui_berita.tsx
Normal file
115
src/app_modules/investasi/_ui/detail/ui_berita.tsx
Normal file
@@ -0,0 +1,115 @@
|
||||
"use client";
|
||||
|
||||
import { funGlobal_DeleteFileById } from "@/app_modules/_global/fun";
|
||||
import {
|
||||
ComponentGlobal_NotifikasiBerhasil,
|
||||
ComponentGlobal_NotifikasiGagal,
|
||||
ComponentGlobal_NotifikasiPeringatan,
|
||||
} from "@/app_modules/_global/notif_global";
|
||||
import {
|
||||
UIGlobal_DrawerCustom,
|
||||
UIGlobal_LayoutHeaderTamplate,
|
||||
UIGlobal_LayoutTamplate,
|
||||
UIGlobal_Modal
|
||||
} from "@/app_modules/_global/ui";
|
||||
import { ActionIcon, Button, Center, Stack, Text } from "@mantine/core";
|
||||
import { IconDotsVertical, IconTrash } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { investasi_funDeleteBerita } from "../../_fun";
|
||||
import { Investasi_ViewDetailBerita } from "../../_view";
|
||||
|
||||
export function Investasi_UiDetailBerita({ dataBerita }: { dataBerita: any }) {
|
||||
const router = useRouter();
|
||||
const [openDrawer, setOpenDrawer] = useState(false);
|
||||
const [openModal, setOpenModal] = useState(false);
|
||||
const [data, setData] = useState(dataBerita);
|
||||
|
||||
async function onDelete() {
|
||||
const del = await investasi_funDeleteBerita({
|
||||
beritaId: dataBerita.id,
|
||||
});
|
||||
|
||||
if (del.status === 200) {
|
||||
const deleteImage = await funGlobal_DeleteFileById({
|
||||
fileId: data.imageId,
|
||||
});
|
||||
|
||||
if (!deleteImage.success) {
|
||||
ComponentGlobal_NotifikasiPeringatan("Gagal hapus gambar ");
|
||||
}
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(del.message);
|
||||
setOpenModal(false);
|
||||
router.back();
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(del.message);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={
|
||||
<UIGlobal_LayoutHeaderTamplate
|
||||
title="Detail Berita"
|
||||
customButtonRight={
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => setOpenDrawer(true)}
|
||||
>
|
||||
<IconDotsVertical color="white" />
|
||||
</ActionIcon>
|
||||
}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Investasi_ViewDetailBerita dataBerita={data} />
|
||||
</UIGlobal_LayoutTamplate>
|
||||
|
||||
<UIGlobal_DrawerCustom
|
||||
opened={openDrawer}
|
||||
close={() => setOpenDrawer(false)}
|
||||
component={
|
||||
<Center>
|
||||
<Stack
|
||||
align="center"
|
||||
spacing={"xs"}
|
||||
onClick={() => {
|
||||
setOpenDrawer(false);
|
||||
setOpenModal(true);
|
||||
}}
|
||||
>
|
||||
<ActionIcon variant="transparent">
|
||||
<IconTrash color="red" />
|
||||
</ActionIcon>
|
||||
<Text c={"red"}>Hapus berita</Text>
|
||||
</Stack>
|
||||
</Center>
|
||||
}
|
||||
/>
|
||||
|
||||
<UIGlobal_Modal
|
||||
opened={openModal}
|
||||
close={() => setOpenModal(false)}
|
||||
title={"Anda yakin ingin menghapus berita ini ?"}
|
||||
buttonKiri={
|
||||
<Button radius="xl" onClick={() => setOpenModal(false)}>
|
||||
Batal
|
||||
</Button>
|
||||
}
|
||||
buttonKanan={
|
||||
<Button
|
||||
radius="xl"
|
||||
color="red"
|
||||
onClick={() => {
|
||||
onDelete();
|
||||
}}
|
||||
>
|
||||
Hapus
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
21
src/app_modules/investasi/_ui/detail/ui_daftar_berita.tsx
Normal file
21
src/app_modules/investasi/_ui/detail/ui_daftar_berita.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
UIGlobal_LayoutHeaderTamplate,
|
||||
UIGlobal_LayoutTamplate,
|
||||
} from "@/app_modules/_global/ui";
|
||||
import { Investasi_ViewDaftarBerita } from "../../_view";
|
||||
|
||||
export function Investasi_UiDaftarBerita({
|
||||
dataBerita,
|
||||
}: {
|
||||
dataBerita: any[];
|
||||
}) {
|
||||
return (
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={<UIGlobal_LayoutHeaderTamplate title="Daftar Berita" />}
|
||||
>
|
||||
<Investasi_ViewDaftarBerita dataBerita={dataBerita} />
|
||||
</UIGlobal_LayoutTamplate>
|
||||
);
|
||||
}
|
||||
79
src/app_modules/investasi/_ui/detail/ui_detail_main.tsx
Normal file
79
src/app_modules/investasi/_ui/detail/ui_detail_main.tsx
Normal file
@@ -0,0 +1,79 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
UIGlobal_Drawer,
|
||||
UIGlobal_LayoutHeaderTamplate,
|
||||
UIGlobal_LayoutTamplate,
|
||||
} from "@/app_modules/_global/ui";
|
||||
import { ActionIcon } from "@mantine/core";
|
||||
import { IconCategoryPlus, IconDotsVertical } from "@tabler/icons-react";
|
||||
import { MODEL_INVESTASI } from "../../_lib/interface";
|
||||
import { Investasi_ViewDetailPublish } from "../../_view";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
NEW_RouterInvestasi,
|
||||
RouterInvestasi_OLD,
|
||||
} from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { IconDeviceIpadPlus } from "@tabler/icons-react";
|
||||
|
||||
export function Investasi_UiDetailMain({
|
||||
dataInvestasi,
|
||||
userLoginId,
|
||||
}: {
|
||||
dataInvestasi: MODEL_INVESTASI;
|
||||
userLoginId: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [openDrawer, setOpenDrawer] = useState(false);
|
||||
|
||||
const listPage = [
|
||||
{
|
||||
id: "1",
|
||||
name: "Tambah & Edit Dokumen",
|
||||
icon: <IconCategoryPlus />,
|
||||
path: NEW_RouterInvestasi.rekap_dokumen({ id: dataInvestasi.id }),
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
name: "Tambah & Edit Berita",
|
||||
icon: <IconDeviceIpadPlus />,
|
||||
path: NEW_RouterInvestasi.rekap_berita({ id: dataInvestasi.id }),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<>
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={
|
||||
<UIGlobal_LayoutHeaderTamplate
|
||||
title="Detail "
|
||||
customButtonRight={
|
||||
userLoginId === dataInvestasi.authorId ? (
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => setOpenDrawer(true)}
|
||||
>
|
||||
<IconDotsVertical color="white" />
|
||||
</ActionIcon>
|
||||
) : (
|
||||
<ActionIcon disabled variant="transparent" />
|
||||
)
|
||||
}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Investasi_ViewDetailPublish
|
||||
dataInvestasi={dataInvestasi}
|
||||
userLoginId={userLoginId}
|
||||
/>
|
||||
</UIGlobal_LayoutTamplate>
|
||||
|
||||
<UIGlobal_Drawer
|
||||
opened={openDrawer}
|
||||
close={() => setOpenDrawer(false)}
|
||||
component={listPage}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -13,20 +13,23 @@ import {
|
||||
IconEdit,
|
||||
IconFilePencil,
|
||||
} from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { MODEL_INVESTASI } from "../../_lib/interface";
|
||||
import {
|
||||
Investasi_ViewDetailDraft,
|
||||
Investasi_ViewDetailPublish,
|
||||
Investasi_ViewDetailReject,
|
||||
Investasi_ViewDetailReview,
|
||||
} from "../../_view";
|
||||
|
||||
export function Investasi_UiDetailPortofolio({
|
||||
data,
|
||||
userLoginId,
|
||||
}: {
|
||||
data: MODEL_INVESTASI;
|
||||
userLoginId: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [openDrawer, setOpenDrawer] = useState(false);
|
||||
const listPage = [
|
||||
{
|
||||
@@ -86,9 +89,12 @@ export function Investasi_UiDetailPortofolio({
|
||||
/>
|
||||
}
|
||||
>
|
||||
{data.masterStatusInvestasiId === "1" && (
|
||||
<Investasi_ViewDetailPublish dataInvestasi={data} />
|
||||
)}
|
||||
{/* {data.masterStatusInvestasiId === "1" && (
|
||||
<Investasi_ViewDetailPublish
|
||||
dataInvestasi={data}
|
||||
userLoginId={userLoginId}
|
||||
/>
|
||||
)} */}
|
||||
|
||||
{data.masterStatusInvestasiId === "2" && (
|
||||
<Investasi_ViewDetailReview dataInvestasi={data} />
|
||||
|
||||
63
src/app_modules/investasi/_ui/detail/ui_rekap_berita.tsx
Normal file
63
src/app_modules/investasi/_ui/detail/ui_rekap_berita.tsx
Normal file
@@ -0,0 +1,63 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
UIGlobal_Drawer,
|
||||
UIGlobal_LayoutHeaderTamplate,
|
||||
UIGlobal_LayoutTamplate,
|
||||
} from "@/app_modules/_global/ui";
|
||||
import { ActionIcon } from "@mantine/core";
|
||||
import { IconCirclePlus, IconDotsVertical } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { Investasi_ViewRekapBerita } from "../../_view";
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
|
||||
export function Investasi_UiRekapBerita({
|
||||
investasiId,
|
||||
dataBerita,
|
||||
}: {
|
||||
investasiId: string;
|
||||
dataBerita: any[]
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [openDrawer, setOpenDrawer] = useState(false);
|
||||
|
||||
const listPage = [
|
||||
{
|
||||
id: "1",
|
||||
name: "Tambah Berita",
|
||||
icon: <IconCirclePlus />,
|
||||
path: NEW_RouterInvestasi.create_berita({ id: investasiId }),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={
|
||||
<UIGlobal_LayoutHeaderTamplate
|
||||
title="Rekap Berita"
|
||||
customButtonRight={
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => {
|
||||
setOpenDrawer(true);
|
||||
}}
|
||||
>
|
||||
<IconDotsVertical color="white" />
|
||||
</ActionIcon>
|
||||
}
|
||||
/>
|
||||
}
|
||||
>
|
||||
|
||||
|
||||
<Investasi_ViewRekapBerita dataBerita={dataBerita} />
|
||||
|
||||
<UIGlobal_Drawer
|
||||
opened={openDrawer}
|
||||
close={() => setOpenDrawer(false)}
|
||||
component={listPage}
|
||||
/>
|
||||
</UIGlobal_LayoutTamplate>
|
||||
);
|
||||
}
|
||||
@@ -19,6 +19,11 @@ import { Investasi_UiEditInvestasi } from "./edit/ui_edit_investasi";
|
||||
import { Investasi_UiEditProspektus } from "./edit/ui_edit_prospektus";
|
||||
import { Investasi_UiCreateDocument } from "./create/ui_create_document";
|
||||
import { Investasi_UiRekapDokumen } from "./detail/ui_rekap_dokumen";
|
||||
import { Investasi_UiDetailMain } from "./detail/ui_detail_main";
|
||||
import { Investasi_UiDaftarBerita } from "./detail/ui_daftar_berita";
|
||||
import { Investasi_UiRekapBerita } from "./detail/ui_rekap_berita";
|
||||
import { Investasi_UiCreateBerita } from "./create/ui_create_berita";
|
||||
import { Investasi_UiDetailBerita } from "./detail/ui_berita";
|
||||
|
||||
export { Investasi_UiProsesPembelian };
|
||||
export { Investasi_UiMetodePembayaran };
|
||||
@@ -41,3 +46,8 @@ export { Investasi_UiEditInvestasi };
|
||||
export { Investasi_UiEditProspektus };
|
||||
export { Investasi_UiCreateDocument };
|
||||
export { Investasi_UiRekapDokumen };
|
||||
export { Investasi_UiDetailMain };
|
||||
export { Investasi_UiDaftarBerita };
|
||||
export { Investasi_UiRekapBerita };
|
||||
export { Investasi_UiCreateBerita };
|
||||
export { Investasi_UiDetailBerita };
|
||||
|
||||
206
src/app_modules/investasi/_view/create/view_create_berita.tsx
Normal file
206
src/app_modules/investasi/_view/create/view_create_berita.tsx
Normal file
@@ -0,0 +1,206 @@
|
||||
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
||||
import {
|
||||
ComponentGlobal_BoxInformation,
|
||||
ComponentGlobal_BoxUploadImage,
|
||||
ComponentGlobal_InputCountDown,
|
||||
} from "@/app_modules/_global/component";
|
||||
import {
|
||||
ComponentGlobal_NotifikasiBerhasil,
|
||||
ComponentGlobal_NotifikasiGagal,
|
||||
ComponentGlobal_NotifikasiPeringatan,
|
||||
} from "@/app_modules/_global/notif_global";
|
||||
import {
|
||||
AspectRatio,
|
||||
Button,
|
||||
Center,
|
||||
FileButton,
|
||||
Image,
|
||||
Stack,
|
||||
Text,
|
||||
TextInput,
|
||||
Textarea,
|
||||
} from "@mantine/core";
|
||||
import { IconCamera, IconUpload } from "@tabler/icons-react";
|
||||
|
||||
import { DIRECTORY_ID } from "@/app/lib";
|
||||
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { investasi_funCreateBerita } from "../../_fun";
|
||||
|
||||
export function Investasi_ViewCreateBerita({
|
||||
investasiId,
|
||||
}: {
|
||||
investasiId: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [file, setFile] = useState<File | null>(null);
|
||||
const [img, setImg] = useState<any | null>();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const [data, setData] = useState<Prisma.BeritaInvestasiCreateArgs>({
|
||||
data: {
|
||||
title: "",
|
||||
deskripsi: "",
|
||||
investasiId: investasiId,
|
||||
},
|
||||
});
|
||||
|
||||
async function onCreate() {
|
||||
if (data.data.title == "" || data.data.deskripsi == "")
|
||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi data");
|
||||
|
||||
try {
|
||||
setIsLoading(true);
|
||||
if (file != null) {
|
||||
const uploadFile = await funGlobal_UploadToStorage({
|
||||
file: file as File,
|
||||
dirId: DIRECTORY_ID.investasi_berita,
|
||||
});
|
||||
|
||||
if (!uploadFile.success)
|
||||
return ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar");
|
||||
|
||||
const createWithFile = await investasi_funCreateBerita({
|
||||
data: data.data as any,
|
||||
fileId: uploadFile.data.id,
|
||||
});
|
||||
|
||||
createWithFile.status === 201
|
||||
? (ComponentGlobal_NotifikasiBerhasil(createWithFile.message),
|
||||
router.back())
|
||||
: ComponentGlobal_NotifikasiGagal(createWithFile.message);
|
||||
} else {
|
||||
const createNoFile = await investasi_funCreateBerita({
|
||||
data: data.data as any,
|
||||
});
|
||||
|
||||
createNoFile.status === 201
|
||||
? (ComponentGlobal_NotifikasiBerhasil(createNoFile.message),
|
||||
router.back())
|
||||
: ComponentGlobal_NotifikasiGagal(createNoFile.message);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack px={"sm"}>
|
||||
<ComponentGlobal_BoxInformation informasi="Pengunggahan foto ke aplikasi bersifat opsional dan tidak diwajibkan, Anda dapat menyimpan berita tanpa mengunggah foto." />
|
||||
|
||||
<Stack spacing={5}>
|
||||
<ComponentGlobal_BoxUploadImage>
|
||||
{img ? (
|
||||
<AspectRatio ratio={1 / 1} mt={5} maw={300} mx={"auto"}>
|
||||
<Image
|
||||
style={{ maxHeight: 250 }}
|
||||
alt="Foto"
|
||||
height={250}
|
||||
src={img}
|
||||
/>
|
||||
</AspectRatio>
|
||||
) : (
|
||||
<Stack justify="center" align="center" h={"100%"}>
|
||||
<IconUpload color="white" />
|
||||
<Text fz={10} fs={"italic"} c={"white"} fw={"bold"}>
|
||||
Upload Gambar
|
||||
</Text>
|
||||
</Stack>
|
||||
)}
|
||||
</ComponentGlobal_BoxUploadImage>
|
||||
|
||||
<Center>
|
||||
<FileButton
|
||||
onChange={async (files: any | null) => {
|
||||
try {
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
setImg(buffer);
|
||||
setFile(files);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}}
|
||||
accept="image/png,image/jpeg"
|
||||
>
|
||||
{(props) => (
|
||||
<Button
|
||||
{...props}
|
||||
radius={"xl"}
|
||||
w={100}
|
||||
style={{
|
||||
backgroundColor: MainColor.yellow,
|
||||
border: `1px solid ${AccentColor.yellow}`,
|
||||
}}
|
||||
>
|
||||
<IconCamera color="black" />
|
||||
</Button>
|
||||
)}
|
||||
</FileButton>
|
||||
</Center>
|
||||
</Stack>
|
||||
|
||||
<TextInput
|
||||
withAsterisk
|
||||
placeholder="Masukan judul berita"
|
||||
styles={{
|
||||
label: {
|
||||
color: "white",
|
||||
},
|
||||
}}
|
||||
label="Judul berita"
|
||||
onChange={(val) => {
|
||||
setData({ data: { ...data.data, title: val.target.value } });
|
||||
}}
|
||||
/>
|
||||
|
||||
<Stack spacing={5}>
|
||||
<Textarea
|
||||
withAsterisk
|
||||
placeholder="Masukan deskripsi berita"
|
||||
styles={{
|
||||
label: {
|
||||
color: "white",
|
||||
},
|
||||
}}
|
||||
label="Deskripsi"
|
||||
autosize
|
||||
maxLength={500}
|
||||
minRows={2}
|
||||
maxRows={6}
|
||||
onChange={(val) => {
|
||||
setData({
|
||||
data: { ...data.data, deskripsi: val.target.value },
|
||||
});
|
||||
}}
|
||||
/>
|
||||
<ComponentGlobal_InputCountDown
|
||||
lengthInput={data.data.deskripsi.length}
|
||||
maxInput={500}
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoading}
|
||||
my={"md"}
|
||||
radius={50}
|
||||
bg={MainColor.yellow}
|
||||
color="yellow"
|
||||
c={"black"}
|
||||
onClick={() => {
|
||||
onCreate();
|
||||
}}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,232 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { RouterInvestasi_OLD } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||
import {
|
||||
ActionIcon,
|
||||
AspectRatio,
|
||||
Box,
|
||||
Flex,
|
||||
Grid,
|
||||
Group,
|
||||
Image,
|
||||
Paper,
|
||||
Progress,
|
||||
Stack,
|
||||
Text,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import {
|
||||
IconBookDownload,
|
||||
IconCircleCheck,
|
||||
IconFileDescription,
|
||||
IconSpeakerphone,
|
||||
} from "@tabler/icons-react";
|
||||
import moment from "moment";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function Investasi_ViewDetailPublish({
|
||||
dataInvestasi,
|
||||
}: {
|
||||
dataInvestasi: MODEL_INVESTASI;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [investasi, setInvestasi] = useState(dataInvestasi);
|
||||
|
||||
const listBox = [
|
||||
{
|
||||
id: 1,
|
||||
name: "Prospektus",
|
||||
icon: <IconBookDownload size={70} color="white" />,
|
||||
route: RouterInvestasi_OLD.detail_prospektus,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "Dokumen",
|
||||
icon: <IconFileDescription size={70} color="white" />,
|
||||
route: RouterInvestasi_OLD.edit_dokumen,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "Berita",
|
||||
icon: <IconSpeakerphone size={70} color="white" />,
|
||||
route: RouterInvestasi_OLD.list_edit_berita,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<Stack
|
||||
style={{
|
||||
paddingInline: "15px",
|
||||
paddingBlock: "15px",
|
||||
backgroundColor: AccentColor.darkblue,
|
||||
border: `2px solid ${AccentColor.blue}`,
|
||||
borderRadius: "10px",
|
||||
color: "white",
|
||||
marginBottom: "15px",
|
||||
}}
|
||||
>
|
||||
{Number(investasi.MasterPencarianInvestor.name) -
|
||||
moment(new Date()).diff(new Date(investasi.countDown), "days") <=
|
||||
0 ? (
|
||||
<Group
|
||||
position="center"
|
||||
mb={"sm"}
|
||||
style={{
|
||||
color: "white",
|
||||
}}
|
||||
>
|
||||
<IconCircleCheck color="green" />
|
||||
<Text c={"green"}>Selesai</Text>
|
||||
</Group>
|
||||
) : (
|
||||
<Group
|
||||
mb={"sm"}
|
||||
position="center"
|
||||
style={{
|
||||
color: "white",
|
||||
}}
|
||||
>
|
||||
<Text>
|
||||
Sisa waktu :{" "}
|
||||
{Number(investasi.MasterPencarianInvestor.name) -
|
||||
moment(new Date()).diff(
|
||||
new Date(investasi.countDown),
|
||||
"days"
|
||||
)}{" "}
|
||||
hari
|
||||
</Text>
|
||||
</Group>
|
||||
)}
|
||||
|
||||
<AspectRatio ratio={1 / 1} mx={"sm"} mah={250}>
|
||||
<Image
|
||||
alt=""
|
||||
src={RouterInvestasi_OLD.api_gambar + `${investasi.imagesId}`}
|
||||
radius={"sm"}
|
||||
height={250}
|
||||
width={"100%"}
|
||||
/>
|
||||
</AspectRatio>
|
||||
|
||||
{/* Title dan Persentase */}
|
||||
<Box mb={"md"}>
|
||||
<Title align="center" order={3} mb={"xs"}>
|
||||
{investasi.title}
|
||||
</Title>
|
||||
<Progress
|
||||
label={
|
||||
"" +
|
||||
(
|
||||
((+investasi.totalLembar - +investasi.sisaLembar) /
|
||||
+investasi.totalLembar) *
|
||||
100
|
||||
).toFixed(1) +
|
||||
"%"
|
||||
}
|
||||
value={
|
||||
+(
|
||||
((+investasi.totalLembar - +investasi.sisaLembar) /
|
||||
+investasi.totalLembar) *
|
||||
100
|
||||
).toFixed(1)
|
||||
}
|
||||
color="teal"
|
||||
size="xl"
|
||||
radius="xl"
|
||||
/>
|
||||
</Box>
|
||||
|
||||
{/* Rincian Data */}
|
||||
<Grid p={"md"} mb={"md"}>
|
||||
<Grid.Col span={6}>
|
||||
<Stack>
|
||||
<Box>
|
||||
<Text>Dana Dibutuhkan</Text>
|
||||
<Text>
|
||||
Rp.{" "}
|
||||
{new Intl.NumberFormat("id-ID", {
|
||||
maximumSignificantDigits: 10,
|
||||
}).format(+investasi.targetDana)}
|
||||
</Text>
|
||||
</Box>
|
||||
<Box>
|
||||
<Text>Harga Per Lembar</Text>
|
||||
<Text>
|
||||
Rp.{" "}
|
||||
{new Intl.NumberFormat("id-ID", {
|
||||
maximumSignificantDigits: 10,
|
||||
}).format(+investasi.hargaLembar)}
|
||||
</Text>
|
||||
</Box>
|
||||
<Box>
|
||||
<Text>Jadwal Pembagian</Text>
|
||||
<Text>{investasi.MasterPembagianDeviden.name} bulan </Text>
|
||||
</Box>
|
||||
<Box>
|
||||
<Text>Pembagian Deviden</Text>
|
||||
<Text>{investasi.MasterPeriodeDeviden.name}</Text>
|
||||
</Box>
|
||||
</Stack>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Stack>
|
||||
<Box>
|
||||
<Text>ROI</Text>
|
||||
<Text>{investasi.roi}%</Text>
|
||||
</Box>
|
||||
<Box>
|
||||
<Text>Total Lembar</Text>
|
||||
<Text>
|
||||
{new Intl.NumberFormat("id-ID", {
|
||||
maximumSignificantDigits: 10,
|
||||
}).format(+investasi.totalLembar)}{" "}
|
||||
lembar
|
||||
</Text>
|
||||
</Box>
|
||||
<Box>
|
||||
<Text>Sisa Lembar</Text>
|
||||
<Text>
|
||||
{new Intl.NumberFormat("id-ID", {
|
||||
maximumSignificantDigits: 10,
|
||||
}).format(+investasi.sisaLembar)}{" "}
|
||||
lembar
|
||||
</Text>
|
||||
</Box>
|
||||
</Stack>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
{/* List Box */}
|
||||
<Group position="apart" px={"lg"}>
|
||||
{listBox.map((e, i) => (
|
||||
<Paper
|
||||
key={i}
|
||||
style={{
|
||||
padding: "15px",
|
||||
backgroundColor: AccentColor.blue,
|
||||
border: `2px solid ${AccentColor.softblue}`,
|
||||
borderRadius: "10px",
|
||||
color: "white",
|
||||
}}
|
||||
>
|
||||
<Flex direction={"column"} align={"center"} justify={"center"}>
|
||||
<Text fz={12}>{e.name}</Text>
|
||||
<ActionIcon
|
||||
radius={"xl"}
|
||||
// loading={isLoadingBox && e?.id === boxId ? true : false}
|
||||
variant="transparent"
|
||||
size={60}
|
||||
onClick={() => router.push(e.route + `${investasi.id}`)}
|
||||
>
|
||||
{e.icon}
|
||||
</ActionIcon>
|
||||
</Flex>
|
||||
</Paper>
|
||||
))}
|
||||
</Group>
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
@@ -1,16 +1,12 @@
|
||||
"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 { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import { Investasi_ComponentDetailDataNonPublish } from "@/app_modules/investasi/_component";
|
||||
import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||
import { ComponentInvestasi_DetailDataNonPublish } from "@/app_modules/investasi/component/detail/x_detai_data_non_publish";
|
||||
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";
|
||||
@@ -27,7 +23,6 @@ export default function Investasi_ViewDetailDraft({
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [activeTab, setActiveTab] = useAtom(gs_investasi_status);
|
||||
|
||||
async function onAjukanReview() {
|
||||
const res = await investasi_funEditStatusById({
|
||||
@@ -54,8 +49,7 @@ export default function Investasi_ViewDetailDraft({
|
||||
|
||||
setIsLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil("Review Berhasil Diajukan");
|
||||
router.push(NEW_RouterInvestasi.portofolio({ id: dataInvestasi.id }));
|
||||
setActiveTab("Review");
|
||||
router.push(NEW_RouterInvestasi.portofolio({ id: "2" }));
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
NEW_RouterInvestasi,
|
||||
RouterInvestasi_OLD,
|
||||
} from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import {
|
||||
ComponentGlobal_AvatarAndUsername,
|
||||
ComponentGlobal_CardStyles,
|
||||
ComponentGlobal_LoadImageLandscape,
|
||||
} from "@/app_modules/_global/component";
|
||||
import {
|
||||
Investasi_ComponentBoxDaftarBerita,
|
||||
Investasi_ComponentBoxDaftarDokumen,
|
||||
Investasi_ComponentBoxProgress,
|
||||
Investasi_ComponentBoxProspektus,
|
||||
Investasi_ComponentTitleAndValueInDetail,
|
||||
} from "@/app_modules/investasi/_component";
|
||||
import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
SimpleGrid,
|
||||
Stack,
|
||||
Text,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { useLocalStorage } from "@mantine/hooks";
|
||||
import {
|
||||
IconBookDownload,
|
||||
IconFileDescription,
|
||||
IconSpeakerphone,
|
||||
} from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import moment from "moment";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function Investasi_ViewDetailPublish({
|
||||
dataInvestasi,
|
||||
userLoginId,
|
||||
}: {
|
||||
dataInvestasi: MODEL_INVESTASI;
|
||||
userLoginId: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState(dataInvestasi);
|
||||
const [boxId, setBoxId] = useState(0);
|
||||
const [isLoadingBox, setLoadingBox] = useState(false);
|
||||
const [isLoadingButton, setLoadingButton] = useState(false);
|
||||
const [total, setTotal] = useLocalStorage({
|
||||
key: "total_investasi",
|
||||
defaultValue: 0,
|
||||
});
|
||||
const [jumlah, setJumlah] = useLocalStorage({
|
||||
key: "jumlah_investasi",
|
||||
defaultValue: 0,
|
||||
});
|
||||
async function onSubmit() {
|
||||
setLoadingButton(true);
|
||||
|
||||
//NEW
|
||||
router.push(NEW_RouterInvestasi.pembelian + data.id, { scroll: false });
|
||||
setTotal(0);
|
||||
setJumlah(0);
|
||||
}
|
||||
|
||||
return (
|
||||
<Stack>
|
||||
<Investasi_ComponentBoxProgress progress={data.progress} />
|
||||
|
||||
<ComponentGlobal_CardStyles>
|
||||
<Stack spacing={"xl"}>
|
||||
<ComponentGlobal_AvatarAndUsername
|
||||
profile={data.author.Profile as any}
|
||||
/>
|
||||
<ComponentGlobal_LoadImageLandscape fileId={data.imageId} />
|
||||
|
||||
{/* Title dan Persentase */}
|
||||
<Center>
|
||||
<Title order={3} align="center">
|
||||
{_.startCase(data.title)}
|
||||
</Title>
|
||||
</Center>
|
||||
|
||||
{/* Rincian Data */}
|
||||
|
||||
<Stack>
|
||||
<Investasi_ComponentTitleAndValueInDetail
|
||||
title="Investor"
|
||||
value={<Text>{data.Investasi_Invoice.length} </Text>}
|
||||
/>
|
||||
<Investasi_ComponentTitleAndValueInDetail
|
||||
title="Target Dana"
|
||||
value={
|
||||
<Text>
|
||||
Rp.{" "}
|
||||
{new Intl.NumberFormat("id-ID", {
|
||||
maximumSignificantDigits: 20,
|
||||
}).format(+data.targetDana)}{" "}
|
||||
</Text>
|
||||
}
|
||||
/>
|
||||
|
||||
<Investasi_ComponentTitleAndValueInDetail
|
||||
title="Harga Per Lembar"
|
||||
value={
|
||||
<Text>
|
||||
Rp.{" "}
|
||||
{new Intl.NumberFormat("id-ID", {
|
||||
maximumSignificantDigits: 10,
|
||||
}).format(+data.hargaLembar)}
|
||||
</Text>
|
||||
}
|
||||
/>
|
||||
|
||||
<Investasi_ComponentTitleAndValueInDetail
|
||||
title={<Text fs={"italic"}>Return Of Invesment (RoI)</Text>}
|
||||
value={<Text>{data.roi} %</Text>}
|
||||
/>
|
||||
|
||||
<Investasi_ComponentTitleAndValueInDetail
|
||||
title="Total Lembar"
|
||||
value={
|
||||
<Text>
|
||||
{new Intl.NumberFormat("id-ID", {
|
||||
maximumSignificantDigits: 10,
|
||||
}).format(+data.totalLembar)}{" "}
|
||||
lembar
|
||||
</Text>
|
||||
}
|
||||
/>
|
||||
|
||||
<Investasi_ComponentTitleAndValueInDetail
|
||||
title="Sisa Lembar"
|
||||
value={
|
||||
<Text>
|
||||
{new Intl.NumberFormat("id-ID", {
|
||||
maximumSignificantDigits: 10,
|
||||
}).format(+data.sisaLembar)}{" "}
|
||||
lembar
|
||||
</Text>
|
||||
}
|
||||
/>
|
||||
|
||||
<Investasi_ComponentTitleAndValueInDetail
|
||||
title="Jadwal Pembagian"
|
||||
value={<Text>{data.MasterPembagianDeviden.name} Bulan </Text>}
|
||||
/>
|
||||
<Investasi_ComponentTitleAndValueInDetail
|
||||
title="Pembagian Deviden"
|
||||
value={<Text>{data.MasterPeriodeDeviden.name}</Text>}
|
||||
/>
|
||||
<Investasi_ComponentTitleAndValueInDetail
|
||||
title="Pencarian Investor"
|
||||
value={<Text>{data.MasterPencarianInvestor.name} Hari </Text>}
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
{/* List Box */}
|
||||
<SimpleGrid
|
||||
cols={3}
|
||||
breakpoints={[
|
||||
{ maxWidth: "62rem", cols: 3, spacing: "md" },
|
||||
{ maxWidth: "48rem", cols: 2, spacing: "sm" },
|
||||
{ maxWidth: "36rem", cols: 1, spacing: "sm" },
|
||||
]}
|
||||
>
|
||||
<Investasi_ComponentBoxProspektus
|
||||
prospektusFileId={data.prospektusFileId}
|
||||
/>
|
||||
<Investasi_ComponentBoxDaftarDokumen investasiId={data?.id} />
|
||||
<Investasi_ComponentBoxDaftarBerita investasiId={data?.id} />
|
||||
</SimpleGrid>
|
||||
</Stack>
|
||||
</ComponentGlobal_CardStyles>
|
||||
|
||||
<Box my={"md"}>
|
||||
{data.sisaLembar === "0" ||
|
||||
Number(data.MasterPencarianInvestor.name) -
|
||||
moment(new Date()).diff(new Date(data.countDown), "days") <=
|
||||
0 ? (
|
||||
<Center mb={"md"}>
|
||||
<Button disabled radius={50} variant="transparent">
|
||||
Investasi Telah Ditutup
|
||||
</Button>
|
||||
</Center>
|
||||
) : (
|
||||
<Box>
|
||||
{userLoginId === data.authorId ? (
|
||||
<Center mb={"md"}>
|
||||
<Button disabled radius={50}>
|
||||
Investasi Ini Milik Anda
|
||||
</Button>
|
||||
</Center>
|
||||
) : (
|
||||
<Center mb={"md"}>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoadingButton}
|
||||
w={"100%"}
|
||||
radius={50}
|
||||
bg={MainColor.yellow}
|
||||
color="yellow"
|
||||
c={"black"}
|
||||
onClick={() => {
|
||||
onSubmit();
|
||||
}}
|
||||
>
|
||||
Beli Saham
|
||||
</Button>
|
||||
</Center>
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_glo
|
||||
import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal";
|
||||
import { Investasi_ComponentDetailDataNonPublish } from "@/app_modules/investasi/_component";
|
||||
import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||
import { ComponentInvestasi_DetailDataNonPublish } from "@/app_modules/investasi/component/detail/x_detai_data_non_publish";
|
||||
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";
|
||||
@@ -49,7 +48,7 @@ export default function Investasi_ViewDetailReject({
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setOpenModal(false);
|
||||
router.push(NEW_RouterInvestasi.portofolio({ id: dataInvestasi.id }));
|
||||
router.push(NEW_RouterInvestasi.portofolio({ id: "3" }));
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
"use client";
|
||||
|
||||
import { NEW_RouterInvestasi, RouterInvestasi_OLD } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import {
|
||||
NEW_RouterInvestasi,
|
||||
RouterInvestasi_OLD,
|
||||
} 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 { Investasi_ComponentDetailDataNonPublish } from "@/app_modules/investasi/_component";
|
||||
@@ -14,7 +17,6 @@ import { useAtom } from "jotai";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
|
||||
export default function Investasi_ViewDetailReview({
|
||||
dataInvestasi,
|
||||
}: {
|
||||
@@ -22,8 +24,6 @@ export default function Investasi_ViewDetailReview({
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
|
||||
const [activeTab, setActiveTab] = useAtom(gs_investasi_status);
|
||||
const [data, setData] = useState<MODEL_INVESTASI>(dataInvestasi);
|
||||
|
||||
async function onCancleReview() {
|
||||
@@ -50,8 +50,7 @@ export default function Investasi_ViewDetailReview({
|
||||
|
||||
setLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil("Review Dibatalkan");
|
||||
setActiveTab("Draft");
|
||||
router.push(NEW_RouterInvestasi.portofolio({id: data.id}));
|
||||
router.push(NEW_RouterInvestasi.portofolio({ id: "3" }));
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||
|
||||
37
src/app_modules/investasi/_view/detail/view_berita.tsx
Normal file
37
src/app_modules/investasi/_view/detail/view_berita.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import {
|
||||
ComponentGlobal_CardStyles,
|
||||
ComponentGlobal_LoadImageLandscape,
|
||||
} from "@/app_modules/_global/component";
|
||||
import { Stack, Text, Title } from "@mantine/core";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { useState } from "react";
|
||||
|
||||
export function Investasi_ViewDetailBerita({
|
||||
dataBerita,
|
||||
}: {
|
||||
dataBerita: any;
|
||||
}) {
|
||||
const [data, setData] =
|
||||
useState<Prisma.BeritaInvestasiGetPayload<{}>>(dataBerita);
|
||||
|
||||
return (
|
||||
<>
|
||||
<ComponentGlobal_CardStyles>
|
||||
<Stack>
|
||||
{data.imageId == null ? (
|
||||
""
|
||||
) : (
|
||||
<ComponentGlobal_LoadImageLandscape fileId={data.imageId} />
|
||||
)}
|
||||
|
||||
<Title order={4} align="center">
|
||||
{" "}
|
||||
{data.title}
|
||||
</Title>
|
||||
|
||||
<Text>{data.deskripsi}</Text>
|
||||
</Stack>
|
||||
</ComponentGlobal_CardStyles>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import {
|
||||
ComponentGlobal_CardStyles,
|
||||
ComponentGlobal_CardLoadingOverlay,
|
||||
} from "@/app_modules/_global/component";
|
||||
import { Box, Title } from "@mantine/core";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
export function Investasi_ViewDaftarBerita({
|
||||
dataBerita,
|
||||
}: {
|
||||
dataBerita: any[];
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState(dataBerita);
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [dataId, setDataId] = useState("");
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box>
|
||||
{data.map((e, i) => (
|
||||
<ComponentGlobal_CardStyles
|
||||
key={i}
|
||||
onClickHandler={() => {
|
||||
router.push(NEW_RouterInvestasi.berita({ id: e.id }), {
|
||||
scroll: false,
|
||||
});
|
||||
setVisible(true);
|
||||
setDataId(e.id);
|
||||
}}
|
||||
>
|
||||
<Title order={6} lineClamp={1}>
|
||||
{e.title}
|
||||
</Title>
|
||||
{visible && dataId === e.id && (
|
||||
<ComponentGlobal_CardLoadingOverlay />
|
||||
)}
|
||||
</ComponentGlobal_CardStyles>
|
||||
))}
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,14 +1,12 @@
|
||||
import { ComponentGlobal_BoxInformation } from "@/app_modules/_global/component";
|
||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
|
||||
import { Box, Center, Stack } from "@mantine/core";
|
||||
import { data } from "autoprefixer";
|
||||
import _ from "lodash";
|
||||
import { ScrollOnly } from "next-scroll-loader";
|
||||
import { investasi_funGetAllDocumentById } from "../../_fun";
|
||||
import { useState } from "react";
|
||||
import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface";
|
||||
import { Investasi_ComponentCardDaftarDocument } from "../../_component";
|
||||
import { investasi_funGetAllDocumentById } from "../../_fun";
|
||||
import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface";
|
||||
|
||||
export function Investasi_ViewDaftarDokumen({
|
||||
dataDokumen,
|
||||
|
||||
11
src/app_modules/investasi/_view/detail/view_detail_main.tsx
Normal file
11
src/app_modules/investasi/_view/detail/view_detail_main.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
export function Investasi_ViewDetailMain({
|
||||
dataInvestasi,
|
||||
}: {
|
||||
dataInvestasi: any;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
data disni
|
||||
</>
|
||||
);
|
||||
}
|
||||
45
src/app_modules/investasi/_view/detail/view_rekap_berita.tsx
Normal file
45
src/app_modules/investasi/_view/detail/view_rekap_berita.tsx
Normal file
@@ -0,0 +1,45 @@
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import {
|
||||
ComponentGlobal_CardLoadingOverlay,
|
||||
ComponentGlobal_CardStyles,
|
||||
} from "@/app_modules/_global/component";
|
||||
import { Box, Group, Title } from "@mantine/core";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
export function Investasi_ViewRekapBerita({
|
||||
dataBerita,
|
||||
}: {
|
||||
dataBerita: any[];
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState(dataBerita);
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [dataId, setDataId] = useState("");
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box>
|
||||
{data.map((e, i) => (
|
||||
<ComponentGlobal_CardStyles
|
||||
key={i}
|
||||
onClickHandler={() => {
|
||||
router.push(NEW_RouterInvestasi.berita({ id: e.id }), {
|
||||
scroll: false,
|
||||
});
|
||||
setVisible(true);
|
||||
setDataId(e.id);
|
||||
}}
|
||||
>
|
||||
<Title order={6} lineClamp={1}>
|
||||
{e.title}
|
||||
</Title>
|
||||
{visible && dataId === e.id && (
|
||||
<ComponentGlobal_CardLoadingOverlay />
|
||||
)}
|
||||
</ComponentGlobal_CardStyles>
|
||||
))}
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import { Investasi_ViewInvoice } from "./transaksi/view_invoice";
|
||||
import { Investasi_ViewMetodePembayaran } from "./transaksi/view_metode_pembayaran";
|
||||
import { Investasi_ViewProsesPembelian } from "./transaksi/view_proses_pembelian";
|
||||
import { Investasi_ViewProsesTransaksi } from "./transaksi/view_proses_transaksi";
|
||||
import Investasi_ViewDetailPublish from "./detail/portofolio/view_detai_publish";
|
||||
import Investasi_ViewDetailPublish from "./detail/portofolio/view_detail_publish";
|
||||
import Investasi_ViewDetailReview from "./detail/portofolio/view_detail_review";
|
||||
import Investasi_ViewDetailDraft from "./detail/portofolio/view_detail_draft";
|
||||
import Investasi_ViewDetailReject from "./detail/portofolio/view_detail_reject";
|
||||
@@ -21,6 +21,11 @@ import { Investasi_ViewEditInvestasi } from "./edit/view_edit_investasi";
|
||||
import { Investasi_ViewEditProspektus } from "./edit/view_edit_prospektus";
|
||||
import { Investasi_ViewCreateDocument } from "./create/view_create_document";
|
||||
import { Investasi_ViewRekapDokumen } from "./detail/view_rekap_dokumen";
|
||||
import { Investasi_ViewDetailMain } from "./detail/view_detail_main";
|
||||
import { Investasi_ViewRekapBerita } from "./detail/view_rekap_berita";
|
||||
import { Investasi_ViewDaftarBerita } from "./detail/view_daftar_berita";
|
||||
import { Investasi_ViewCreateBerita } from "./create/view_create_berita";
|
||||
import { Investasi_ViewDetailBerita } from "./detail/view_berita";
|
||||
|
||||
export { Investasi_ViewProsesPembelian };
|
||||
export { Investasi_ViewMetodePembayaran };
|
||||
@@ -44,3 +49,8 @@ export { Investasi_ViewEditInvestasi };
|
||||
export { Investasi_ViewEditProspektus };
|
||||
export { Investasi_ViewCreateDocument };
|
||||
export { Investasi_ViewRekapDokumen };
|
||||
export { Investasi_ViewDetailMain };
|
||||
export { Investasi_ViewRekapBerita };
|
||||
export { Investasi_ViewDaftarBerita };
|
||||
export { Investasi_ViewCreateBerita };
|
||||
export { Investasi_ViewDetailBerita };
|
||||
|
||||
@@ -25,7 +25,12 @@ import {
|
||||
Text,
|
||||
TextInput,
|
||||
} from "@mantine/core";
|
||||
import { IconCamera, IconCircleCheck, IconFileTypePdf, IconUpload } from "@tabler/icons-react";
|
||||
import {
|
||||
IconCamera,
|
||||
IconCircleCheck,
|
||||
IconFileTypePdf,
|
||||
IconUpload,
|
||||
} from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { useState } from "react";
|
||||
import { Investasi_ComponentButtonCreateNewInvestasi } from "../_component";
|
||||
@@ -106,14 +111,9 @@ export default function InvestasiCreate({
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
// console.log(files.size);
|
||||
|
||||
if (files.size > maksimalUploadFile) {
|
||||
ComponentGlobal_WarningMaxUpload({});
|
||||
} else {
|
||||
setImg(buffer);
|
||||
setFileImage(files);
|
||||
}
|
||||
setImg(buffer);
|
||||
setFileImage(files);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
@@ -161,34 +161,6 @@ export default function InvestasiCreate({
|
||||
)}
|
||||
</ComponentGlobal_CardStyles>
|
||||
|
||||
{/* {!pdf ? (
|
||||
<Paper
|
||||
w={"100%"}
|
||||
style={{
|
||||
border: `2px solid gray`,
|
||||
backgroundColor: "gray.1",
|
||||
padding: "10px",
|
||||
borderRadius: "10px",
|
||||
color: "gray",
|
||||
}}
|
||||
>
|
||||
<Text>Upload File Prospektus</Text>
|
||||
</Paper>
|
||||
) : (
|
||||
<Paper
|
||||
w={"100%"}
|
||||
style={{
|
||||
border: `2px solid ${AccentColor.softblue}`,
|
||||
backgroundColor: AccentColor.blue,
|
||||
padding: "10px",
|
||||
borderRadius: "10px",
|
||||
color: "white",
|
||||
}}
|
||||
>
|
||||
<Text lineClamp={1}>{pdf.name}</Text>
|
||||
</Paper>
|
||||
)} */}
|
||||
{/* {JSON.stringify(filePdf)} */}
|
||||
<Group position="center">
|
||||
<FileButton
|
||||
accept={"application/pdf"}
|
||||
|
||||
@@ -50,11 +50,11 @@ export default function CreateBeritaInvestasi({
|
||||
const fd = new FormData();
|
||||
fd.append("file", fl);
|
||||
|
||||
await funCreateBeritaInvestasi(fd, body as any).then((res) => {
|
||||
res.status === 201
|
||||
? (ComponentGlobal_NotifikasiBerhasil(res.message), router.back())
|
||||
: ComponentGlobal_NotifikasiGagal(res.message);
|
||||
});
|
||||
// await funCreateBeritaInvestasi(fd, body as any).then((res) => {
|
||||
// res.status === 201
|
||||
// ? (ComponentGlobal_NotifikasiBerhasil(res.message), router.back())
|
||||
// : ComponentGlobal_NotifikasiGagal(res.message);
|
||||
// });
|
||||
|
||||
// router.back();
|
||||
// toast("Berita tersimpan");
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
"use server";
|
||||
|
||||
import _ from "lodash";
|
||||
import { MODEL_INVESTASI } from "../_lib/interface";
|
||||
import { v4 } from "uuid";
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import fs from "fs";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { RouterInvestasi_OLD } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import fs from "fs";
|
||||
import _ from "lodash";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { v4 } from "uuid";
|
||||
|
||||
export default async function funCreateBeritaInvestasi(
|
||||
formData: FormData,
|
||||
@@ -34,8 +33,8 @@ export default async function funCreateBeritaInvestasi(
|
||||
message: "File Kosong",
|
||||
};
|
||||
|
||||
const upFolder = Buffer.from(await file.arrayBuffer());
|
||||
fs.writeFileSync(`./public/investasi/${upload.url}`, upFolder);
|
||||
// const upFolder = Buffer.from(await file.arrayBuffer());
|
||||
// fs.writeFileSync(`./public/investasi/${upload.url}`, upFolder);
|
||||
|
||||
const createBerita = await prisma.beritaInvestasi.create({
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user