diff --git a/public/file/6576e0ab-2803-4cb4-8fb7-5d91cd6c8cd8.pdf b/public/file/6576e0ab-2803-4cb4-8fb7-5d91cd6c8cd8.pdf new file mode 100644 index 00000000..5aef1936 Binary files /dev/null and b/public/file/6576e0ab-2803-4cb4-8fb7-5d91cd6c8cd8.pdf differ diff --git a/public/investasi/d300094c-1ce5-4d9a-9178-47b0be1df5c1.png b/public/investasi/d300094c-1ce5-4d9a-9178-47b0be1df5c1.png new file mode 100644 index 00000000..24d01eeb Binary files /dev/null and b/public/investasi/d300094c-1ce5-4d9a-9178-47b0be1df5c1.png differ diff --git a/src/app/dev/auth/validasi/layout.tsx b/src/app/dev/auth/validasi/layout.tsx new file mode 100644 index 00000000..86a4fa5e --- /dev/null +++ b/src/app/dev/auth/validasi/layout.tsx @@ -0,0 +1,8 @@ +import { LayoutValidasi } from "@/app_modules/auth"; +import React from "react"; + +export default async function Layout({children}: {children: React.ReactNode}) { + return<> + {children} + +} \ No newline at end of file diff --git a/src/app/dev/investasi/detail/[id]/page.tsx b/src/app/dev/investasi/detail/[id]/page.tsx index ddef4c07..07f65ed2 100644 --- a/src/app/dev/investasi/detail/[id]/page.tsx +++ b/src/app/dev/investasi/detail/[id]/page.tsx @@ -1,7 +1,11 @@ +import { funGetUserProfile } from "@/app_modules/fun/get_user_profile"; import { DetailInvestasi } from "@/app_modules/investasi"; +import getOneInvestasiById from "@/app_modules/investasi/fun/get_one_investasi_by_id"; export default async function Page({params}: {params: {id: string}}) { + const dataInvestasi = await getOneInvestasiById(params.id) + const dataUser = await funGetUserProfile(dataInvestasi?.authorId as any) return<> - + } \ No newline at end of file diff --git a/src/app/dev/investasi/detail_porto/[id]/layout.tsx b/src/app/dev/investasi/detail_porto/[id]/layout.tsx deleted file mode 100644 index ae1e2728..00000000 --- a/src/app/dev/investasi/detail_porto/[id]/layout.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { LayoutPortofolioDetailInvestasi } from "@/app_modules/investasi"; -import React from "react"; - -export default async function Layout({children, params}: {children: React.ReactNode, params: {id: string}}) { - return<> - {children} - -} \ No newline at end of file diff --git a/src/app/dev/investasi/detail_porto/[id]/page.tsx b/src/app/dev/investasi/detail_porto/[id]/page.tsx deleted file mode 100644 index 145ca1c8..00000000 --- a/src/app/dev/investasi/detail_porto/[id]/page.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import { PortofolioDetailInvestasi } from "@/app_modules/investasi"; - -export default async function Page({params} : {params: {id: string}}) { - return<> - - -} \ No newline at end of file diff --git a/src/app/dev/investasi/detail_portofolio/publish/layout.tsx b/src/app/dev/investasi/detail_portofolio/publish/[id]/layout.tsx similarity index 100% rename from src/app/dev/investasi/detail_portofolio/publish/layout.tsx rename to src/app/dev/investasi/detail_portofolio/publish/[id]/layout.tsx diff --git a/src/app/dev/investasi/detail_portofolio/publish/[id]/page.tsx b/src/app/dev/investasi/detail_portofolio/publish/[id]/page.tsx new file mode 100644 index 00000000..71c85689 --- /dev/null +++ b/src/app/dev/investasi/detail_portofolio/publish/[id]/page.tsx @@ -0,0 +1,10 @@ +import { DetailPublishInvestasi } from "@/app_modules/investasi"; +import getOneInvestasiById from "@/app_modules/investasi/fun/get_one_investasi_by_id"; + +export default async function Page({params}: {params: {id: string}}) { + + const dataInvestasi = await getOneInvestasiById(params.id) + return<> + + +} \ No newline at end of file diff --git a/src/app/dev/investasi/detail_portofolio/publish/page.tsx b/src/app/dev/investasi/detail_portofolio/publish/page.tsx deleted file mode 100644 index 46e707c3..00000000 --- a/src/app/dev/investasi/detail_portofolio/publish/page.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import { DetailPublishInvestasi } from "@/app_modules/investasi"; - -export default async function Page() { - return<> - - -} \ No newline at end of file diff --git a/src/app/dev/investasi/detail_portofolio/reject/[id]/layout.tsx b/src/app/dev/investasi/detail_portofolio/reject/[id]/layout.tsx new file mode 100644 index 00000000..f0653738 --- /dev/null +++ b/src/app/dev/investasi/detail_portofolio/reject/[id]/layout.tsx @@ -0,0 +1,18 @@ +import { LayoutDetailRejectInvestasi } from "@/app_modules/investasi"; +import React from "react"; + +export default async function Layout({ + children, + params, +}: { + children: React.ReactNode; + params: { id: string }; +}) { + return ( + <> + + {children} + + + ); +} diff --git a/src/app/dev/investasi/detail_portofolio/reject/[id]/page.tsx b/src/app/dev/investasi/detail_portofolio/reject/[id]/page.tsx new file mode 100644 index 00000000..23368b5b --- /dev/null +++ b/src/app/dev/investasi/detail_portofolio/reject/[id]/page.tsx @@ -0,0 +1,10 @@ +import { DetailRejectInvestasi } from "@/app_modules/investasi"; +import getOneInvestasiById from "@/app_modules/investasi/fun/get_one_investasi_by_id"; + +export default async function Page({params}: {params: {id: string}}) { + const dataInvestasi = await getOneInvestasiById(params.id) +// console.log(dataInvestasi) + return<> + + +} \ No newline at end of file diff --git a/src/app/dev/investasi/detail_portofolio/reject/layout.tsx b/src/app/dev/investasi/detail_portofolio/reject/layout.tsx deleted file mode 100644 index 6d374c05..00000000 --- a/src/app/dev/investasi/detail_portofolio/reject/layout.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { LayoutDetailRejectInvestasi } from "@/app_modules/investasi"; -import React from "react"; - -export default async function Layout({children}: {children: React.ReactNode}) { - return<> - {children} - -} \ No newline at end of file diff --git a/src/app/dev/investasi/detail_portofolio/reject/page.tsx b/src/app/dev/investasi/detail_portofolio/reject/page.tsx deleted file mode 100644 index 37ade701..00000000 --- a/src/app/dev/investasi/detail_portofolio/reject/page.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import { DetailRejectInvestasi } from "@/app_modules/investasi"; - -export default async function Page() { - return<> - - -} \ No newline at end of file diff --git a/src/app/dev/investasi/edit_prospektus/[id]/layout.tsx b/src/app/dev/investasi/edit_prospektus/[id]/layout.tsx index 36271a8c..0c6a45a1 100644 --- a/src/app/dev/investasi/edit_prospektus/[id]/layout.tsx +++ b/src/app/dev/investasi/edit_prospektus/[id]/layout.tsx @@ -1,8 +1,21 @@ import { LayoutEditProspektusInvestasi } from "@/app_modules/investasi"; +import getOneInvestasiById from "@/app_modules/investasi/fun/get_one_investasi_by_id"; import React from "react"; -export default async function Layout({children, params}: {children: React.ReactNode, params: {id: string}}) { - return<> - {children} +export default async function Layout({ + children, + params, +}: { + children: React.ReactNode; + params: { id: string }; +}) { + const dataInvestasi = await getOneInvestasiById(params.id); + + return ( + <> + + {children} + -} \ No newline at end of file + ); +} diff --git a/src/app/dev/investasi/main/page.tsx b/src/app/dev/investasi/main/page.tsx index b41a5645..ca8c03be 100644 --- a/src/app/dev/investasi/main/page.tsx +++ b/src/app/dev/investasi/main/page.tsx @@ -1,24 +1,24 @@ import { MainInvestasi } from "@/app_modules/investasi"; -import { getListAllInvestasi } from "@/app_modules/investasi/fun/get_list_all_investasi"; +import { getListAllPublish } from "@/app_modules/investasi/fun/get_list_all_publish"; import getPembagianDeviden from "@/app_modules/investasi/fun/master/get_pembagian_deviden"; import getPencarianInvestor from "@/app_modules/investasi/fun/master/get_pencarian_investor"; import getPeriodeDeviden from "@/app_modules/investasi/fun/master/get_periode_deviden"; export default async function Page() { - const data = await getListAllInvestasi() - const pencarianInvestor = await getPencarianInvestor(); - const periodeDeviden = await getPeriodeDeviden(); - const pembagianDeviden = await getPembagianDeviden(); - - // console.log(data) - return <> - + const data = await getListAllPublish(); + const pencarianInvestor = await getPencarianInvestor(); + const periodeDeviden = await getPeriodeDeviden(); + const pembagianDeviden = await getPembagianDeviden(); + + // console.log(data) + return ( + <> + - -} \ No newline at end of file + ); +} diff --git a/src/app/dev/investasi/main/portofolio/page.tsx b/src/app/dev/investasi/main/portofolio/page.tsx index faa90fb2..53d718e2 100644 --- a/src/app/dev/investasi/main/portofolio/page.tsx +++ b/src/app/dev/investasi/main/portofolio/page.tsx @@ -3,8 +3,9 @@ import { cookies } from "next/headers"; import fs from "fs"; import yaml from "yaml"; import { unsealData } from "iron-session"; -import getInvestasiById from "@/app_modules/investasi/fun/get_investasi_by_id"; +import getInvestasiByStatusId from "@/app_modules/investasi/fun/get_investasi_by_id"; import getStatusInvestasi from "@/app_modules/investasi/fun/master/get_status_investasi"; +import getPortoByStatusId from "@/app_modules/investasi/fun/get_porto_status_by_id"; const config = yaml.parse(fs.readFileSync("config.yaml").toString()); @@ -16,13 +17,23 @@ export default async function Page() { }) ); -const dataInvestasi = await getInvestasiById(tkn.id) -const listStatusInvestasi = await getStatusInvestasi() -// console.log(listStatusInvestasi) + const listStatusInvestasi = await getStatusInvestasi(); + const dataDraft = await getPortoByStatusId(tkn.id, 1) + const dataReview = await getPortoByStatusId(tkn.id, 2) + const dataPublish = await getPortoByStatusId(tkn.id, 3) + const dataReject = await getPortoByStatusId(tkn.id, 4) + + return ( <> - + ); } diff --git a/src/app/lib/router_hipmi/router_investasi.ts b/src/app/lib/router_hipmi/router_investasi.ts index 1afd840b..1a9b415e 100644 --- a/src/app/lib/router_hipmi/router_investasi.ts +++ b/src/app/lib/router_hipmi/router_investasi.ts @@ -26,7 +26,7 @@ export const RouterInvestasi = { edit_prospektus: "/dev/investasi/edit_prospektus/", edit_dokumen: "/dev/investasi/edit_dokumen/", edit_berita: "/dev/investasi/edit_berita/", - + // detail // detail_portofolio: "", detail_saham_terbeli: "/dev/investasi/detail_saham_terbeli/", @@ -34,9 +34,9 @@ export const RouterInvestasi = { detail_dokumen: "/dev/investasi/detail_dokumen/", detail_berita: "/dev/investasi/detail_berita/", detail_draft: "/dev/investasi/detail_portofolio/draft/", - detail_publish: "/dev/investasi/detail_portofolio/publish", + detail_publish: "/dev/investasi/detail_portofolio/publish/", detail_review: "/dev/investasi/detail_portofolio/review/", - detail_reject: "/dev/investasi/detail_portofolio/reject", + detail_reject: "/dev/investasi/detail_portofolio/reject/", // berita berita: "/dev/investasi/berita/", @@ -45,6 +45,5 @@ export const RouterInvestasi = { //upload upload_prospektus: "/dev/investasi/upload_prospektus/", - upload_dokumen: "/dev/investasi/upload_dokumen/" - + upload_dokumen: "/dev/investasi/upload_dokumen/", }; diff --git a/src/app_modules/admin/investasi/fun/fun_reject_investasi.ts b/src/app_modules/admin/investasi/fun/fun_reject_investasi.ts index 0b74d9b9..8a263a15 100644 --- a/src/app_modules/admin/investasi/fun/fun_reject_investasi.ts +++ b/src/app_modules/admin/investasi/fun/fun_reject_investasi.ts @@ -1,6 +1,9 @@ "use server" import prisma from "@/app/lib/prisma" +import { RouterAdminInvestasi } from "@/app/lib/router_hipmi/router_admin" +import { RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi" +import { revalidatePath } from "next/cache" export default async function funRejectInvestasi(data: any) { // console.log(data) @@ -14,6 +17,8 @@ export default async function funRejectInvestasi(data: any) { }) if(!res) return {status: 400, message: "Gagal reject"} + revalidatePath(RouterAdminInvestasi.main_investasi) + return { status: 200, message: "Reject berhasil" diff --git a/src/app_modules/auth/index.ts b/src/app_modules/auth/index.ts index 6cfd1f76..47281058 100644 --- a/src/app_modules/auth/index.ts +++ b/src/app_modules/auth/index.ts @@ -1,7 +1,8 @@ import SplashScreen from "./splash/view"; import Login from "./login/view"; import Validasi from "./validasi/view"; +import LayoutValidasi from "./validasi/layout"; import Register from "./register/view"; import Logout from "./logout/view"; -export { SplashScreen, Login, Validasi, Register, Logout }; +export { SplashScreen, Login, Validasi, Register, Logout, LayoutValidasi }; diff --git a/src/app_modules/auth/login/view.tsx b/src/app_modules/auth/login/view.tsx index 023029ee..86014978 100644 --- a/src/app_modules/auth/login/view.tsx +++ b/src/app_modules/auth/login/view.tsx @@ -43,7 +43,7 @@ export default function Login() { router.push(RouterAdminDashboard.splash_admin); } else { if (val.status == 200) { - toast(val.message); + toast("Nomor OTP terkirim"); setCode(val.body.otp); setInputNumber(val.body.nomor); router.push("/dev/auth/validasi"); diff --git a/src/app_modules/auth/logout/view.tsx b/src/app_modules/auth/logout/view.tsx index 9da7b017..7fc5af4a 100644 --- a/src/app_modules/auth/logout/view.tsx +++ b/src/app_modules/auth/logout/view.tsx @@ -1,13 +1,14 @@ "use client"; import { myConsole } from "@/app/fun/my_console"; import { ApiHipmi } from "@/app/lib/api"; -import { ActionIcon, Button } from "@mantine/core"; +import { ActionIcon, Button, Group, Modal } from "@mantine/core"; import { useRouter } from "next/navigation"; import { useAtom } from "jotai"; import { gs_nomor, gs_otp } from "../state/state"; import { IconLogout } from "@tabler/icons-react"; import { Warna } from "@/app/lib/warna"; import { gs_token } from "@/app_modules/home/state/global_state"; +import { useDisclosure } from "@mantine/hooks"; export default function Logout() { const router = useRouter(); @@ -15,6 +16,7 @@ export default function Logout() { const [code, setCode] = useAtom(gs_otp); const [token, setToken] = useAtom(gs_token); + const [opened, { toggle }] = useDisclosure(false); const onLogout = async () => { // MyConsole("keluar"); @@ -25,7 +27,7 @@ export default function Logout() { if (val.status == 200) { setnomor(null); setCode(null); - setToken(null) + setToken(null); return router.push("/dev/auth/login"); } @@ -34,9 +36,25 @@ export default function Logout() { return ( <> - - onLogout()}/> - + + + + + + + + + ); } diff --git a/src/app_modules/auth/validasi/layout.tsx b/src/app_modules/auth/validasi/layout.tsx new file mode 100644 index 00000000..d1bfeec5 --- /dev/null +++ b/src/app_modules/auth/validasi/layout.tsx @@ -0,0 +1,31 @@ +"use client"; + +import { ActionIcon, AppShell, Group, Header } from "@mantine/core"; +import { IconChevronLeft } from "@tabler/icons-react"; +import { useRouter } from "next/navigation"; +import React from "react"; + +export default function LayoutValidasi({ + children, +}: { + children: React.ReactNode; +}) { + const router = useRouter() + return ( + <> + + + router.back()} > + + + + + } + > + {children} + + + ); +} diff --git a/src/app_modules/auth/validasi/view.tsx b/src/app_modules/auth/validasi/view.tsx index f3ac68da..c342f244 100644 --- a/src/app_modules/auth/validasi/view.tsx +++ b/src/app_modules/auth/validasi/view.tsx @@ -2,6 +2,7 @@ import { useAtom } from "jotai"; import { + ActionIcon, Button, Center, Flex, @@ -14,7 +15,7 @@ import { gs_nomor, gs_otp } from "../state/state"; import { Warna } from "@/app/lib/warna"; import { useState } from "react"; import { myConsole } from "@/app/fun/my_console"; -import { IconCircleLetterH } from "@tabler/icons-react"; +import { IconChevronLeft, IconCircleLetterH } from "@tabler/icons-react"; import toast from "react-simple-toasts"; import { ApiHipmi } from "@/app/lib/api"; import { useRouter } from "next/navigation"; @@ -62,13 +63,14 @@ export default function Validasi() { <> {/* {JSON.stringify(nomor)} {JSON.stringify(code)} */} + Validasi Kode OTP diff --git a/src/app_modules/investasi/berita/view.tsx b/src/app_modules/investasi/berita/view.tsx index 7a7c7a8b..e5d9e664 100644 --- a/src/app_modules/investasi/berita/view.tsx +++ b/src/app_modules/investasi/berita/view.tsx @@ -34,6 +34,7 @@ export default function BeritaInvestasi({ berita.BeritaInvestasi.map((e) => ( , - route: RouterInvestasi.detail_dokumen + route: RouterInvestasi.detail_dokumen, }, { id: 3, @@ -51,72 +67,81 @@ export default function DetailInvestasi({id}: {id: string}) { return ( <> + {/* Foto username dan sisa waktu */} - - Username + + {user.username} - Sisa waktu : 20 Hari + {Number(investasi.MasterPencarianInvestor.name) - + moment(new Date()).diff(new Date(investasi.updatedAt), "days") <= + 0 ? ( + + + Selesai + + ) : ( + + Sisa waktu: + + {Number(investasi.MasterPencarianInvestor.name) - + moment(new Date()).diff(new Date(investasi.updatedAt), "days")} + + Hari + + )} - + - + - {/* Title dan Persentase */} + {/* Title dan Progress */} - Judul Proyek + {investasi.title} - + - {/* Rincian Data */} - + {/* Rincian Data */} + - - Terkumpul - Rp. - Dana Dibutuhkan - Rp. + Rp. {investasi.targetDana} Harga Per Lembar - Rp. + Rp. {investasi.hargaLembar} Jadwal Pembagian - 3 Bulan + {investasi.MasterPembagianDeviden.name} bulan - - Investor - 4657 - ROI - % + {investasi.roi}% Total Lembar - 0 + {investasi.totalLembar} lembar Pembagian Deviden - Selamanya + {investasi.MasterPeriodeDeviden.name} @@ -125,7 +150,11 @@ export default function DetailInvestasi({id}: {id: string}) { {/* List Box */} {listBox.map((e) => ( - router.push(e.route + `${id}`)}> + router.push(e.route + `${investasi.id}`)} + > {e.name} diff --git a/src/app_modules/investasi/detail_portofolio/publish/page.tsx b/src/app_modules/investasi/detail_portofolio/publish/page.tsx index 046932aa..4892e1be 100644 --- a/src/app_modules/investasi/detail_portofolio/publish/page.tsx +++ b/src/app_modules/investasi/detail_portofolio/publish/page.tsx @@ -14,6 +14,7 @@ import { Group, Image, Paper, + Progress, Slider, Stack, Text, @@ -21,22 +22,32 @@ import { } from "@mantine/core"; import { IconBookDownload, + IconCircleCheck, IconFileDescription, IconSpeakerphone, } from "@tabler/icons-react"; import { useAtom } from "jotai"; import { useRouter } from "next/navigation"; import toast from "react-simple-toasts"; +import { MODEL_Investasi } from "../../model/model_investasi"; +import { useState } from "react"; +import moment from "moment"; +import _ from "lodash"; -export default function DetailPublishInvestasi() { +export default function DetailPublishInvestasi({ + dataInvestasi, +}: { + dataInvestasi: MODEL_Investasi; +}) { const router = useRouter(); + const [investasi, setInvestasi] = useState(dataInvestasi); const listBox = [ { id: 1, name: "Prospektus", icon: , - route: RouterInvestasi.edit_prospektus, + route: RouterInvestasi.detail_prospektus, }, { id: 2, @@ -48,73 +59,81 @@ export default function DetailPublishInvestasi() { id: 3, name: "Berita", icon: , - route: RouterInvestasi.edit_berita, + route: RouterInvestasi.list_edit_berita, }, ]; return ( <> -
- Sisa waktu : 20 Hari -
+ {Number(investasi.MasterPencarianInvestor.name) - + moment(new Date()).diff(new Date(investasi.updatedAt), "days") <= + 0 ? ( + + + Selesai + + ) : ( + + + Sisa waktu :{" "} + {Number(investasi.MasterPencarianInvestor.name) - + moment(new Date()).diff( + new Date(investasi.updatedAt), + "days" + )}{" "} + hari + + + )} + - + {/* Title dan Persentase */} - Judul Proyek + {investasi.title} - + {/* Rincian Data */} - - Terkumpul - Rp. - Dana Dibutuhkan - Rp. + Rp. {investasi.targetDana} Harga Per Lembar - Rp. + Rp. {investasi.hargaLembar} Jadwal Pembagian - 3 Bulan + {investasi.MasterPembagianDeviden.name} bulan - - Investor - 4657 - ROI - % + {investasi.roi}% Total Lembar - 0 + {investasi.totalLembar} lembar Pembagian Deviden - Selamanya + {investasi.MasterPeriodeDeviden.name} @@ -126,7 +145,7 @@ export default function DetailPublishInvestasi() { router.push(e.route + `${1}`)} + onClick={() => router.push(e.route + `${investasi.id}`)} > diff --git a/src/app_modules/investasi/detail_portofolio/reject/layout.tsx b/src/app_modules/investasi/detail_portofolio/reject/layout.tsx index 4cc12545..15a6ff3b 100644 --- a/src/app_modules/investasi/detail_portofolio/reject/layout.tsx +++ b/src/app_modules/investasi/detail_portofolio/reject/layout.tsx @@ -1,23 +1,30 @@ -"use client" +"use client"; -import HeaderTamplate from "@/app_modules/component/header_tamplate" -import { AppShell } from "@mantine/core" -import { IconEdit } from "@tabler/icons-react" -import React from "react" +import HeaderTamplate from "@/app_modules/component/header_tamplate"; +import { AppShell } from "@mantine/core"; +import { IconEdit } from "@tabler/icons-react"; +import React from "react"; -export default function LayoutDetailRejecttInvestasi({children}: {children: React.ReactNode}){ - return<> - - } - route2={`/dev/investasi/edit/${1}`} - /> - } - > +export default function LayoutDetailRejecttInvestasi({ + children, + idInves, +}: { + children: React.ReactNode; + idInves: string; +}) { + return ( + <> + } + route2={`/dev/investasi/edit/${idInves}`} + /> + } + > {children} - - + -} \ No newline at end of file + ); +} diff --git a/src/app_modules/investasi/detail_portofolio/reject/page.tsx b/src/app_modules/investasi/detail_portofolio/reject/page.tsx index afccc9ee..c029cf06 100644 --- a/src/app_modules/investasi/detail_portofolio/reject/page.tsx +++ b/src/app_modules/investasi/detail_portofolio/reject/page.tsx @@ -14,6 +14,7 @@ import { Grid, Group, Image, + Modal, Paper, Slider, Stack, @@ -29,10 +30,21 @@ import { useAtom } from "jotai"; import { useRouter } from "next/navigation"; import { gs_StatusPortoInvestasi } from "../../g_state"; import toast from "react-simple-toasts"; +import { MODEL_Investasi } from "../../model/model_investasi"; +import { useState } from "react"; +import funGantiStatusInvestasi from "../../fun/fun_ganti_status"; +import funDeleteInvestasi from "../../fun/fun_delete_investasi"; +import { useDisclosure } from "@mantine/hooks"; -export default function DetailRejectInvestasi() { +export default function DetailRejectInvestasi({ + dataInvestasi, +}: { + dataInvestasi: MODEL_Investasi; +}) { const router = useRouter(); + const [investasi, setInvestasi] = useState(dataInvestasi); const [activeTab, setActiveTab] = useAtom(gs_StatusPortoInvestasi); + const [opened, { toggle }] = useDisclosure(false); const listBox = [ { @@ -56,31 +68,53 @@ export default function DetailRejectInvestasi() { ]; async function onAjukan() { - toast("Project Diajukan Kembali"); - router.push(RouterInvestasi.portofolio); - setActiveTab("Review"); + await funGantiStatusInvestasi(investasi.id, "2").then((res) => { + if (res.status === 200) { + toast("Project Diajukan Kembali"); + router.push(RouterInvestasi.portofolio); + setActiveTab("Review"); + } else { + toast("Gagal Pengajuan"); + } + }); } async function onBatal() { - toast("Project Dibatalkan"); - router.push(RouterInvestasi.portofolio); - setActiveTab("Reject"); - + await funDeleteInvestasi(investasi.id).then((res) => { + if (res.status === 200) { + toast(res.message); + toggle(); + router.push(RouterInvestasi.portofolio); + } else { + toast(res.message); + } + }); + // setActiveTab("Reject"); } return ( <> + {/* Pop up */} + + + + + + + {/* Alasan */} Alasan : - - Lorem ipsum dolor sit amet consectetur adipisicing elit. Ab - necessitatibus dolores, doloribus porro quis velit unde voluptatem - delectus, nesciunt laboriosam non quae numquam sed tenetur! Minus - earum odio possimus dolore? - + {investasi.catatan} @@ -94,6 +128,7 @@ export default function DetailRejectInvestasi() { radius={50} bg={"orange.7"} color="yellow" + compact onClick={() => onAjukan()} > Ajukan Kembali @@ -101,17 +136,19 @@ export default function DetailRejectInvestasi() { + {/* Tombol Hapus */}
{" "}
@@ -119,22 +156,18 @@ export default function DetailRejectInvestasi() { - + - {/* Title dan Persentase */} - Judul Proyek + {investasi.title} - {/* Rincian Data */} @@ -143,15 +176,19 @@ export default function DetailRejectInvestasi() { Dana Dibutuhkan - Rp. + Rp. {investasi.targetDana} Harga Per Lembar - Rp. + Rp. {investasi.hargaLembar} Jadwal Pembagian - 3 Bulan + {investasi.MasterPembagianDeviden.name} Bulan + + + Pencarian Investor + {investasi.MasterPencarianInvestor.name} Hari
@@ -159,22 +196,22 @@ export default function DetailRejectInvestasi() { ROI - % + {investasi.roi} % Total Lembar - 0 + {investasi.totalLembar} lembar Pembagian Deviden - Selamanya + {investasi.MasterPeriodeDeviden.name}
{/* List Box */} - + {/* {listBox.map((e) => ( ))} - - - + */} ); } diff --git a/src/app_modules/investasi/detail_prospektus/view.tsx b/src/app_modules/investasi/detail_prospektus/view.tsx index 23b1348a..638bb0cc 100644 --- a/src/app_modules/investasi/detail_prospektus/view.tsx +++ b/src/app_modules/investasi/detail_prospektus/view.tsx @@ -25,11 +25,11 @@ export default function DetailPropektus({ target="_blank" style={{ textDecorationLine: "none" }} > - + ""} > diff --git a/src/app_modules/investasi/edit_propektus/layout.tsx b/src/app_modules/investasi/edit_propektus/layout.tsx index c6055f49..0e0c2574 100644 --- a/src/app_modules/investasi/edit_propektus/layout.tsx +++ b/src/app_modules/investasi/edit_propektus/layout.tsx @@ -5,17 +5,27 @@ import HeaderTamplate from "@/app_modules/component/header_tamplate"; import { AppShell } from "@mantine/core"; import { IconEdit } from "@tabler/icons-react"; import React from "react"; +import getOneInvestasiById from "../fun/get_one_investasi_by_id"; +import { MODEL_Investasi } from "../model/model_investasi"; export default function LayoutEditProspektusInvestasi({ children, - idInves + dataInvestasi, }: { children: React.ReactNode; - idInves: string + dataInvestasi: MODEL_Investasi; }) { return ( <> - }route2={RouterInvestasi.upload_prospektus + `${idInves}`} />}> + } + route2={RouterInvestasi.upload_prospektus + `${dataInvestasi.id}`} + /> + } + > {children} diff --git a/src/app_modules/investasi/edit_propektus/view.tsx b/src/app_modules/investasi/edit_propektus/view.tsx index 360861b0..5ea33d68 100644 --- a/src/app_modules/investasi/edit_propektus/view.tsx +++ b/src/app_modules/investasi/edit_propektus/view.tsx @@ -49,13 +49,13 @@ export default function EditProspektusInvestasi({ px={"sm"} onClick={() => ""} > - + {/* */} Prospektus_{prospek.title} - +
@@ -68,7 +68,7 @@ export default function EditProspektusInvestasi({ Tidak ada file )} - + {/* */} ); diff --git a/src/app_modules/investasi/fun/fun_delete_investasi.ts b/src/app_modules/investasi/fun/fun_delete_investasi.ts new file mode 100644 index 00000000..8a5efc44 --- /dev/null +++ b/src/app_modules/investasi/fun/fun_delete_investasi.ts @@ -0,0 +1,26 @@ +"use server"; + +import prisma from "@/app/lib/prisma"; +import { RouterAdminInvestasi } from "@/app/lib/router_hipmi/router_admin"; +import { RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; +import { revalidatePath } from "next/cache"; + +export default async function funDeleteInvestasi(id: string) { + const res = await prisma.investasi.delete({ + where: { + id: id, + }, + }); + + if (!res) return { status: 400, message: "Gagal Hapus Data" }; + + + revalidatePath(RouterInvestasi.portofolio) + revalidatePath(RouterAdminInvestasi.main_investasi) + + + return { + status: 200, + message: "Berhasil Hapus", + }; +} diff --git a/src/app_modules/investasi/fun/fun_ganti_status.ts b/src/app_modules/investasi/fun/fun_ganti_status.ts index 092c6af0..7fec9998 100644 --- a/src/app_modules/investasi/fun/fun_ganti_status.ts +++ b/src/app_modules/investasi/fun/fun_ganti_status.ts @@ -2,6 +2,7 @@ import prisma from "@/app/lib/prisma"; import { RouterAdminInvestasi } from "@/app/lib/router_hipmi/router_admin"; +import { RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; import { revalidatePath } from "next/cache"; export default async function funGantiStatusInvestasi(id: string, val: string) { @@ -16,7 +17,7 @@ export default async function funGantiStatusInvestasi(id: string, val: string) { if(!data) return {status: 400} - revalidatePath("/dev/investasi/main/portofolio") + revalidatePath(RouterInvestasi.portofolio) revalidatePath(RouterAdminInvestasi.main_investasi) return { diff --git a/src/app_modules/investasi/fun/get_investasi_by_id.ts b/src/app_modules/investasi/fun/get_investasi_by_id.ts index e05ac8a8..513754a7 100644 --- a/src/app_modules/investasi/fun/get_investasi_by_id.ts +++ b/src/app_modules/investasi/fun/get_investasi_by_id.ts @@ -2,9 +2,13 @@ import prisma from "@/app/lib/prisma"; -export default async function getInvestasiById(id: string) { +export default async function getInvestasiByStatusId( + id: string, +) { const data = await prisma.user.findUnique({ - where: { id: id }, + where: { + id: id, + }, select: { Investasi: { select: { diff --git a/src/app_modules/investasi/fun/get_list_all_investasi.ts b/src/app_modules/investasi/fun/get_list_all_investasi.ts deleted file mode 100644 index b5b72cea..00000000 --- a/src/app_modules/investasi/fun/get_list_all_investasi.ts +++ /dev/null @@ -1,13 +0,0 @@ -"use server"; - -import prisma from "@/app/lib/prisma"; - -export async function getListAllInvestasi() { - const data = await prisma.investasi.findMany({ - orderBy: { - createdAt: "desc" - } - }); - - return data; -} diff --git a/src/app_modules/investasi/fun/get_list_all_publish.ts b/src/app_modules/investasi/fun/get_list_all_publish.ts new file mode 100644 index 00000000..57d9e0cc --- /dev/null +++ b/src/app_modules/investasi/fun/get_list_all_publish.ts @@ -0,0 +1,44 @@ +"use server"; + +import prisma from "@/app/lib/prisma"; + +export async function getListAllPublish() { + const data = await prisma.investasi.findMany({ + orderBy: { + updatedAt: "desc", + }, + where: { + MasterStatusInvestasi: { + name: { + equals: "Publish", + }, + }, + AND: { + active: true + } + }, + select: { + id: true, + title: true, + authorId: true, + hargaLembar: true, + targetDana: true, + totalLembar: true, + roi: true, + active: true, + createdAt: true, + updatedAt: true, + imagesId: true, + MasterStatusInvestasi: true, + BeritaInvestasi: true, + DokumenInvestasi: true, + ProspektusInvestasi: true, + MasterPembagianDeviden: true, + MasterPencarianInvestor: true, + MasterPeriodeDeviden: true, + SahamTerbeli: true, + }, + }); + + return data; +} diff --git a/src/app_modules/investasi/fun/get_one_investasi_by_id.ts b/src/app_modules/investasi/fun/get_one_investasi_by_id.ts index 79ee49e1..1d76e214 100644 --- a/src/app_modules/investasi/fun/get_one_investasi_by_id.ts +++ b/src/app_modules/investasi/fun/get_one_investasi_by_id.ts @@ -16,6 +16,9 @@ export default async function getOneInvestasiById(id: string) { totalLembar: true, roi: true, active: true, + createdAt: true, + updatedAt: true, + catatan: true, imagesId: true, MasterStatusInvestasi: true, BeritaInvestasi: true, diff --git a/src/app_modules/investasi/fun/get_porto_status_by_id.ts b/src/app_modules/investasi/fun/get_porto_status_by_id.ts new file mode 100644 index 00000000..8d1040ad --- /dev/null +++ b/src/app_modules/investasi/fun/get_porto_status_by_id.ts @@ -0,0 +1,104 @@ +"use server"; + +import prisma from "@/app/lib/prisma"; + +export default async function getPortoByStatusId(id: string, statusId: number) { + // Draft + if (statusId === 1) { + const data = await prisma.investasi.findMany({ + orderBy: { + updatedAt: "desc", + }, + where: { + authorId: id, + MasterStatusInvestasi: { + name: "Draft", + }, + }, + select: { + id: true, + title: true, + imagesId: true, + // hargaLembar: true, + // targetDana: true, + // totalLembar: true, + // roi: true, + // active: true, + // MasterStatusInvestasi: true, + // BeritaInvestasi: true, + // DokumenInvestasi: true, + // ProspektusInvestasi: true, + // MasterPembagianDeviden: true, + // MasterPencarianInvestor: true, + // MasterPeriodeDeviden: true, + // SahamTerbeli: true, + }, + }); + return data; + } + + // Review + if (statusId === 2) { + const data = await prisma.investasi.findMany({ + orderBy: { + createdAt: "desc", + }, + where: { + authorId: id, + MasterStatusInvestasi: { + name: "Review", + }, + }, + select: { + id: true, + title: true, + imagesId: true, + }, + }); + return data; + } + + // Publish + if (statusId === 3) { + const data = await prisma.investasi.findMany({ + orderBy: { + updatedAt: "desc", + }, + where: { + authorId: id, + MasterStatusInvestasi: { + name: "Publish", + }, + }, + select: { + id: true, + title: true, + imagesId: true, + updatedAt: true, + MasterPencarianInvestor: true, + }, + }); + return data; + } + + // Reject + if (statusId === 4) { + const data = await prisma.investasi.findMany({ + orderBy: { + updatedAt: "desc", + }, + where: { + authorId: id, + MasterStatusInvestasi: { + name: "Reject", + }, + }, + select: { + id: true, + title: true, + imagesId: true, + }, + }); + return data; + } +} diff --git a/src/app_modules/investasi/main/view.tsx b/src/app_modules/investasi/main/view.tsx index 1837830d..48348d70 100644 --- a/src/app_modules/investasi/main/view.tsx +++ b/src/app_modules/investasi/main/view.tsx @@ -10,10 +10,12 @@ import { Card, CardSection, Divider, + Flex, Grid, Group, Image, Paper, + Progress, Slider, Stack, Text, @@ -24,6 +26,8 @@ import dataDummy from "../dummy/data_dummy.json"; import moment from "moment"; import { IconCheck, IconCircleCheck } from "@tabler/icons-react"; import { MODEL_Investasi } from "../model/model_investasi"; +import _ from "lodash"; +import { useState } from "react"; export default function MainInvestasi({ listData, @@ -31,17 +35,19 @@ export default function MainInvestasi({ periodeDeviden, pembagianDeviden, }: { - listData: MODEL_Investasi[] + listData: MODEL_Investasi[]; pencarianInvestor: MODEL_DEFAULT_MASTER[]; periodeDeviden: MODEL_DEFAULT_MASTER[]; pembagianDeviden: MODEL_DEFAULT_MASTER[]; }) { const router = useRouter(); + const [investasi, setInvestasi] = useState(listData); return ( <> {/*
{JSON.stringify(listData, null, 2)}
*/} - {dataDummy.map((e) => ( + + {investasi.map((e) => ( + {/* Progress dan titlr */} - + {e.title} - - + + @@ -102,9 +103,9 @@ export default function MainInvestasi({ - + - {e.saham_beli === 0 ? ( + {e.SahamTerbeli === null ? ( "" ) : ( @@ -112,9 +113,10 @@ export default function MainInvestasi({ )} + {(() => { if ( - e.masterPencarianInvestorId - + Number(e.MasterPencarianInvestor.name) - moment(new Date()).diff(new Date(e.createdAt), "days") <= 0 ) { @@ -132,9 +134,9 @@ export default function MainInvestasi({ Sisa waktu: - {e.masterPencarianInvestorId - + {Number(e.MasterPencarianInvestor.name) - moment(new Date()).diff( - new Date(e.createdAt), + new Date(e.updatedAt), "days" )} @@ -144,7 +146,7 @@ export default function MainInvestasi({ ); } })()} - + ))} diff --git a/src/app_modules/investasi/portofolio/draft.tsx b/src/app_modules/investasi/portofolio/draft.tsx new file mode 100644 index 00000000..a44650fb --- /dev/null +++ b/src/app_modules/investasi/portofolio/draft.tsx @@ -0,0 +1,61 @@ +import { RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; +import { + Card, + CardSection, + AspectRatio, + Box, + Title, + Divider, + Group, + Badge, + Image, + Text, + Center, +} from "@mantine/core"; +import { useRouter } from "next/navigation"; +import { MODEL_Investasi } from "../model/model_investasi"; +import _ from "lodash"; + +export default function Draft({ data }: { data: MODEL_Investasi[] }) { + const router = useRouter(); + + return ( + <> + {/*
 {JSON.stringify(data,null, 2)}
*/} + {data.map((e) => + + router.push(RouterInvestasi.detail_draft + `${e.id}`) + } + > + + + + + + + + + {e.title} + + + + + + + Draft + + + + + )} + + ); +} diff --git a/src/app_modules/investasi/portofolio/publish.tsx b/src/app_modules/investasi/portofolio/publish.tsx new file mode 100644 index 00000000..49c3af55 --- /dev/null +++ b/src/app_modules/investasi/portofolio/publish.tsx @@ -0,0 +1,96 @@ +import { RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; +import { + Card, + CardSection, + AspectRatio, + Box, + Title, + Slider, + Divider, + Group, + Badge, + Image, + Text, + Center, +} from "@mantine/core"; +import { useRouter } from "next/navigation"; +import { + MODEL_Investasi, + MODEL_Status_investasi, +} from "../model/model_investasi"; +import _ from "lodash"; +import moment from "moment"; +import { useState } from "react"; +import { IconCircleCheck } from "@tabler/icons-react"; + +export default function Publish({ data }: { data: MODEL_Investasi[] }) { + const router = useRouter(); + const [sisaWaktu, setSisaWaktu] = useState(); + if (_.isEmpty(data)) + return ( + <> +
Tidak ada Publish
+ + ); + + return ( + <> + {data.map((e) => ( + + router.push(RouterInvestasi.detail_publish + `${e.id}`) + } + > + + + + + + + + + {e.title} + {/* */} + + + + + {Number(e.MasterPencarianInvestor.name) - + moment(new Date()).diff(new Date(e.updatedAt), "days") <= + 0 ? ( + + + Selesai + + ) : ( + + + Publish + + + Sisa Waktu :{" "} + {Number(e.MasterPencarianInvestor.name) - + moment(new Date()).diff(new Date(e.updatedAt), "days")}{" "} + hari + + + )} + + + ))} + + ); +} diff --git a/src/app_modules/investasi/portofolio/reject.tsx b/src/app_modules/investasi/portofolio/reject.tsx new file mode 100644 index 00000000..c057650e --- /dev/null +++ b/src/app_modules/investasi/portofolio/reject.tsx @@ -0,0 +1,71 @@ +import { RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; +import { + Card, + CardSection, + AspectRatio, + Box, + Title, + Divider, + Group, + Badge, + Image, + Text, + Center, +} from "@mantine/core"; +import { useRouter } from "next/navigation"; +import { + MODEL_Investasi, + MODEL_Status_investasi, +} from "../model/model_investasi"; +import { useState } from "react"; +import _ from "lodash"; + +export default function Reject({ data }: { data: MODEL_Investasi[] }) { + const [investasi, setInvestasi] = useState(data); + const router = useRouter(); + + if (_.isEmpty(data)) + return ( + <> +
Tidak ada Reject
+ + ); + + return ( + <> + + {investasi.map((e) => ( + router.push(RouterInvestasi.detail_reject + `${e.id}`)} + > + + + + + + + + + {e.title} + + + + + + + Reject + + + + + ))} + + ); +} diff --git a/src/app_modules/investasi/portofolio/review.tsx b/src/app_modules/investasi/portofolio/review.tsx new file mode 100644 index 00000000..bc58bb6d --- /dev/null +++ b/src/app_modules/investasi/portofolio/review.tsx @@ -0,0 +1,67 @@ +import { RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; +import { + Card, + CardSection, + AspectRatio, + Box, + Title, + Divider, + Group, + Badge, + Image, + Center, + Text, +} from "@mantine/core"; +import { useRouter } from "next/navigation"; +import { + MODEL_Status_investasi, + MODEL_Investasi, +} from "../model/model_investasi"; +import _ from "lodash"; + +export default function Review({ data }: { data: MODEL_Investasi[] }) { + const router = useRouter(); + + if (_.isEmpty(data)) + return ( + <> +
Tidak ada Review
+ + ); + return ( + <> + {data.map((e) => ( + router.push(RouterInvestasi.detail_review + `${e.id}`)} + > + + + + + + + + + {e.title} + + + + + + + Review + + + + + ))} + + ); +} diff --git a/src/app_modules/investasi/portofolio/view.tsx b/src/app_modules/investasi/portofolio/view.tsx index f57cbd2d..ded43286 100644 --- a/src/app_modules/investasi/portofolio/view.tsx +++ b/src/app_modules/investasi/portofolio/view.tsx @@ -47,18 +47,26 @@ import { MODEL_Status_investasi, } from "../model/model_investasi"; import _ from "lodash"; +import Draft from "./draft"; +import Review from "./review"; +import Publish from "./publish"; +import Reject from "./reject"; export default function PortofolioInvestasi({ - dataInvestasi, listStatusInvestasi, + dataDraft, + dataReview, + dataPublish, + dataReject, }: { - dataInvestasi: any listStatusInvestasi: any; + dataDraft: any; + dataReview: any; + dataPublish: any; + dataReject: any; }) { const router = useRouter(); const [activeTab, setActiveTab] = useAtom(gs_StatusPortoInvestasi); - - const [investasi, setInvestasi] = useState(dataInvestasi); const [status_inves, setStatus_inves] = useState(listStatusInvestasi); @@ -85,190 +93,18 @@ export default function PortofolioInvestasi({ - + - + - + - + ); } - -function Draft({ data }: { data: MODEL_Investasi[] }) { - const router = useRouter(); - return ( - <> - {data.map((e) => - e.MasterStatusInvestasi.id === "1" ? ( - - router.push(RouterInvestasi.detail_draft + `${e.id}`) - } - > - - - - - - - - - {e.title} - - - - - - - Draft - - - - - ) : ( - "" - ) - )} - - ); -} - -function Review({ - status, - data, -}: { - status: MODEL_Status_investasi; - data: MODEL_Investasi[]; -}) { - const router = useRouter(); - return ( - <> - {data.map((e) => - e.MasterStatusInvestasi.id === "2" ? ( - router.push(RouterInvestasi.detail_review + `${e.id}`)} - > - - - - - - - - - {e.title} - - - - - - - Review - - - - - ) : ( - "" - ) - )} - - ); -} - -function Publish({ status }: { status: MODEL_Status_investasi }) { - const router = useRouter(); - return ( - <> - router.push(RouterInvestasi.detail_publish)} - > - - - - - - - - - Judul Investasi - - - - - - - - {status.name} - - Sisa Waktu : 30 Hari - - - - - ); -} - -function Reject({ status }: { status: MODEL_Status_investasi }) { - const router = useRouter(); - return ( - <> - router.push(RouterInvestasi.detail_reject)} - > - - - - - - - - - Judul Investasi - - - - - - - {status.name} - - - - - - ); -}