From 5ff74b00f55751cc951b959f2d9bccda403158dc Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Tue, 15 Oct 2024 11:06:14 +0800 Subject: [PATCH] Fix: Investasi Deskripsi: - Upload gambar investasi ke storage wibu - Upload bukti transfer ke storage wibu # No Issue --- package.json | 2 +- prisma/schema.prisma | 7 +- src/app/dev/colab/create/page.tsx | 1 - .../investasi/create/dokumen/[id]/page.tsx | 11 + .../create/{ => investasi}/layout.tsx | 0 .../investasi/create/{ => investasi}/page.tsx | 2 - .../detail/daftar-dokumen/[id]/page.tsx | 19 + .../investasi/detail/portofolio/[id]/page.tsx | 15 + .../investasi/detail/prospektus/[id]/page.tsx | 13 + .../detail/rekap-dokumen/[id]/page.tsx | 17 + .../detail_portofolio/draft/[id]/page.tsx | 4 +- src/app/dev/investasi/edit/[id]/layout.tsx | 9 - src/app/dev/investasi/edit/[id]/loading.tsx | 9 - src/app/dev/investasi/edit/[id]/page.tsx | 36 +- .../dev/investasi/edit/dokumen/[id]/page.tsx | 14 + .../investasi/edit/prospektus/[id]/page.tsx | 11 + .../file-view/prospektus/[id]/page.tsx | 4 +- .../investasi/main/portofolio/[id]/page.tsx | 22 + .../dev/investasi/main/portofolio/page.tsx | 36 -- .../draft/[id]/layout.tsx | 0 .../x_detail_portofolio/draft/[id]/page.tsx | 13 + .../publish/[id]/layout.tsx | 0 .../x_detail_portofolio/publish/[id]/page.tsx | 11 + .../reject/[id]/layout.tsx | 0 .../reject/[id]/page.tsx | 0 .../review/[id]/layout.tsx | 0 .../review/[id]/page.tsx | 0 src/app/lib/APIs.ts | 6 + src/app/lib/id-derectory.ts | 3 +- src/app/lib/router_hipmi/router_investasi.ts | 63 +- .../_global/component/box_information.tsx | 36 +- .../component/comp_box_upload_image.tsx | 4 +- .../_global/component/comp_load_image.tsx | 9 +- .../component/comp_load_image_custom.tsx | 60 ++ .../component/comp_load_image_landscape.tsx | 3 +- src/app_modules/_global/component/index.ts | 2 + .../fun/delete/fun_delete_file_by_id.tsx | 24 + src/app_modules/_global/fun/index.ts | 2 + src/app_modules/_global/ui/index.ts | 2 + .../_global/ui/ui_drawer_custom.tsx | 72 +++ .../_global/ui/ui_image_preview.tsx | 23 +- .../comp_button_create_new_investasi.tsx | 140 +++++ .../button/comp_button_update_investasi.tsx | 90 +++ .../detail/comp_box_daftar_berita.tsx | 19 +- .../detail/comp_box_daftar_dokumen.tsx | 22 +- .../_component/detail/comp_box_prospektus.tsx | 24 +- .../detail/comp_card_daftar_document.tsx | 37 ++ .../detail/comp_card_rekap_document.tsx | 181 ++++++ .../detail/comp_detail_data_non_publish.tsx | 106 ++++ .../detail/comp_title_and_value_in_detail.tsx | 23 + .../detail/saham_saya/comp_detail_data.tsx | 30 +- src/app_modules/investasi/_component/index.ts | 12 + .../_component/main/comp_card_beranda.tsx | 180 +++--- .../main/comp_card_portofolio_not_publish.tsx | 33 +- .../main/comp_card_portofolio_publish.tsx | 2 +- .../_component/main/comp_footer_main.tsx | 11 +- .../_fun/create/fun_create_document.tsx | 28 + .../_fun/create/fun_create_new_investasi.tsx | 62 ++ .../_fun/delete/fun_delete_dokumen.tsx | 21 + .../investasi/_fun/edit/fun_edit_document.tsx | 67 ++ .../_fun/edit/fun_edit_investasi.tsx | 67 ++ .../_fun/edit/fun_edit_prospektus.tsx | 29 + .../_fun/get/fun_get_all_document_by_id.tsx | 28 + .../_fun/get/fun_get_one_document_by_id.tsx | 13 + .../_fun/get/fun_get_one_investasi_by_id.ts | 1 + .../get/fun_get_portofolio_by_status_id.ts | 34 ++ src/app_modules/investasi/_fun/index.ts | 24 + .../_fun/upload/fun_upload_bukti_transfer.tsx | 27 +- src/app_modules/investasi/_lib/interface.ts | 8 +- .../_ui/create/ui_create_document.tsx | 16 + .../_ui/detail/ui_daftar_dokumen.tsx | 28 + .../_ui/detail/ui_detail_portofolio.tsx | 102 ++++ .../_ui/detail/ui_detail_prospektus.tsx | 23 + .../investasi/_ui/detail/ui_rekap_dokumen.tsx | 62 ++ .../investasi/_ui/edit/ui_edit_dokumen.tsx | 19 + .../investasi/_ui/edit/ui_edit_investasi.tsx | 34 ++ .../investasi/_ui/edit/ui_edit_prospektus.tsx | 23 + .../_ui/file_view/ui_file_view_dokumen.tsx | 12 +- .../_ui/file_view/ui_file_view_prospektus.tsx | 16 +- src/app_modules/investasi/_ui/index.ts | 16 + .../investasi/_ui/main/ui_layout_main.tsx | 7 +- .../investasi/_ui/main/ui_portofolio.tsx | 74 ++- .../_view/create/view_create_document.tsx | 159 +++++ .../detail/portofolio/view_detai_publish.tsx | 232 +++++++ .../detail/portofolio/view_detail_draft.tsx | 92 +++ .../detail/portofolio/view_detail_reject.tsx | 114 ++++ .../detail/portofolio/view_detail_review.tsx | 85 +++ .../_view/detail/view_daftar_dokemen.tsx | 61 ++ .../_view/detail/view_detail_prospektusl.tsx | 46 ++ .../_view/detail/view_rekap_dokumen.tsx | 60 ++ .../_view/edit/view_edit_dokumen.tsx | 180 ++++++ .../_view/edit/view_edit_investasi.tsx | 328 ++++++++++ .../_view/edit/view_edit_prospektus.tsx | 148 +++++ src/app_modules/investasi/_view/index.ts | 23 +- .../main/portofolio/view_portofolio_draft.tsx | 20 +- .../portofolio/view_portofolio_publish.tsx | 16 +- .../portofolio/view_portofolio_reject.tsx | 20 +- .../portofolio/view_portofolio_review.tsx | 20 +- .../investasi/_view/main/view_portofolio.tsx | 152 +---- .../view_invoice_berhasil.tsx | 8 +- .../_view/transaksi/view_invoice.tsx | 16 +- .../_view/transaksi/view_proses_pembelian.tsx | 9 +- .../detail/detai_data_non_publish.tsx | 159 ----- .../detail/x_detai_data_non_publish.tsx | 113 ++++ src/app_modules/investasi/create/view.tsx | 576 ++++++++---------- src/app_modules/investasi/detail/view.tsx | 19 +- .../investasi/detail_dokumen/view.tsx | 2 +- .../detail_portofolio/draft/index.tsx | 2 +- .../detail_portofolio/publish/layout.tsx | 38 +- .../detail_portofolio/reject/index.tsx | 8 +- .../detail_portofolio/review/index.tsx | 5 +- .../investasi/detail_prospektus/view.tsx | 2 +- src/app_modules/investasi/edit/layout.tsx | 14 - src/app_modules/investasi/edit/view.tsx | 75 --- src/app_modules/investasi/edit_intro/view.tsx | 1 + .../investasi/fun/fun_edit_investasi.ts | 2 +- .../investasi/fun/get_one_investasi_by_id.ts | 2 + .../fun/master/get_pencarian_investor.ts | 4 +- src/app_modules/investasi/g_state/index.ts | 10 +- src/app_modules/investasi/index.ts | 4 - src/app_modules/map/ui/ui_edit_map.tsx | 20 +- 121 files changed, 4022 insertions(+), 1139 deletions(-) create mode 100644 src/app/dev/investasi/create/dokumen/[id]/page.tsx rename src/app/dev/investasi/create/{ => investasi}/layout.tsx (100%) rename src/app/dev/investasi/create/{ => investasi}/page.tsx (91%) create mode 100644 src/app/dev/investasi/detail/daftar-dokumen/[id]/page.tsx create mode 100644 src/app/dev/investasi/detail/portofolio/[id]/page.tsx create mode 100644 src/app/dev/investasi/detail/prospektus/[id]/page.tsx create mode 100644 src/app/dev/investasi/detail/rekap-dokumen/[id]/page.tsx delete mode 100644 src/app/dev/investasi/edit/[id]/layout.tsx delete mode 100644 src/app/dev/investasi/edit/[id]/loading.tsx create mode 100644 src/app/dev/investasi/edit/dokumen/[id]/page.tsx create mode 100644 src/app/dev/investasi/edit/prospektus/[id]/page.tsx create mode 100644 src/app/dev/investasi/main/portofolio/[id]/page.tsx delete mode 100644 src/app/dev/investasi/main/portofolio/page.tsx rename src/app/dev/investasi/{detail_portofolio => x_detail_portofolio}/draft/[id]/layout.tsx (100%) create mode 100644 src/app/dev/investasi/x_detail_portofolio/draft/[id]/page.tsx rename src/app/dev/investasi/{detail_portofolio => x_detail_portofolio}/publish/[id]/layout.tsx (100%) create mode 100644 src/app/dev/investasi/x_detail_portofolio/publish/[id]/page.tsx rename src/app/dev/investasi/{detail_portofolio => x_detail_portofolio}/reject/[id]/layout.tsx (100%) rename src/app/dev/investasi/{detail_portofolio => x_detail_portofolio}/reject/[id]/page.tsx (100%) rename src/app/dev/investasi/{detail_portofolio => x_detail_portofolio}/review/[id]/layout.tsx (100%) rename src/app/dev/investasi/{detail_portofolio => x_detail_portofolio}/review/[id]/page.tsx (100%) create mode 100644 src/app_modules/_global/component/comp_load_image_custom.tsx create mode 100644 src/app_modules/_global/fun/delete/fun_delete_file_by_id.tsx create mode 100644 src/app_modules/_global/ui/ui_drawer_custom.tsx create mode 100644 src/app_modules/investasi/_component/button/comp_button_create_new_investasi.tsx create mode 100644 src/app_modules/investasi/_component/button/comp_button_update_investasi.tsx create mode 100644 src/app_modules/investasi/_component/detail/comp_card_daftar_document.tsx create mode 100644 src/app_modules/investasi/_component/detail/comp_card_rekap_document.tsx create mode 100644 src/app_modules/investasi/_component/detail/comp_detail_data_non_publish.tsx create mode 100644 src/app_modules/investasi/_component/detail/comp_title_and_value_in_detail.tsx create mode 100644 src/app_modules/investasi/_fun/create/fun_create_document.tsx create mode 100644 src/app_modules/investasi/_fun/create/fun_create_new_investasi.tsx create mode 100644 src/app_modules/investasi/_fun/delete/fun_delete_dokumen.tsx create mode 100644 src/app_modules/investasi/_fun/edit/fun_edit_document.tsx create mode 100644 src/app_modules/investasi/_fun/edit/fun_edit_investasi.tsx create mode 100644 src/app_modules/investasi/_fun/edit/fun_edit_prospektus.tsx create mode 100644 src/app_modules/investasi/_fun/get/fun_get_all_document_by_id.tsx create mode 100644 src/app_modules/investasi/_fun/get/fun_get_one_document_by_id.tsx create mode 100644 src/app_modules/investasi/_fun/get/fun_get_portofolio_by_status_id.ts create mode 100644 src/app_modules/investasi/_ui/create/ui_create_document.tsx create mode 100644 src/app_modules/investasi/_ui/detail/ui_daftar_dokumen.tsx create mode 100644 src/app_modules/investasi/_ui/detail/ui_detail_portofolio.tsx create mode 100644 src/app_modules/investasi/_ui/detail/ui_detail_prospektus.tsx create mode 100644 src/app_modules/investasi/_ui/detail/ui_rekap_dokumen.tsx create mode 100644 src/app_modules/investasi/_ui/edit/ui_edit_dokumen.tsx create mode 100644 src/app_modules/investasi/_ui/edit/ui_edit_investasi.tsx create mode 100644 src/app_modules/investasi/_ui/edit/ui_edit_prospektus.tsx create mode 100644 src/app_modules/investasi/_view/create/view_create_document.tsx create mode 100644 src/app_modules/investasi/_view/detail/portofolio/view_detai_publish.tsx create mode 100644 src/app_modules/investasi/_view/detail/portofolio/view_detail_draft.tsx create mode 100644 src/app_modules/investasi/_view/detail/portofolio/view_detail_reject.tsx create mode 100644 src/app_modules/investasi/_view/detail/portofolio/view_detail_review.tsx create mode 100644 src/app_modules/investasi/_view/detail/view_daftar_dokemen.tsx create mode 100644 src/app_modules/investasi/_view/detail/view_detail_prospektusl.tsx create mode 100644 src/app_modules/investasi/_view/detail/view_rekap_dokumen.tsx create mode 100644 src/app_modules/investasi/_view/edit/view_edit_dokumen.tsx create mode 100644 src/app_modules/investasi/_view/edit/view_edit_investasi.tsx create mode 100644 src/app_modules/investasi/_view/edit/view_edit_prospektus.tsx delete mode 100644 src/app_modules/investasi/component/detail/detai_data_non_publish.tsx create mode 100644 src/app_modules/investasi/component/detail/x_detai_data_non_publish.tsx delete mode 100644 src/app_modules/investasi/edit/layout.tsx delete mode 100644 src/app_modules/investasi/edit/view.tsx diff --git a/package.json b/package.json index e8f914d1..9b56140c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hipmi", - "version": "1.0.3", + "version": "1.0.4", "private": true, "prisma": { "seed": "npx tsx prisma/seed.ts" diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 591c38cd..1d534fd1 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -217,7 +217,8 @@ model Investasi { masterProgresInvestasiId String? Investasi_Invoice Investasi_Invoice[] - imageId String? + imageId String? + prospektusFileId String? } model MasterPencarianInvestor { @@ -273,7 +274,7 @@ model ProspektusInvestasi { model DokumenInvestasi { id String @id @default(cuid()) title String - url String + url String? active Boolean @default(true) createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt @@ -372,6 +373,8 @@ model Investasi_Invoice { Images Images? @relation(fields: [imagesId], references: [id]) imagesId String? + + imageId String? } model InvestasiMaster_StatusInvoice { diff --git a/src/app/dev/colab/create/page.tsx b/src/app/dev/colab/create/page.tsx index b0dcdc7c..f1d84a65 100644 --- a/src/app/dev/colab/create/page.tsx +++ b/src/app/dev/colab/create/page.tsx @@ -1,6 +1,5 @@ import { Colab_Create } from "@/app_modules/colab"; import colab_funGetMasterIndustri from "@/app_modules/colab/fun/master/fun_get_master_industri"; -import colab_funGetMasterStatus from "@/app_modules/colab/fun/master/fun_get_master_status"; export default async function Page() { const listIndustri = await colab_funGetMasterIndustri(); diff --git a/src/app/dev/investasi/create/dokumen/[id]/page.tsx b/src/app/dev/investasi/create/dokumen/[id]/page.tsx new file mode 100644 index 00000000..66a66f7c --- /dev/null +++ b/src/app/dev/investasi/create/dokumen/[id]/page.tsx @@ -0,0 +1,11 @@ +import { Investasi_UiCreateDocument } from "@/app_modules/investasi/_ui"; + +export default async function Page({ params }: { params: { id: string } }) { + const investasiId = params.id; + + return ( + <> + + + ); +} diff --git a/src/app/dev/investasi/create/layout.tsx b/src/app/dev/investasi/create/investasi/layout.tsx similarity index 100% rename from src/app/dev/investasi/create/layout.tsx rename to src/app/dev/investasi/create/investasi/layout.tsx diff --git a/src/app/dev/investasi/create/page.tsx b/src/app/dev/investasi/create/investasi/page.tsx similarity index 91% rename from src/app/dev/investasi/create/page.tsx rename to src/app/dev/investasi/create/investasi/page.tsx index 4e0df510..ba8af421 100644 --- a/src/app/dev/investasi/create/page.tsx +++ b/src/app/dev/investasi/create/investasi/page.tsx @@ -3,8 +3,6 @@ import getPembagianDeviden from "@/app_modules/investasi/fun/master/get_pembagia import getPencarianInvestor from "@/app_modules/investasi/fun/master/get_pencarian_investor"; import getPeriodeDeviden from "@/app_modules/investasi/fun/master/get_periode_deviden"; import getStatusInvestasi from "@/app_modules/investasi/fun/master/get_status_investasi"; -import { unsealData } from "iron-session"; -import { cookies } from "next/headers"; export default async function Page() { diff --git a/src/app/dev/investasi/detail/daftar-dokumen/[id]/page.tsx b/src/app/dev/investasi/detail/daftar-dokumen/[id]/page.tsx new file mode 100644 index 00000000..7da6559d --- /dev/null +++ b/src/app/dev/investasi/detail/daftar-dokumen/[id]/page.tsx @@ -0,0 +1,19 @@ +import { + investasi_funGetAllDocumentById, + investasi_funGetOneInvestasiById, +} from "@/app_modules/investasi/_fun"; +import { Investasi_UiDaftarDokmen } from "@/app_modules/investasi/_ui"; + +export default async function Page({ params }: { params: { id: string } }) { + const investasiId = params.id; + const dataDokumen = await investasi_funGetAllDocumentById({ + investasiId: investasiId, + page: 1, + }); + + return ( + <> + + + ); +} diff --git a/src/app/dev/investasi/detail/portofolio/[id]/page.tsx b/src/app/dev/investasi/detail/portofolio/[id]/page.tsx new file mode 100644 index 00000000..7a3e4524 --- /dev/null +++ b/src/app/dev/investasi/detail/portofolio/[id]/page.tsx @@ -0,0 +1,15 @@ +import { investasi_funGetOneInvestasiById } from "@/app_modules/investasi/_fun"; +import { Investasi_UiDetailPortofolio } from "@/app_modules/investasi/_ui"; + +export default async function Page({ params }: { params: { id: string } }) { + const investasiId = params.id; + const dataPortofolio = await investasi_funGetOneInvestasiById({ + investasiId, + }); + + return ( + <> + + + ); +} diff --git a/src/app/dev/investasi/detail/prospektus/[id]/page.tsx b/src/app/dev/investasi/detail/prospektus/[id]/page.tsx new file mode 100644 index 00000000..a42503a5 --- /dev/null +++ b/src/app/dev/investasi/detail/prospektus/[id]/page.tsx @@ -0,0 +1,13 @@ +import { investasi_funGetOneInvestasiById } from "@/app_modules/investasi/_fun"; +import { Investasi_UiDetailProspektus } from "@/app_modules/investasi/_ui"; + +export default async function Page({ params }: { params: { id: string } }) { + const investasiId = params.id; + const dataInvestasi = await investasi_funGetOneInvestasiById({ investasiId }); + + return ( + <> + + + ); +} diff --git a/src/app/dev/investasi/detail/rekap-dokumen/[id]/page.tsx b/src/app/dev/investasi/detail/rekap-dokumen/[id]/page.tsx new file mode 100644 index 00000000..611813b5 --- /dev/null +++ b/src/app/dev/investasi/detail/rekap-dokumen/[id]/page.tsx @@ -0,0 +1,17 @@ +import { investasi_funGetAllDocumentById } from "@/app_modules/investasi/_fun"; +import { Investasi_UiRekapDokumen } from "@/app_modules/investasi/_ui"; + +export default async function Page({ params }: { params: { id: string } }) { + const investasiId = params.id; + const dataDokumen = await investasi_funGetAllDocumentById({ investasiId, page: 1 }); + + + return ( + <> + + + ); +} diff --git a/src/app/dev/investasi/detail_portofolio/draft/[id]/page.tsx b/src/app/dev/investasi/detail_portofolio/draft/[id]/page.tsx index ce6a3451..02d9b04d 100644 --- a/src/app/dev/investasi/detail_portofolio/draft/[id]/page.tsx +++ b/src/app/dev/investasi/detail_portofolio/draft/[id]/page.tsx @@ -1,5 +1,5 @@ -import { DetailDraftInvestasi } from "@/app_modules/investasi"; -import getOneInvestasiById from "@/app_modules/investasi/fun/get_one_investasi_by_id"; +import { DetailDraftInvestasi } 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}}) { diff --git a/src/app/dev/investasi/edit/[id]/layout.tsx b/src/app/dev/investasi/edit/[id]/layout.tsx deleted file mode 100644 index 5ab6c294..00000000 --- a/src/app/dev/investasi/edit/[id]/layout.tsx +++ /dev/null @@ -1,9 +0,0 @@ - -import { LayoutEditInvestasi } 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/edit/[id]/loading.tsx b/src/app/dev/investasi/edit/[id]/loading.tsx deleted file mode 100644 index d8a1c040..00000000 --- a/src/app/dev/investasi/edit/[id]/loading.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import ComponentGlobal_V2_LoadingPage from "@/app_modules/_global/loading_page_v2"; - -export default async function Page() { - return ( - <> - - - ); -} diff --git a/src/app/dev/investasi/edit/[id]/page.tsx b/src/app/dev/investasi/edit/[id]/page.tsx index e4aa7e1a..5d91e4d2 100644 --- a/src/app/dev/investasi/edit/[id]/page.tsx +++ b/src/app/dev/investasi/edit/[id]/page.tsx @@ -1,11 +1,39 @@ -import { EditInvestasi } from "@/app_modules/investasi"; +import { investasi_funGetOneInvestasiById } from "@/app_modules/investasi/_fun"; +import { Investasi_UiEditInvestasi } from "@/app_modules/investasi/_ui"; +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"; +import _ from "lodash"; +export default async function Page({ params }: { params: { id: string } }) { + const investasiId = params.id; + // console.log(investasiId); + + const allData = await investasi_funGetOneInvestasiById({ investasiId }); + const dataInvestasi = _.omit(allData, [ + "BeritaInvestasi", + "DokumenInvestasi", + "MasterPembagianDeviden", + "MasterPencarianInvestor", + "MasterProgresInvestasi", + "MasterStatusInvestasi", + "ProspektusInvestasi", + "MasterPeriodeDeviden", + "author", + ]); + + const listPencarian = await getPencarianInvestor(); + const listPeriode = await getPeriodeDeviden(); + const listPembagian = await getPembagianDeviden(); -export default async function Page({params}: {params: {id: string}}) { return ( <> - - + ); } diff --git a/src/app/dev/investasi/edit/dokumen/[id]/page.tsx b/src/app/dev/investasi/edit/dokumen/[id]/page.tsx new file mode 100644 index 00000000..95da1b64 --- /dev/null +++ b/src/app/dev/investasi/edit/dokumen/[id]/page.tsx @@ -0,0 +1,14 @@ +import { investasi_funGetOneDocumentById } from "@/app_modules/investasi/_fun"; +import { Investasi_UiEditDokumen } from "@/app_modules/investasi/_ui"; + +export default async function Page({ params }: { params: { id: string } }) { + const documentId = params.id; + const dataDokumen = await investasi_funGetOneDocumentById({ documentId }); + + + return ( + <> + + + ); +} diff --git a/src/app/dev/investasi/edit/prospektus/[id]/page.tsx b/src/app/dev/investasi/edit/prospektus/[id]/page.tsx new file mode 100644 index 00000000..519debdf --- /dev/null +++ b/src/app/dev/investasi/edit/prospektus/[id]/page.tsx @@ -0,0 +1,11 @@ +import { Investasi_UiEditProspektus } from "@/app_modules/investasi/_ui"; + +export default async function Page({ params }: { params: { id: string } }) { + const investasiId = params.id; + + return ( + <> + + + ); +} diff --git a/src/app/dev/investasi/file-view/prospektus/[id]/page.tsx b/src/app/dev/investasi/file-view/prospektus/[id]/page.tsx index cb7f2e3c..25de80fd 100644 --- a/src/app/dev/investasi/file-view/prospektus/[id]/page.tsx +++ b/src/app/dev/investasi/file-view/prospektus/[id]/page.tsx @@ -2,11 +2,11 @@ import { investasi_funGetProspekById } from "@/app_modules/investasi/_fun"; import { Investasi_UiFileView } from "@/app_modules/investasi/_ui"; export default async function Page({ params }: { params: { id: string } }) { - const prospekId = params.id; + const pospektusId = params.id; return ( <> - + ); } diff --git a/src/app/dev/investasi/main/portofolio/[id]/page.tsx b/src/app/dev/investasi/main/portofolio/[id]/page.tsx new file mode 100644 index 00000000..b8378bd8 --- /dev/null +++ b/src/app/dev/investasi/main/portofolio/[id]/page.tsx @@ -0,0 +1,22 @@ +import { investasi_funGetPortofolioByStatusId } from "@/app_modules/investasi/_fun"; +import { Investasi_UiPortofolio } from "@/app_modules/investasi/_ui"; +import getStatusInvestasi from "@/app_modules/investasi/fun/master/get_status_investasi"; + +export default async function Page({ params }: { params: { id: string } }) { + const statusId = params.id; + const listStatus = await getStatusInvestasi(); + const dataPortofolio = await investasi_funGetPortofolioByStatusId({ + page: 1, + statusId: statusId, + }); + + return ( + <> + + + ); +} diff --git a/src/app/dev/investasi/main/portofolio/page.tsx b/src/app/dev/investasi/main/portofolio/page.tsx deleted file mode 100644 index 25df448f..00000000 --- a/src/app/dev/investasi/main/portofolio/page.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { - investasi_funGetAllInvestasiNonPublishByUserId, - investasi_funGetAllPublishByUserId, -} from "@/app_modules/investasi/_fun"; -import { Investasi_UiPortofolio } from "@/app_modules/investasi/_ui"; -import getStatusInvestasi from "@/app_modules/investasi/fun/master/get_status_investasi"; - -export default async function Page() { - const listStatus = await getStatusInvestasi(); - - const listDataPublish = await investasi_funGetAllPublishByUserId({ page: 1 }); - const listDataReview = await investasi_funGetAllInvestasiNonPublishByUserId({ - page: 1, - statusId: "2", - }); - const listDataDraft = await investasi_funGetAllInvestasiNonPublishByUserId({ - page: 1, - statusId: "3", - }); - const listDataReject = await investasi_funGetAllInvestasiNonPublishByUserId({ - page: 1, - statusId: "4", - }); - - return ( - <> - - - ); -} diff --git a/src/app/dev/investasi/detail_portofolio/draft/[id]/layout.tsx b/src/app/dev/investasi/x_detail_portofolio/draft/[id]/layout.tsx similarity index 100% rename from src/app/dev/investasi/detail_portofolio/draft/[id]/layout.tsx rename to src/app/dev/investasi/x_detail_portofolio/draft/[id]/layout.tsx diff --git a/src/app/dev/investasi/x_detail_portofolio/draft/[id]/page.tsx b/src/app/dev/investasi/x_detail_portofolio/draft/[id]/page.tsx new file mode 100644 index 00000000..ce6a3451 --- /dev/null +++ b/src/app/dev/investasi/x_detail_portofolio/draft/[id]/page.tsx @@ -0,0 +1,13 @@ +import { DetailDraftInvestasi } 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/[id]/layout.tsx b/src/app/dev/investasi/x_detail_portofolio/publish/[id]/layout.tsx similarity index 100% rename from src/app/dev/investasi/detail_portofolio/publish/[id]/layout.tsx rename to src/app/dev/investasi/x_detail_portofolio/publish/[id]/layout.tsx diff --git a/src/app/dev/investasi/x_detail_portofolio/publish/[id]/page.tsx b/src/app/dev/investasi/x_detail_portofolio/publish/[id]/page.tsx new file mode 100644 index 00000000..0fbb7990 --- /dev/null +++ b/src/app/dev/investasi/x_detail_portofolio/publish/[id]/page.tsx @@ -0,0 +1,11 @@ +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 ( + <> + + + ); +} diff --git a/src/app/dev/investasi/detail_portofolio/reject/[id]/layout.tsx b/src/app/dev/investasi/x_detail_portofolio/reject/[id]/layout.tsx similarity index 100% rename from src/app/dev/investasi/detail_portofolio/reject/[id]/layout.tsx rename to src/app/dev/investasi/x_detail_portofolio/reject/[id]/layout.tsx diff --git a/src/app/dev/investasi/detail_portofolio/reject/[id]/page.tsx b/src/app/dev/investasi/x_detail_portofolio/reject/[id]/page.tsx similarity index 100% rename from src/app/dev/investasi/detail_portofolio/reject/[id]/page.tsx rename to src/app/dev/investasi/x_detail_portofolio/reject/[id]/page.tsx diff --git a/src/app/dev/investasi/detail_portofolio/review/[id]/layout.tsx b/src/app/dev/investasi/x_detail_portofolio/review/[id]/layout.tsx similarity index 100% rename from src/app/dev/investasi/detail_portofolio/review/[id]/layout.tsx rename to src/app/dev/investasi/x_detail_portofolio/review/[id]/layout.tsx diff --git a/src/app/dev/investasi/detail_portofolio/review/[id]/page.tsx b/src/app/dev/investasi/x_detail_portofolio/review/[id]/page.tsx similarity index 100% rename from src/app/dev/investasi/detail_portofolio/review/[id]/page.tsx rename to src/app/dev/investasi/x_detail_portofolio/review/[id]/page.tsx diff --git a/src/app/lib/APIs.ts b/src/app/lib/APIs.ts index a1a591e1..ecd90c9b 100644 --- a/src/app/lib/APIs.ts +++ b/src/app/lib/APIs.ts @@ -9,6 +9,12 @@ const APIs = { size ? `https://wibu-storage.wibudev.com/api/files/${fileId}-size-${size}` : `https://wibu-storage.wibudev.com/api/files/${fileId}`, + + /** + * @type {string} + * @returns alamat API dari wibu storage + */ + GET_NO_PARAMS: "https://wibu-storage.wibudev.com/api/files/" }; export default APIs; diff --git a/src/app/lib/id-derectory.ts b/src/app/lib/id-derectory.ts index f94b253b..06ad0090 100644 --- a/src/app/lib/id-derectory.ts +++ b/src/app/lib/id-derectory.ts @@ -6,7 +6,8 @@ const DIRECTORY_ID = { map_image: "cm0yjqnxl000910njplqho07w", investasi_image: "cm0yjs35h000b10njb35o12h1", investasi_bukti_transfer: "cm0yjsflu000d10njrc3lnqho", - investasi_pdf: "cm1soio74003p38bjyciwf1oy", + investasi_prospektus: "cm1soio74003p38bjyciwf1oy", + investasi_dokumen: "cm21g2hxw004d10dpx8j16tt7", donasi_image: "cm0yk1coh000f10nj597a99kv", donasi_bukti_transfer: "cm0yk1pmh000h10njhi6m8b8t", job_image: "cm0ypp6zl0003kp7jf59zuvjy", diff --git a/src/app/lib/router_hipmi/router_investasi.ts b/src/app/lib/router_hipmi/router_investasi.ts index 92fe3d75..cdf42d2e 100644 --- a/src/app/lib/router_hipmi/router_investasi.ts +++ b/src/app/lib/router_hipmi/router_investasi.ts @@ -2,26 +2,75 @@ export const NEW_RouterInvestasi = { // API api_gambar: "/api/investasi/gambar/", - // Transaksi + // MAIN + /** + * + * @param param status id | 1: Publish, 2: Review, 3: Draft, 4: Reject + * @type string + */ + portofolio: ({ id }: { id: string }) => + `/dev/investasi/main/portofolio/${id}`, + + // TRANSAKSI pembelian: "/dev/investasi/transaksi/pembelian/", metode_pembayaran: "/dev/investasi/transaksi/metode-pembayaran/", invoice: "/dev/investasi/transaksi/invoice/", proses_transaksi: "/dev/investasi/transaksi/proses-transaksi/", - // stasus transaksi + // STATUS TRANSAKSI transaksi_gagal: "/dev/investasi/status-transaksi/gagal/", transaksi_berhasil: "/dev/investasi/status-transaksi/berhasil/", - // file view - file_view_prospektus: "/dev/investasi/file-view/prospektus/", - file_view_dokumen: "/dev/investasi/file-view/dokumen/", + // FILE VIEW + file_prospektus: ({ id }: { id: string }) => + `/dev/investasi/file-view/prospektus/${id}`, + + OLD_file_view_prospektus: "/dev/investasi/file-view/prospektus/", + OLD_file_view_dokumen: "/dev/investasi/file-view/dokumen/", + + // DETAIL + detail_portofolio: ({ id }: { id: string }) => + `/dev/investasi/detail/portofolio/${id}`, + detail_prospektus: ({ id }: { id: string }) => + `/dev/investasi/detail/prospektus/${id}`, + daftar_dokumen: ({ id }: { id: string }) => + `/dev/investasi/detail/daftar-dokumen/${id}`, + rekap_dokumen: ({ id }: { id: string }) => + `/dev/investasi/detail/rekap-dokumen/${id}`, - // detail detail_saham: "/dev/investasi/detail/saham/", detail_publish: "/dev/investasi/detail_portofolio/publish/", detail_review: "/dev/investasi/detail_portofolio/review/", detail_draft: "/dev/investasi/detail_portofolio/draft/", detail_reject: "/dev/investasi/detail_portofolio/reject/", + + // CREATE + /** + * @param id | investasiId + * @type string + */ + create_dokumen: ({ id }: { id: string }) => + `/dev/investasi/create/dokumen/${id}`, + + // EDIT + /** + * @param id | investasiId + * @type string + */ + edit_investasi: ({ id }: { id: string }) => `/dev/investasi/edit/${id}`, + + /** + * @param id | dokumenId + * @type string + */ + edit_dokumen: ({ id }: { id: string }) => `/dev/investasi/edit/dokumen/${id}`, + + /** + * @param id | investasiId + * @type string + */ + edit_prospektus: ({ id }: { id: string }) => + `/dev/investasi/edit/prospektus/${id}`, }; export const RouterInvestasi_OLD = { @@ -32,7 +81,7 @@ export const RouterInvestasi_OLD = { //INVESTASI main: "/dev/investasi/main", - create: "/dev/investasi/create", + create: "/dev/investasi/create/investasi", main_porto: "/dev/investasi/main/portofolio", main_investasi: "/dev/investasi/main/saham_saya", main_transaksi: "/dev/investasi/main/transaksi", diff --git a/src/app_modules/_global/component/box_information.tsx b/src/app_modules/_global/component/box_information.tsx index 71a91909..5f3f0643 100644 --- a/src/app_modules/_global/component/box_information.tsx +++ b/src/app_modules/_global/component/box_information.tsx @@ -12,15 +12,16 @@ export default function ComponentGlobal_BoxInformation({ }) { return ( <> - {isReport ? ( - + + {isReport ? ( - - ) : ( - + ) : ( *{" "} @@ -52,8 +44,10 @@ export default function ComponentGlobal_BoxInformation({ - - )} + )} + ); + + } diff --git a/src/app_modules/_global/component/comp_box_upload_image.tsx b/src/app_modules/_global/component/comp_box_upload_image.tsx index 50a7d84d..97b05beb 100644 --- a/src/app_modules/_global/component/comp_box_upload_image.tsx +++ b/src/app_modules/_global/component/comp_box_upload_image.tsx @@ -9,7 +9,7 @@ import { Box } from "@mantine/core"; Avatar +src={image ? image : APIs.GET({ fileId: })}/> * * @returns folllow like this */ @@ -22,7 +22,7 @@ export function ComponentGlobal_BoxUploadImage({ }) { return ( <> - + - // - // -
- + +
+
); @@ -74,6 +72,7 @@ export function ComponentGlobal_LoadImage({ opacity={isLoading ? 0.5 : 1} radius={radius ? radius : 0} alt="Image" + height={h ? h : 250} maw={maw ? maw : 200} miw={200} src={url} diff --git a/src/app_modules/_global/component/comp_load_image_custom.tsx b/src/app_modules/_global/component/comp_load_image_custom.tsx new file mode 100644 index 00000000..9cfd3b73 --- /dev/null +++ b/src/app_modules/_global/component/comp_load_image_custom.tsx @@ -0,0 +1,60 @@ +"use client"; + +import { APIs } from "@/app/lib"; +import { pathAssetImage } from "@/app/lib/path_asset_image"; +import { Center, Image, Skeleton } from "@mantine/core"; +import { useShallowEffect } from "@mantine/hooks"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; + +export function ComponentGlobal_LoadImageCustom({ + fileId, + height, +}: { + fileId: string; + height: number; +}) { + const [isImage, setIsImage] = useState(null); + const url = APIs.GET({ fileId: fileId }); + + useShallowEffect(() => { + onLoadImage(); + }, []); + + async function onLoadImage() { + try { + const res = await fetch(url); + if (res.ok) { + return setIsImage(true); + } + setIsImage(false); + } catch (error) { + console.log(error); + } + } + + if (isImage === null) + return ; + + return ( + <> + {isImage ? ( + No Image + ) : ( +
+ No Image +
+ )} + + ); +} diff --git a/src/app_modules/_global/component/comp_load_image_landscape.tsx b/src/app_modules/_global/component/comp_load_image_landscape.tsx index 1a9c4257..0fc435b3 100644 --- a/src/app_modules/_global/component/comp_load_image_landscape.tsx +++ b/src/app_modules/_global/component/comp_load_image_landscape.tsx @@ -39,7 +39,7 @@ export function ComponentGlobal_LoadImageLandscape({ if (!isImage) return ( <> -
+
No Image
{ setLoading(true); router.push(RouterImagePreview.main({ id: fileId }), { diff --git a/src/app_modules/_global/component/index.ts b/src/app_modules/_global/component/index.ts index 3cab61b4..90aaa047 100644 --- a/src/app_modules/_global/component/index.ts +++ b/src/app_modules/_global/component/index.ts @@ -5,6 +5,7 @@ import { ComponentGlobal_BoxUploadImage } from "./comp_box_upload_image"; import { ComponentGlobal_CardStyles } from "./comp_card_box_and_background"; import { ComponentGlobal_LoaderAvatar } from "./comp_load_avatar"; import { ComponentGlobal_LoadImage } from "./comp_load_image"; +import { ComponentGlobal_LoadImageCustom } from "./comp_load_image_custom"; import { ComponentGlobal_LoadImageLandscape } from "./comp_load_image_landscape"; import ComponentGlobal_CardLoadingOverlay from "./comp_loading_card"; import { ComponentGlobal_NotUserLoadImage } from "./comp_not_user_load_image"; @@ -27,3 +28,4 @@ export { ComponentGlobal_LoaderAvatar }; export { ComponentGlobal_AvatarAndUsername }; export { ComponentGlobal_NotUserLoadImage }; export { ComponentGlobal_LoadImageLandscape }; +export { ComponentGlobal_LoadImageCustom }; diff --git a/src/app_modules/_global/fun/delete/fun_delete_file_by_id.tsx b/src/app_modules/_global/fun/delete/fun_delete_file_by_id.tsx new file mode 100644 index 00000000..a31df82d --- /dev/null +++ b/src/app_modules/_global/fun/delete/fun_delete_file_by_id.tsx @@ -0,0 +1,24 @@ +export async function funGlobal_DeleteFileById({ fileId }: { fileId: string }) { + try { + const res = await fetch( + `https://wibu-storage.wibudev.com/api/files/${fileId}/delete`, + { + method: "DELETE", + headers: { + Authorization: `Bearer ${process.env.WS_APIKEY}`, + }, + } + ); + + if (res.ok) { + const hasil = await res.json(); + return { success: true }; + } else { + const errorText = await res.json(); + return { success: false }; + } + } catch (error) { + return { success: false }; + console.error("Upload error:", error); + } +} diff --git a/src/app_modules/_global/fun/index.ts b/src/app_modules/_global/fun/index.ts index e85ec448..809afd9b 100644 --- a/src/app_modules/_global/fun/index.ts +++ b/src/app_modules/_global/fun/index.ts @@ -1,3 +1,5 @@ +import { funGlobal_DeleteFileById } from "./delete/fun_delete_file_by_id"; import { funGlobal_UploadToStorage } from "./upload/fun_upload_to_storage"; export { funGlobal_UploadToStorage }; +export { funGlobal_DeleteFileById }; diff --git a/src/app_modules/_global/ui/index.ts b/src/app_modules/_global/ui/index.ts index 73027096..6d4ba8d2 100644 --- a/src/app_modules/_global/ui/index.ts +++ b/src/app_modules/_global/ui/index.ts @@ -1,4 +1,5 @@ import UIGlobal_Drawer from "./ui_drawer"; +import UIGlobal_DrawerCustom from "./ui_drawer_custom"; import UIGlobal_LayoutHeaderTamplate from "./ui_header_tamplate"; import { UIGlobal_ImagePreview } from "./ui_image_preview"; import UIGlobal_LayoutDefault from "./ui_layout_default"; @@ -15,3 +16,4 @@ export { UIGlobal_SplashScreen }; export { UIGlobal_ImagePreview }; export { UIGlobal_NotUserImagePreview }; export { UIGlobal_LayoutDefault }; +export { UIGlobal_DrawerCustom }; diff --git a/src/app_modules/_global/ui/ui_drawer_custom.tsx b/src/app_modules/_global/ui/ui_drawer_custom.tsx new file mode 100644 index 00000000..034670b2 --- /dev/null +++ b/src/app_modules/_global/ui/ui_drawer_custom.tsx @@ -0,0 +1,72 @@ +"use client"; + +import { AccentColor } from "@/app_modules/_global/color"; +import { + ActionIcon, + Box, + Drawer, + Group, + SimpleGrid, + Stack, +} from "@mantine/core"; +import { IconX } from "@tabler/icons-react"; +import React from "react"; + +interface MODEL_DRAWER { + id: string; + name: string; + icon: string; + path: string; +} +export default function UIGlobal_DrawerCustom({ + opened, + close, + component, +}: { + opened: boolean; + close: () => void; + component: React.ReactNode; +}) { + return ( + <> + close()} + position={"bottom"} + size={"auto"} + withCloseButton={false} + styles={{ + content: { + padding: 0, + position: "absolute", + margin: "auto", + backgroundColor: "transparent", + left: 0, + right: 0, + width: 500, + }, + body: { + backgroundColor: AccentColor.darkblue, + borderTop: `2px solid ${AccentColor.blue}`, + borderRight: `1px solid ${AccentColor.blue}`, + borderLeft: `1px solid ${AccentColor.blue}`, + borderRadius: "20px 20px 0px 0px", + color: "white", + paddingBottom: "5%", + }, + }} + > + + + + + + + + {component} + + + + + ); +} diff --git a/src/app_modules/_global/ui/ui_image_preview.tsx b/src/app_modules/_global/ui/ui_image_preview.tsx index 798b7821..9f37411a 100644 --- a/src/app_modules/_global/ui/ui_image_preview.tsx +++ b/src/app_modules/_global/ui/ui_image_preview.tsx @@ -9,6 +9,7 @@ import { Container, Image, rem, + ScrollArea, Skeleton, Text, Title, @@ -20,10 +21,12 @@ import { useState } from "react"; import { MainColor } from "../color"; import UIGlobal_LayoutHeaderTamplate from "./ui_header_tamplate"; import { UIHeader } from "./ui_layout_tamplate"; +import ComponentGlobal_Loader from "../component/loader"; export function UIGlobal_ImagePreview({ fileId }: { fileId: string }) { const router = useRouter(); const [isImage, setIsImage] = useState(null); + const [isLoading, setIsLoading] = useState(false); const url = APIs.GET({ fileId: fileId }); @@ -63,23 +66,31 @@ export function UIGlobal_ImagePreview({ fileId }: { fileId: string }) { hideButtonLeft customButtonRight={ router.back()} + onClick={() => { + router.back(), setIsLoading(true); + }} variant="transparent" > - + {isLoading ? ( + + ) : ( + + )} } /> } /> - + {isImage === null ? ( ) : isImage ? ( -
- Image -
+ +
+ Image +
+
) : ( + + + ); +} diff --git a/src/app_modules/investasi/_component/button/comp_button_update_investasi.tsx b/src/app_modules/investasi/_component/button/comp_button_update_investasi.tsx new file mode 100644 index 00000000..5556c207 --- /dev/null +++ b/src/app_modules/investasi/_component/button/comp_button_update_investasi.tsx @@ -0,0 +1,90 @@ +import { MainColor } from "@/app_modules/_global/color"; +import { Button, Stack } from "@mantine/core"; +import { MODEL_INVESTASI } from "../../_lib/interface"; +import { + ComponentGlobal_NotifikasiBerhasil, + ComponentGlobal_NotifikasiPeringatan, +} from "@/app_modules/_global/notif_global"; +import { DIRECTORY_ID } from "@/app/lib"; +import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun"; +import _ from "lodash"; +import { investasi_funUpdateInvestasi } from "../../_fun"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; + +export function Investasi_ComponentButtonUpdateDataInvestasi({ + data, + file, + totalLembar, +}: { + data: MODEL_INVESTASI; + file: File; + totalLembar: string; +}) { + const router = useRouter(); + const [isLoading, setIsLoading] = useState(false); + + async function onUpdate() { + if (totalLembar === "0") + return ComponentGlobal_NotifikasiPeringatan("Total lembar kosong"); + + if (file !== null) { + if (_.values(data).includes("")) + return ComponentGlobal_NotifikasiPeringatan("Lengkapi data"); + + const uploadImage = await funGlobal_UploadToStorage({ + file: file as any, + dirId: DIRECTORY_ID.investasi_image, + }); + if (!uploadImage.success) { + setIsLoading(false); + return ComponentGlobal_NotifikasiPeringatan("Gagal upload file gambar"); + } + + const updtWithImage = await investasi_funUpdateInvestasi({ + data: data, + imageId: uploadImage.data.id, + totalLembar: totalLembar, + }); + + if (updtWithImage.status === 200) { + setIsLoading(false); + router.back(); + return ComponentGlobal_NotifikasiBerhasil(updtWithImage.message); + } else { + setIsLoading(false); + return ComponentGlobal_NotifikasiPeringatan(updtWithImage.message); + } + } else { + const updtNoImage = await investasi_funUpdateInvestasi({ + data: data, + totalLembar: totalLembar, + }); + + if (updtNoImage.status === 200) { + setIsLoading(false); + router.back(); + return ComponentGlobal_NotifikasiBerhasil(updtNoImage.message); + } else { + setIsLoading(false); + return ComponentGlobal_NotifikasiPeringatan(updtNoImage.message); + } + } + } + return ( + + + + ); +} diff --git a/src/app_modules/investasi/_component/detail/comp_box_daftar_berita.tsx b/src/app_modules/investasi/_component/detail/comp_box_daftar_berita.tsx index ed186c0f..4d8cd7db 100644 --- a/src/app_modules/investasi/_component/detail/comp_box_daftar_berita.tsx +++ b/src/app_modules/investasi/_component/detail/comp_box_daftar_berita.tsx @@ -1,4 +1,4 @@ -import { RouterInvestasi_OLD } from "@/app/lib/router_hipmi/router_investasi"; +import { NEW_RouterInvestasi } 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"; @@ -23,18 +23,17 @@ export function Investasi_ComponentBoxDaftarBerita({ borderRadius: "10px", color: "white", }} + onClick={() => { + setLoading(true); + router.push( + NEW_RouterInvestasi.detail_prospektus({ id: investasiId }), + { scroll: false } + ); + }} > Berita - { - setLoading(true); - router.push(RouterInvestasi_OLD.daftar_berita + investasiId); - }} - > + {isLoading ? ( ) : ( diff --git a/src/app_modules/investasi/_component/detail/comp_box_daftar_dokumen.tsx b/src/app_modules/investasi/_component/detail/comp_box_daftar_dokumen.tsx index 417a07b6..a422ac7c 100644 --- a/src/app_modules/investasi/_component/detail/comp_box_daftar_dokumen.tsx +++ b/src/app_modules/investasi/_component/detail/comp_box_daftar_dokumen.tsx @@ -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 { AccentColor } from "@/app_modules/_global/color"; import { ActionIcon, Flex, Loader, Paper, Text } from "@mantine/core"; import { IconFileDescription } from "@tabler/icons-react"; @@ -23,18 +26,17 @@ export function Investasi_ComponentBoxDaftarDokumen({ borderRadius: "10px", color: "white", }} + onClick={() => { + setLoading(true); + router.push(NEW_RouterInvestasi.daftar_dokumen({ id: investasiId }), { + scroll: false, + }); + // router.push(RouterInvestasi_OLD.detail_dokumen + investasiId, { scroll: false }); + }} > Dokumen - { - setLoading(true); - router.push(RouterInvestasi_OLD.detail_dokumen + investasiId); - }} - > + {isLoading ? ( ) : ( diff --git a/src/app_modules/investasi/_component/detail/comp_box_prospektus.tsx b/src/app_modules/investasi/_component/detail/comp_box_prospektus.tsx index a8a9a04a..1af7d87e 100644 --- a/src/app_modules/investasi/_component/detail/comp_box_prospektus.tsx +++ b/src/app_modules/investasi/_component/detail/comp_box_prospektus.tsx @@ -1,4 +1,4 @@ -import { RouterInvestasi_OLD } from "@/app/lib/router_hipmi/router_investasi"; +import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; import { AccentColor } from "@/app_modules/_global/color"; import { ActionIcon, Flex, Loader, Paper, Text } from "@mantine/core"; import { IconBookDownload } from "@tabler/icons-react"; @@ -6,9 +6,9 @@ import { useRouter } from "next/navigation"; import { useState } from "react"; export function Investasi_ComponentBoxProspektus({ - investasiId, + prospektusFileId, }: { - investasiId: string; + prospektusFileId: string; }) { const router = useRouter(); const [isLoading, setLoading] = useState(false); @@ -22,20 +22,18 @@ export function Investasi_ComponentBoxProspektus({ border: `2px solid ${AccentColor.softblue}`, borderRadius: "10px", color: "white", - + }} + onClick={() => { + setLoading(true); + router.push( + NEW_RouterInvestasi.file_prospektus({ id: prospektusFileId }), + { scroll: false } + ); }} > Prospektus - { - setLoading(true); - router.push(RouterInvestasi_OLD.detail_prospektus + investasiId); - }} - > + {isLoading ? ( ) : ( diff --git a/src/app_modules/investasi/_component/detail/comp_card_daftar_document.tsx b/src/app_modules/investasi/_component/detail/comp_card_daftar_document.tsx new file mode 100644 index 00000000..5bfdab9e --- /dev/null +++ b/src/app_modules/investasi/_component/detail/comp_card_daftar_document.tsx @@ -0,0 +1,37 @@ +import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; +import { + ComponentGlobal_CardLoadingOverlay, + ComponentGlobal_CardStyles, +} from "@/app_modules/_global/component"; +import { Stack, Text } from "@mantine/core"; + +import { useRouter } from "next/navigation"; +import { useState } from "react"; +import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface"; + +export function Investasi_ComponentCardDaftarDocument({ + data, +}: { + data: MODEL_INVESTASI_DOKUMEN; +}) { + const router = useRouter(); + const [visible, setVisible] = useState(false); + return ( + + { + router.push( + NEW_RouterInvestasi.file_prospektus({ id: data.fileId }), + { scroll: false } + ); + setVisible(true); + }} + > + {data.title} + + {visible && } + + ); +} diff --git a/src/app_modules/investasi/_component/detail/comp_card_rekap_document.tsx b/src/app_modules/investasi/_component/detail/comp_card_rekap_document.tsx new file mode 100644 index 00000000..5e62a0f2 --- /dev/null +++ b/src/app_modules/investasi/_component/detail/comp_card_rekap_document.tsx @@ -0,0 +1,181 @@ +import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; +import { + ComponentGlobal_CardLoadingOverlay, + ComponentGlobal_CardStyles, +} from "@/app_modules/_global/component"; +import { + UIGlobal_DrawerCustom, + UIGlobal_Modal, +} from "@/app_modules/_global/ui"; +import { + ActionIcon, + Button, + Grid, + Group, + SimpleGrid, + Stack, + Text, +} from "@mantine/core"; +import { IconDots, IconEdit, IconTrash } from "@tabler/icons-react"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; +import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface"; +import ComponentGlobal_Loader from "@/app_modules/_global/component/loader"; +import { + investasi_funDeleteDokumenById, + investasi_funGetAllDocumentById, +} from "../../_fun"; +import { funGlobal_DeleteFileById } from "@/app_modules/_global/fun"; +import { + ComponentGlobal_NotifikasiBerhasil, + ComponentGlobal_NotifikasiPeringatan, +} from "@/app_modules/_global/notif_global"; + +export function Investasi_ComponentCardRekapDocument({ + data, + onSetData, +}: { + data: MODEL_INVESTASI_DOKUMEN; + onSetData: (val: any) => any[]; +}) { + const router = useRouter(); + const [openDrawer, setOpenDrawer] = useState(false); + const [isLoadingEdit, setIsLoadingEdit] = useState(false); + + const [openModal, setOpenModal] = useState(false); + const [isLoadingDelete, setIsLoadingDelete] = useState(false); + const [visible, setVisible] = useState(false); + + async function onDelete() { + try { + setIsLoadingDelete(true); + const deleteFileFromStorage = await funGlobal_DeleteFileById({ + fileId: data.fileId, + }); + + if (!deleteFileFromStorage.success) { + ComponentGlobal_NotifikasiPeringatan("Gagal hapus file lama"); + } + + const deleteFromDB = await investasi_funDeleteDokumenById({ + dokumenId: data.id, + }); + + if (deleteFromDB.status !== 200) { + ComponentGlobal_NotifikasiPeringatan(deleteFromDB.message); + } + ComponentGlobal_NotifikasiBerhasil(deleteFromDB.message); + setOpenModal(false); + + const loadData = await investasi_funGetAllDocumentById({ + investasiId: data.investasiId, + page: 1, + }); + + onSetData(loadData); + } catch (error) { + console.log(error); + } finally { + setIsLoadingDelete(false); + } + } + + return ( + <> + + + { + router.push( + NEW_RouterInvestasi.file_prospektus({ id: data.fileId }), + { scroll: false } + ); + setVisible(true); + }} + > + + {data.title} + + + + setOpenDrawer(true)}> + + + + + + + + {visible && } + + + setOpenDrawer(false)} + component={ + + + { + setIsLoadingEdit(true); + router.push( + NEW_RouterInvestasi.edit_dokumen({ id: data.id }), + { scroll: false } + ); + }} + > + {isLoadingEdit ? : } + + + Edit Dokumen + + + + + { + setOpenModal(true); + setOpenDrawer(false); + }} + > + + + + Hapus Dokumen + + + + } + /> + + setOpenModal(false)} + title={"Anda yakin akan menghapus dokumen ini ?"} + buttonKiri={ + + } + buttonKanan={ + + } + /> + + ); +} diff --git a/src/app_modules/investasi/_component/detail/comp_detail_data_non_publish.tsx b/src/app_modules/investasi/_component/detail/comp_detail_data_non_publish.tsx new file mode 100644 index 00000000..a556dc18 --- /dev/null +++ b/src/app_modules/investasi/_component/detail/comp_detail_data_non_publish.tsx @@ -0,0 +1,106 @@ +import { + ComponentGlobal_CardStyles, + ComponentGlobal_LoadImageLandscape, +} from "@/app_modules/_global/component"; +import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface"; +import { Center, SimpleGrid, Stack, Text, Title } from "@mantine/core"; +import _ from "lodash"; +import { Investasi_ComponentBoxDaftarDokumen } from "./comp_box_daftar_dokumen"; +import { Investasi_ComponentBoxProspektus } from "./comp_box_prospektus"; +import { Investasi_ComponentTitleAndValueInDetail } from "./comp_title_and_value_in_detail"; + +export function Investasi_ComponentDetailDataNonPublish({ + data, +}: { + data: MODEL_INVESTASI; +}) { + return ( + <> + + + + + {/* Title dan Persentase */} +
+ + {_.startCase(data.title)} + +
+ + {/* Rincian Data */} + + + + Rp.{" "} + {new Intl.NumberFormat("id-ID", { + maximumSignificantDigits: 20, + }).format(+data.targetDana)}{" "} + + } + /> + + + Rp.{" "} + {new Intl.NumberFormat("id-ID", { + maximumSignificantDigits: 10, + }).format(+data.hargaLembar)} + + } + /> + + Return Of Invesment (RoI)} + value={{data.roi} %} + /> + + + {new Intl.NumberFormat("id-ID", { + maximumSignificantDigits: 10, + }).format(+data.totalLembar)}{" "} + lembar + + } + /> + + {data.MasterPembagianDeviden.name} Bulan } + /> + {data.MasterPeriodeDeviden.name}} + /> + {data.MasterPencarianInvestor.name} Hari } + /> + + + {/* List Box */} + + + + +
+
+ + ); +} diff --git a/src/app_modules/investasi/_component/detail/comp_title_and_value_in_detail.tsx b/src/app_modules/investasi/_component/detail/comp_title_and_value_in_detail.tsx new file mode 100644 index 00000000..3f8ca614 --- /dev/null +++ b/src/app_modules/investasi/_component/detail/comp_title_and_value_in_detail.tsx @@ -0,0 +1,23 @@ +import { Grid, Text } from "@mantine/core"; +import { data } from "autoprefixer"; +import React from "react"; + +export function Investasi_ComponentTitleAndValueInDetail({ + title, + value, +}: { + title: string | React.ReactNode; + value: React.ReactNode; +}) { + return ( + <> + + + {title} + + : + {value} + + + ); +} diff --git a/src/app_modules/investasi/_component/detail/saham_saya/comp_detail_data.tsx b/src/app_modules/investasi/_component/detail/saham_saya/comp_detail_data.tsx index 2d3a547d..1a9423ad 100644 --- a/src/app_modules/investasi/_component/detail/saham_saya/comp_detail_data.tsx +++ b/src/app_modules/investasi/_component/detail/saham_saya/comp_detail_data.tsx @@ -1,5 +1,9 @@ import { RouterInvestasi_OLD } from "@/app/lib/router_hipmi/router_investasi"; -import { ComponentGlobal_AvatarAndUsername } from "@/app_modules/_global/component"; +import { + ComponentGlobal_AvatarAndUsername, + ComponentGlobal_CardStyles, + ComponentGlobal_LoadImageLandscape, +} from "@/app_modules/_global/component"; import { MODEL_INVOICE_INVESTASI } from "@/app_modules/investasi/_lib/interface"; import { AspectRatio, @@ -23,20 +27,14 @@ export function Investasi_ComponentBoxDetailData({ }) { return ( <> - + - - - - + + + + {data?.Investasi.title} @@ -122,7 +120,7 @@ export function Investasi_ComponentBoxDetailData({ ]} > - + ); } diff --git a/src/app_modules/investasi/_component/index.ts b/src/app_modules/investasi/_component/index.ts index 1ad29dcc..ef436387 100644 --- a/src/app_modules/investasi/_component/index.ts +++ b/src/app_modules/investasi/_component/index.ts @@ -12,6 +12,12 @@ import { Investasi_ComponentFooterMain } from "./main/comp_footer_main"; import { Investasi_ComponentCardPortofolioPublish } from "./main/comp_card_portofolio_publish"; import { Investasi_ComponentButtonUpdateBeranda } from "./main/comp_update_beranda"; import { Investasi_ComponentCardPortofolio_NotPublish } from "./main/comp_card_portofolio_not_publish"; +import { Investasi_ComponentButtonCreateNewInvestasi } from "./button/comp_button_create_new_investasi"; +import { Investasi_ComponentTitleAndValueInDetail } from "./detail/comp_title_and_value_in_detail"; +import { Investasi_ComponentDetailDataNonPublish } from "./detail/comp_detail_data_non_publish"; +import { Investasi_ComponentButtonUpdateDataInvestasi } from "./button/comp_button_update_investasi"; +import { Investasi_ComponentCardRekapDocument } from "./detail/comp_card_rekap_document"; +import { Investasi_ComponentCardDaftarDocument } from "./detail/comp_card_daftar_document"; export { Investasi_ComponentFooterMain }; export { Investasi_ComponentCardBeranda }; @@ -27,3 +33,9 @@ export { Investasi_ComponentBoxProgress }; export { Investasi_ComponentBoxDetailData }; export { Investasi_ComponentCardPortofolioPublish }; export { Investasi_ComponentCardPortofolio_NotPublish }; +export { Investasi_ComponentButtonCreateNewInvestasi }; +export { Investasi_ComponentTitleAndValueInDetail }; +export { Investasi_ComponentDetailDataNonPublish }; +export { Investasi_ComponentButtonUpdateDataInvestasi }; +export { Investasi_ComponentCardRekapDocument }; +export { Investasi_ComponentCardDaftarDocument }; diff --git a/src/app_modules/investasi/_component/main/comp_card_beranda.tsx b/src/app_modules/investasi/_component/main/comp_card_beranda.tsx index 0759ee28..841b6e32 100644 --- a/src/app_modules/investasi/_component/main/comp_card_beranda.tsx +++ b/src/app_modules/investasi/_component/main/comp_card_beranda.tsx @@ -15,16 +15,20 @@ import { Group, Image, Text, + Grid, } from "@mantine/core"; import { IconCircleCheck, IconXboxX } from "@tabler/icons-react"; import moment from "moment"; import { MODEL_INVESTASI } from "../../_lib/interface"; import { useRouter } from "next/navigation"; -import { useState } from "react"; +import { Component, useState } from "react"; import { ComponentGlobal_CardLoadingOverlay, ComponentGlobal_CardStyles, + ComponentGlobal_LoadImage, + ComponentGlobal_LoadImageCustom, + ComponentGlobal_LoadImageLandscape, } from "@/app_modules/_global/component"; export function Investasi_ComponentCardBeranda({ @@ -45,109 +49,89 @@ export function Investasi_ComponentCardBeranda({ router.push(RouterInvestasi_OLD.detail + `${data?.id}`); }} > - - - - {data.imagesId ? ( - Foto + + + + + + + {data?.title} + + - ) : ( - - )} - - - - - - - - {data?.title} - - - - - - - - {data?.progress === "100" ? ( - - - - Selesai - - - ) : ( - - {+data?.MasterPencarianInvestor.name - - moment(new Date()).diff(new Date(data?.countDown), "days") <= - 0 ? ( - - - - Waktu Habis - - - ) : ( - - Sisa waktu: - - {Number(data?.MasterPencarianInvestor.name) - + + {data?.progress === "100" ? ( + + + + Selesai + + + ) : ( + + {+data?.MasterPencarianInvestor.name - moment(new Date()).diff( new Date(data?.countDown), "days" - )} - - Hari - - )} - - )} - - + ) <= + 0 ? ( + + + + Waktu Habis + + + ) : ( + + Sisa waktu: + + {Number(data?.MasterPencarianInvestor.name) - + moment(new Date()).diff( + new Date(data?.countDown), + "days" + )} + + Hari + + )} +
+ )} + + + + + + {visible ? : ""} - - {/* */} ); } diff --git a/src/app_modules/investasi/_component/main/comp_card_portofolio_not_publish.tsx b/src/app_modules/investasi/_component/main/comp_card_portofolio_not_publish.tsx index 5db92ecc..0ac0ec76 100644 --- a/src/app_modules/investasi/_component/main/comp_card_portofolio_not_publish.tsx +++ b/src/app_modules/investasi/_component/main/comp_card_portofolio_not_publish.tsx @@ -1,11 +1,13 @@ -import { RouterInvestasi_OLD } from "@/app/lib/router_hipmi/router_investasi"; -import { Grid, Stack, AspectRatio, Paper, Text, Image } from "@mantine/core"; +import { + ComponentGlobal_CardLoadingOverlay, + ComponentGlobal_CardStyles, + ComponentGlobal_LoadImageCustom, +} from "@/app_modules/_global/component"; +import { Grid, Stack, Text } from "@mantine/core"; import _ from "lodash"; -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 { MODEL_INVESTASI } from "../../_lib/interface"; export function Investasi_ComponentCardPortofolio_NotPublish({ data, @@ -16,12 +18,13 @@ export function Investasi_ComponentCardPortofolio_NotPublish({ }) { const router = useRouter(); const [visible, setVisible] = useState(false); - return ( <> - {JSON.stringify(data, null, 2)} */} + + { - router.push(path + data?.id); + router.push(path, { scroll: false }); setVisible(true); }} > @@ -43,18 +46,14 @@ export function Investasi_ComponentCardPortofolio_NotPublish({ - - - - - + {visible && } - + ); } diff --git a/src/app_modules/investasi/_component/main/comp_card_portofolio_publish.tsx b/src/app_modules/investasi/_component/main/comp_card_portofolio_publish.tsx index 2f3d20ee..2211b50e 100644 --- a/src/app_modules/investasi/_component/main/comp_card_portofolio_publish.tsx +++ b/src/app_modules/investasi/_component/main/comp_card_portofolio_publish.tsx @@ -34,7 +34,7 @@ export function Investasi_ComponentCardPortofolioPublish({ { - router.push(NEW_RouterInvestasi.detail_publish + data?.id); + router.push(NEW_RouterInvestasi.detail_portofolio({ id: data?.id })); setVisible(true); }} > diff --git a/src/app_modules/investasi/_component/main/comp_footer_main.tsx b/src/app_modules/investasi/_component/main/comp_footer_main.tsx index c9879ca6..98559873 100644 --- a/src/app_modules/investasi/_component/main/comp_footer_main.tsx +++ b/src/app_modules/investasi/_component/main/comp_footer_main.tsx @@ -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 { MainColor } from "@/app_modules/_global/color/color_pallet"; import { SimpleGrid, Stack, ActionIcon, Text } from "@mantine/core"; import { @@ -21,7 +24,7 @@ const listFooter = [ { id: 2, name: "Portofolio", - route: RouterInvestasi_OLD.main_porto, + route: NEW_RouterInvestasi.portofolio({ id: "1" }), icon: , }, { @@ -45,14 +48,14 @@ export function Investasi_ComponentFooterMain() { return ( <> - {listFooter.map((e, i) => ( + {listFooter.map((e: any, i) => ( { - router.push(e.route); + router.push(e.route, { scroll: false }); setHotMenu(i); }} > diff --git a/src/app_modules/investasi/_fun/create/fun_create_document.tsx b/src/app_modules/investasi/_fun/create/fun_create_document.tsx new file mode 100644 index 00000000..7fc84e4c --- /dev/null +++ b/src/app_modules/investasi/_fun/create/fun_create_document.tsx @@ -0,0 +1,28 @@ +"use server"; + +import { prisma } from "@/app/lib"; +import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; +import { revalidatePath } from "next/cache"; + +type ICreateDocument = { + investasiId: string; + title: string; + fileId: string; +}; +export async function investasi_funCreateDocument({ + data, +}: { + data: ICreateDocument; +}) { + const create = await prisma.dokumenInvestasi.create({ + data: { + investasiId: data.investasiId, + title: data.title, + fileId: data.fileId, + }, + }); + + if (!create) return { status: 400, message: "Gagal membuat dokumen" }; + revalidatePath(NEW_RouterInvestasi.rekap_dokumen({ id: data.investasiId })); + return { status: 201, message: "Berhasil membuat dokumen" }; +} diff --git a/src/app_modules/investasi/_fun/create/fun_create_new_investasi.tsx b/src/app_modules/investasi/_fun/create/fun_create_new_investasi.tsx new file mode 100644 index 00000000..20559163 --- /dev/null +++ b/src/app_modules/investasi/_fun/create/fun_create_new_investasi.tsx @@ -0,0 +1,62 @@ +"use server"; + +import { prisma } from "@/app/lib"; +import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; +import { funGetUserIdByToken } from "@/app_modules/_global/fun/get"; +import _ from "lodash"; +import { revalidatePath } from "next/cache"; +import { MODEL_INVESTASI } from "../../_lib/interface"; + +export async function investasi_funCreateNewInvestasi({ + data, + fileImageId, + filePdfId, +}: { + data: MODEL_INVESTASI; + fileImageId: string; + filePdfId: string; +}) { + const userLoginId = await funGetUserIdByToken(); + try { + const createNew = await prisma.investasi.create({ + data: { + authorId: userLoginId, + title: _.startCase(data.title), + targetDana: data.targetDana.toString(), + hargaLembar: data.hargaLembar.toString(), + totalLembar: data.totalLembar.toString(), + sisaLembar: data.totalLembar.toString(), + roi: data.roi.toString(), + masterPembagianDevidenId: data.masterPembagianDevidenId, + masterPeriodeDevidenId: data.masterPeriodeDevidenId, + masterPencarianInvestorId: data.masterPencarianInvestorId, + masterStatusInvestasiId: "2", + imageId: fileImageId, + prospektusFileId: filePdfId, + }, + select: { + id: true, + title: true, + authorId: true, + MasterStatusInvestasi: { + select: { + name: true, + }, + }, + }, + }); + + if (!createNew) return { status: 400, message: "Gagal Membuat Investasi" }; + revalidatePath(NEW_RouterInvestasi.portofolio({id: "2"})); + + return { + status: 201, + data: createNew, + message: "Berhasil Membuat Investasi", + }; + } catch (error) { + console.log(error); + + return { status: 400, message: "Error Message" }; + } +} diff --git a/src/app_modules/investasi/_fun/delete/fun_delete_dokumen.tsx b/src/app_modules/investasi/_fun/delete/fun_delete_dokumen.tsx new file mode 100644 index 00000000..360c09fe --- /dev/null +++ b/src/app_modules/investasi/_fun/delete/fun_delete_dokumen.tsx @@ -0,0 +1,21 @@ +"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_funDeleteDokumenById({ + dokumenId, +}: { + dokumenId: string; +}) { + const del = await prisma.dokumenInvestasi.delete({ + where: { + id: dokumenId, + }, + }); + + if (!del) return { status: 400, message: "Gagal hapus data" }; + revalidatePath(NEW_RouterInvestasi.rekap_dokumen({ id: del.investasiId as any })); + return { status: 200, message: "Berhasil hapus data" }; +} diff --git a/src/app_modules/investasi/_fun/edit/fun_edit_document.tsx b/src/app_modules/investasi/_fun/edit/fun_edit_document.tsx new file mode 100644 index 00000000..56332497 --- /dev/null +++ b/src/app_modules/investasi/_fun/edit/fun_edit_document.tsx @@ -0,0 +1,67 @@ +"use server"; + +import { prisma } from "@/app/lib"; +import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface"; +import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; +import { revalidatePath } from "next/cache"; + +export async function investasi_funUpdateDocument({ + data, + fileId, +}: { + data: MODEL_INVESTASI_DOKUMEN; + fileId?: string; +}) { + try { + fileId !== undefined + ? await prisma.dokumenInvestasi.update({ + where: { + id: data.id, + }, + data: { + title: data.title, + fileId: fileId, + }, + }) + : await prisma.dokumenInvestasi.update({ + where: { + id: data.id, + }, + data: { + title: data.title, + }, + }); + } catch (error) { + console.log(error); + } finally { + revalidatePath(NEW_RouterInvestasi.rekap_dokumen({ id: data.investasiId })); + return { status: 200, message: "Berhasil Update" }; + } + + // if (fileId !== undefined) { + // const updt = await prisma.dokumenInvestasi.update({ + // where: { + // id: data.id, + // }, + // data: { + // title: data.title, + // fileId: fileId, + // }, + // }); + // } else { + // const updt = await prisma.dokumenInvestasi.update({ + // where: { + // id: data.id, + // }, + // data: { + // title: data.title, + // }, + // }); + // } + // if (!updt) return { status: 400, message: "Gagal Update" }; + // revalidatePath(NEW_RouterInvestasi.rekap_dokumen({ id: data.investasiId })); + // return { + // status: 200, + // message: "Berhasil Update", + // }; +} diff --git a/src/app_modules/investasi/_fun/edit/fun_edit_investasi.tsx b/src/app_modules/investasi/_fun/edit/fun_edit_investasi.tsx new file mode 100644 index 00000000..580f143f --- /dev/null +++ b/src/app_modules/investasi/_fun/edit/fun_edit_investasi.tsx @@ -0,0 +1,67 @@ +"use server"; + +import { prisma } from "@/app/lib"; +import { MODEL_INVESTASI } from "../../_lib/interface"; +import _ from "lodash"; +import { revalidatePath } from "next/cache"; +import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; + +export async function investasi_funUpdateInvestasi({ + data, + imageId, + totalLembar, +}: { + data: MODEL_INVESTASI; + imageId?: string; + totalLembar: string; +}) { + // console.log(data); + // console.log(imageId); + // console.log(totalLembar); + + if (imageId !== undefined) { + const updtWithImage = await prisma.investasi.update({ + where: { + id: data.id, + }, + data: { + title: _.startCase(data.title), + targetDana: data.targetDana, + hargaLembar: data.hargaLembar, + totalLembar: totalLembar, + sisaLembar: totalLembar, + roi: data.roi, + masterPembagianDevidenId: data.masterPembagianDevidenId, + masterPeriodeDevidenId: data.masterPeriodeDevidenId, + masterPencarianInvestorId: data.masterPencarianInvestorId, + imageId: imageId, + }, + }); + + if (!updtWithImage) return { status: 400, message: "Gagal update data" }; + revalidatePath(NEW_RouterInvestasi.detail_draft); + return { status: 200, message: "Berhasil update" }; + } else { + const updtNoImage = await prisma.investasi.update({ + where: { + id: data.id, + }, + data: { + title: _.startCase(data.title), + targetDana: data.targetDana, + hargaLembar: data.hargaLembar, + totalLembar: totalLembar, + sisaLembar: totalLembar, + roi: data.roi, + masterPembagianDevidenId: data.masterPembagianDevidenId, + masterPeriodeDevidenId: data.masterPeriodeDevidenId, + masterPencarianInvestorId: data.masterPencarianInvestorId, + imageId: imageId, + }, + }); + + if (!updtNoImage) return { status: 400, message: "Gagal update data" }; + revalidatePath(NEW_RouterInvestasi.detail_draft); + return { status: 200, message: "Berhasil update" }; + } +} diff --git a/src/app_modules/investasi/_fun/edit/fun_edit_prospektus.tsx b/src/app_modules/investasi/_fun/edit/fun_edit_prospektus.tsx new file mode 100644 index 00000000..e8bf3575 --- /dev/null +++ b/src/app_modules/investasi/_fun/edit/fun_edit_prospektus.tsx @@ -0,0 +1,29 @@ +"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_funUpdateProspektus({ + investasiId, + fileId, +}: { + investasiId: string; + fileId: string; +}) { + const updte = await prisma.investasi.update({ + where: { + id: investasiId, + }, + data: { + prospektusFileId: fileId, + }, + }); + + if (!updte) return { status: 400, message: "Gagal update prospektus" }; + revalidatePath(NEW_RouterInvestasi.detail_draft); + return { + status: 200, + message: "Berhasil update prospektus", + }; +} diff --git a/src/app_modules/investasi/_fun/get/fun_get_all_document_by_id.tsx b/src/app_modules/investasi/_fun/get/fun_get_all_document_by_id.tsx new file mode 100644 index 00000000..26373d7f --- /dev/null +++ b/src/app_modules/investasi/_fun/get/fun_get_all_document_by_id.tsx @@ -0,0 +1,28 @@ +"use server"; + +import { prisma } from "@/app/lib"; + +export async function investasi_funGetAllDocumentById({ + investasiId, + page, +}: { + investasiId: string; + page: number +}) { + const takeData = 10; + const skipData = page * takeData - takeData; + + const data = await prisma.dokumenInvestasi.findMany({ + take: takeData, + skip: skipData, + orderBy: { + updatedAt: "desc", + }, + where: { + investasiId: investasiId, + active: true, + }, + }); + + return data; +} diff --git a/src/app_modules/investasi/_fun/get/fun_get_one_document_by_id.tsx b/src/app_modules/investasi/_fun/get/fun_get_one_document_by_id.tsx new file mode 100644 index 00000000..e31ef426 --- /dev/null +++ b/src/app_modules/investasi/_fun/get/fun_get_one_document_by_id.tsx @@ -0,0 +1,13 @@ +"use server" + +import { prisma } from "@/app/lib" + +export async function investasi_funGetOneDocumentById({ documentId }: { documentId: string }) { + const data = await prisma.dokumenInvestasi.findFirst({ + where: { + id: documentId + } + }) + + return data +} \ No newline at end of file diff --git a/src/app_modules/investasi/_fun/get/fun_get_one_investasi_by_id.ts b/src/app_modules/investasi/_fun/get/fun_get_one_investasi_by_id.ts index 2173a3db..0aebcfad 100644 --- a/src/app_modules/investasi/_fun/get/fun_get_one_investasi_by_id.ts +++ b/src/app_modules/investasi/_fun/get/fun_get_one_investasi_by_id.ts @@ -24,6 +24,7 @@ export async function investasi_funGetOneInvestasiById({ MasterPencarianInvestor: true, MasterPeriodeDeviden: true, MasterProgresInvestasi: true, + }, }); diff --git a/src/app_modules/investasi/_fun/get/fun_get_portofolio_by_status_id.ts b/src/app_modules/investasi/_fun/get/fun_get_portofolio_by_status_id.ts new file mode 100644 index 00000000..22f2cd57 --- /dev/null +++ b/src/app_modules/investasi/_fun/get/fun_get_portofolio_by_status_id.ts @@ -0,0 +1,34 @@ +"use server"; + +import prisma from "@/app/lib/prisma"; +import { funGetUserIdByToken } from "@/app_modules/_global/fun/get"; + +export async function investasi_funGetPortofolioByStatusId({ + page, + statusId, +}: { + page: number; + statusId: string; +}) { + const userLoginId = await funGetUserIdByToken(); + + const takeData = 10; + const skipData = page * takeData - takeData; + + const data = await prisma.investasi.findMany({ + take: takeData, + skip: skipData, + orderBy: { + updatedAt: "desc", + }, + where: { + authorId: userLoginId, + masterStatusInvestasiId: statusId, + }, + include: { + MasterPencarianInvestor: true, + }, + }); + + return data; +} diff --git a/src/app_modules/investasi/_fun/index.ts b/src/app_modules/investasi/_fun/index.ts index 5739c000..6b3dde2c 100644 --- a/src/app_modules/investasi/_fun/index.ts +++ b/src/app_modules/investasi/_fun/index.ts @@ -5,6 +5,19 @@ import { investasi_funUploadBuktiTransferById } from "./upload/fun_upload_bukti_ import { investasi_funGetSuccessTransactionById } from "./get/fun_get_success_transaction_by_id"; import { investasi_funGetAllPublishByUserId } from "./get/fun_get_all_investasi_by_user_id"; import { investasi_funGetAllInvestasiNonPublishByUserId } from "./get/fun_get_all_investasi_non_publish_by_user_id"; +import { investasi_funCreateNewInvestasi } from "./create/fun_create_new_investasi"; +import { investasi_funGetPortofolioByStatusId } from "./get/fun_get_portofolio_by_status_id"; +import { investasi_funUpdateInvestasi } from "./edit/fun_edit_investasi"; +import { investasi_funUpdateProspektus } from "./edit/fun_edit_prospektus"; +import { investasi_funGetAllDocumentById } from "./get/fun_get_all_document_by_id"; +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"; + +// Create +export { investasi_funCreateNewInvestasi }; +export { investasi_funCreateDocument }; // Get export { investasi_funGetOneInvestasiById }; @@ -13,6 +26,17 @@ export { investasi_funGetTransaksiByUserId }; export { investasi_funGetSuccessTransactionById }; export { investasi_funGetAllPublishByUserId }; export { investasi_funGetAllInvestasiNonPublishByUserId }; +export { investasi_funGetPortofolioByStatusId }; +export { investasi_funGetAllDocumentById }; +export { investasi_funGetOneDocumentById }; + +// Update +export { investasi_funUpdateInvestasi }; +export { investasi_funUpdateProspektus }; +export { investasi_funUpdateDocument }; // Upload export { investasi_funUploadBuktiTransferById }; + +// Delete +export { investasi_funDeleteDokumenById }; diff --git a/src/app_modules/investasi/_fun/upload/fun_upload_bukti_transfer.tsx b/src/app_modules/investasi/_fun/upload/fun_upload_bukti_transfer.tsx index eb662a69..f8a2b1b4 100644 --- a/src/app_modules/investasi/_fun/upload/fun_upload_bukti_transfer.tsx +++ b/src/app_modules/investasi/_fun/upload/fun_upload_bukti_transfer.tsx @@ -7,38 +7,17 @@ import fs from "fs"; export async function investasi_funUploadBuktiTransferById({ invoiceId, - file, + fileId, }: { invoiceId: string; - file: FormData; + fileId: string; }) { - // console.log(file); - const gambar: any = file.get("file"); - const fileName = gambar.name; - const fileExtension = _.lowerCase(gambar.name.split(".").pop()); - const fileRandomName = v4(fileName) + "." + fileExtension; - - const upload = await prisma.images.create({ - data: { - url: fileRandomName, - label: "INVESTASI_INVOICE", - }, - select: { - id: true, - url: true, - }, - }); - - if (!upload) return { status: 400, message: "Gagal upload gambar" }; - const uploadFolder = Buffer.from(await gambar.arrayBuffer()); - fs.writeFileSync(`./public/investasi/invoice/${upload.url}`, uploadFolder); - const updateFile = await prisma.investasi_Invoice.update({ where: { id: invoiceId, }, data: { - imagesId: upload.id, + imageId: fileId, statusInvoiceId: "2", }, }); diff --git a/src/app_modules/investasi/_lib/interface.ts b/src/app_modules/investasi/_lib/interface.ts index 18d44144..72268726 100644 --- a/src/app_modules/investasi/_lib/interface.ts +++ b/src/app_modules/investasi/_lib/interface.ts @@ -19,7 +19,7 @@ export interface MODEL_INVESTASI { progress: string; MasterStatusInvestasi: MODEL_Status_investasi; BeritaInvestasi: Model_Berita_Investasi[]; - DokumenInvestasi: Model_Dokumen_Investasi[]; + DokumenInvestasi: MODEL_INVESTASI_DOKUMEN[]; ProspektusInvestasi: MODEl_PROSPEKTUS_INVESTASI; MasterPembagianDeviden: Model_All_Master; MasterPencarianInvestor: Model_All_Master; @@ -32,6 +32,8 @@ export interface MODEL_INVESTASI { author: MODEL_PROFILE_OLD; countDown: Date; Investasi_Invoice: MODEL_INVOICE_INVESTASI[]; + imageId: string; + prospektusFileId: string; } export interface MODEL_Transaksi_Investasi { @@ -88,7 +90,7 @@ export interface MODEl_PROSPEKTUS_INVESTASI { investasiId: string; } -export interface Model_Dokumen_Investasi { +export interface MODEL_INVESTASI_DOKUMEN { id: string; title: string; url: string; @@ -96,6 +98,7 @@ export interface Model_Dokumen_Investasi { createdAt: Date; updatedAt: Date; investasiId: string; + fileId: string; } export interface MODEL_MASTER_BANK { @@ -134,6 +137,7 @@ export interface MODEL_INVOICE_INVESTASI { MasterBank: MODEL_MASTER_BANK; StatusInvoice: MODEL_STATUS_INVOICE_INVESTASI; Investor: any[]; + imageId: string } export interface MODEL_STATUS_INVOICE_INVESTASI { diff --git a/src/app_modules/investasi/_ui/create/ui_create_document.tsx b/src/app_modules/investasi/_ui/create/ui_create_document.tsx new file mode 100644 index 00000000..ada8bef7 --- /dev/null +++ b/src/app_modules/investasi/_ui/create/ui_create_document.tsx @@ -0,0 +1,16 @@ +"use client" + +import { UIGlobal_LayoutHeaderTamplate, UIGlobal_LayoutTamplate } from "@/app_modules/_global/ui" +import { Investasi_ViewCreateDocument } from "../../_view"; + +export function Investasi_UiCreateDocument({ investasiId }: { investasiId : string}) { + return ( + <> + } + > + + + + ); +} \ No newline at end of file diff --git a/src/app_modules/investasi/_ui/detail/ui_daftar_dokumen.tsx b/src/app_modules/investasi/_ui/detail/ui_daftar_dokumen.tsx new file mode 100644 index 00000000..becc1705 --- /dev/null +++ b/src/app_modules/investasi/_ui/detail/ui_daftar_dokumen.tsx @@ -0,0 +1,28 @@ +"use client"; + +import { + UIGlobal_LayoutHeaderTamplate, + UIGlobal_LayoutTamplate, +} from "@/app_modules/_global/ui"; +import { Investasi_ViewDaftarDokumen } from "../../_view"; + +export function Investasi_UiDaftarDokmen({ + dataDokumen, + investasiId, +}: { + dataDokumen: any[]; + investasiId: string +}) { + return ( + <> + } + > + + + + ); +} diff --git a/src/app_modules/investasi/_ui/detail/ui_detail_portofolio.tsx b/src/app_modules/investasi/_ui/detail/ui_detail_portofolio.tsx new file mode 100644 index 00000000..83bbfa07 --- /dev/null +++ b/src/app_modules/investasi/_ui/detail/ui_detail_portofolio.tsx @@ -0,0 +1,102 @@ +"use client"; + +import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; +import { + UIGlobal_Drawer, + UIGlobal_LayoutHeaderTamplate, + UIGlobal_LayoutTamplate, +} from "@/app_modules/_global/ui"; +import { ActionIcon } from "@mantine/core"; +import { + IconCategoryPlus, + IconDotsVertical, + IconEdit, + IconFilePencil, +} from "@tabler/icons-react"; +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, +}: { + data: MODEL_INVESTASI; +}) { + const [openDrawer, setOpenDrawer] = useState(false); + const listPage = [ + { + id: "1", + name: "Edit Investasi", + icon: , + path: NEW_RouterInvestasi.edit_investasi({ id: data.id }), + }, + { + id: "2", + name: "Edit Prospektus", + icon: , + path: NEW_RouterInvestasi.edit_prospektus({ id: data.id }), + }, + { + id: "3", + name: "Tambah & Edit Dokumen", + icon: , + path: NEW_RouterInvestasi.rekap_dokumen({ id: data.id }), + }, + ]; + + if (data.masterStatusInvestasiId == "3") + return ( + <> + setOpenDrawer(true)} + > + + + } + /> + } + > + + + + setOpenDrawer(false)} + component={listPage} + /> + + ); + + return ( + + } + > + {data.masterStatusInvestasiId === "1" && ( + + )} + + {data.masterStatusInvestasiId === "2" && ( + + )} + + {data.masterStatusInvestasiId === "4" && ( + + )} + + ); +} diff --git a/src/app_modules/investasi/_ui/detail/ui_detail_prospektus.tsx b/src/app_modules/investasi/_ui/detail/ui_detail_prospektus.tsx new file mode 100644 index 00000000..d235f84d --- /dev/null +++ b/src/app_modules/investasi/_ui/detail/ui_detail_prospektus.tsx @@ -0,0 +1,23 @@ +"use client"; + +import { + UIGlobal_LayoutHeaderTamplate, + UIGlobal_LayoutTamplate, +} from "@/app_modules/_global/ui"; +import { Investasi_ViewDetailProspektus } from "../../_view"; + +export function Investasi_UiDetailProspektus({ + dataInvestasi, +}: { + dataInvestasi: any; +}) { + return ( + <> + } + > + + + + ); +} diff --git a/src/app_modules/investasi/_ui/detail/ui_rekap_dokumen.tsx b/src/app_modules/investasi/_ui/detail/ui_rekap_dokumen.tsx new file mode 100644 index 00000000..9d66d28d --- /dev/null +++ b/src/app_modules/investasi/_ui/detail/ui_rekap_dokumen.tsx @@ -0,0 +1,62 @@ +"use client"; + +import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; +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 { useState } from "react"; +import { Investasi_ViewRekapDokumen } from "../../_view"; + +export function Investasi_UiRekapDokumen({ + investasiId, + dataDokumen, +}: { + investasiId: string; + dataDokumen: any[] +}) { + const [openDrawer, setOpenDrawer] = useState(false); + + const listPage = [ + { + id: "1", + name: "Tambah Dokumen", + icon: , + path: NEW_RouterInvestasi.create_dokumen({ id: investasiId }), + }, + ]; + + return ( + <> + setOpenDrawer(true)} + variant="transparent" + > + + + } + /> + } + > + + + + setOpenDrawer(false)} + component={listPage} + /> + + ); +} diff --git a/src/app_modules/investasi/_ui/edit/ui_edit_dokumen.tsx b/src/app_modules/investasi/_ui/edit/ui_edit_dokumen.tsx new file mode 100644 index 00000000..5b53fada --- /dev/null +++ b/src/app_modules/investasi/_ui/edit/ui_edit_dokumen.tsx @@ -0,0 +1,19 @@ +"use client"; + +import { + UIGlobal_LayoutHeaderTamplate, + UIGlobal_LayoutTamplate, +} from "@/app_modules/_global/ui"; +import { Investasi_ViewEditDokumen } from "../../_view"; + +export function Investasi_UiEditDokumen({ dataDokumen }: { dataDokumen: any }) { + return ( + <> + } + > + + + + ); +} diff --git a/src/app_modules/investasi/_ui/edit/ui_edit_investasi.tsx b/src/app_modules/investasi/_ui/edit/ui_edit_investasi.tsx new file mode 100644 index 00000000..4cc5ff35 --- /dev/null +++ b/src/app_modules/investasi/_ui/edit/ui_edit_investasi.tsx @@ -0,0 +1,34 @@ +"use client"; + +import { + UIGlobal_LayoutHeaderTamplate, + UIGlobal_LayoutTamplate, +} from "@/app_modules/_global/ui"; +import { Investasi_ViewEditInvestasi } from "../../_view"; + +export function Investasi_UiEditInvestasi({ + dataInvestasi, + pembagianDeviden, + pencarianInvestor, + periodeDeviden, +}: { + dataInvestasi: any; + pembagianDeviden: any[]; + pencarianInvestor: any[]; + periodeDeviden: any[]; +}) { + return ( + <> + } + > + + + + ); +} diff --git a/src/app_modules/investasi/_ui/edit/ui_edit_prospektus.tsx b/src/app_modules/investasi/_ui/edit/ui_edit_prospektus.tsx new file mode 100644 index 00000000..d4aea25c --- /dev/null +++ b/src/app_modules/investasi/_ui/edit/ui_edit_prospektus.tsx @@ -0,0 +1,23 @@ +"use client"; + +import { + UIGlobal_LayoutHeaderTamplate, + UIGlobal_LayoutTamplate, +} from "@/app_modules/_global/ui"; +import { Investasi_ViewEditProspektus } from "../../_view"; + +export function Investasi_UiEditProspektus({ + investasiId, +}: { + investasiId: string; +}) { + return ( + <> + } + > + + + + ); +} diff --git a/src/app_modules/investasi/_ui/file_view/ui_file_view_dokumen.tsx b/src/app_modules/investasi/_ui/file_view/ui_file_view_dokumen.tsx index d7d20611..3ef116a5 100644 --- a/src/app_modules/investasi/_ui/file_view/ui_file_view_dokumen.tsx +++ b/src/app_modules/investasi/_ui/file_view/ui_file_view_dokumen.tsx @@ -1,8 +1,9 @@ "use client"; -import { RouterInvestasi_OLD } from "@/app/lib/router_hipmi/router_investasi"; +import { APIs } from "@/app/lib"; import UIGlobal_LayoutHeaderTamplate from "@/app_modules/_global/ui/ui_header_tamplate"; import UIGlobal_LayoutTamplate from "@/app_modules/_global/ui/ui_layout_tamplate"; +import { Box } from "@mantine/core"; import { IconX } from "@tabler/icons-react"; import dynamic from "next/dynamic"; const PdfToImage = dynamic( @@ -19,12 +20,11 @@ export function Investasi_UiFileViewDokumen({ return ( <> } />} + header={} />} > - + + + ); diff --git a/src/app_modules/investasi/_ui/file_view/ui_file_view_prospektus.tsx b/src/app_modules/investasi/_ui/file_view/ui_file_view_prospektus.tsx index 310e7632..224a1f93 100644 --- a/src/app_modules/investasi/_ui/file_view/ui_file_view_prospektus.tsx +++ b/src/app_modules/investasi/_ui/file_view/ui_file_view_prospektus.tsx @@ -1,8 +1,10 @@ "use client"; +import { APIs } from "@/app/lib"; import { RouterInvestasi_OLD } from "@/app/lib/router_hipmi/router_investasi"; import UIGlobal_LayoutHeaderTamplate from "@/app_modules/_global/ui/ui_header_tamplate"; import UIGlobal_LayoutTamplate from "@/app_modules/_global/ui/ui_layout_tamplate"; +import { Box } from "@mantine/core"; import { IconX } from "@tabler/icons-react"; import dynamic from "next/dynamic"; const PdfToImage = dynamic( @@ -12,19 +14,21 @@ const PdfToImage = dynamic( ); export function Investasi_UiFileViewProspektus({ - prospekId, + pospektusId, }: { - prospekId: string; + pospektusId: string; }) { return ( <> } />} > - + + + ); diff --git a/src/app_modules/investasi/_ui/index.ts b/src/app_modules/investasi/_ui/index.ts index 30dbe1a7..daedb9bc 100644 --- a/src/app_modules/investasi/_ui/index.ts +++ b/src/app_modules/investasi/_ui/index.ts @@ -11,6 +11,14 @@ import { Investasi_UiFileViewDokumen } from "./file_view/ui_file_view_dokumen"; import { Investasi_UiSahamSaya } from "./main/ui_saham_saya"; import { Investasi_UiDetailSahamSaya } from "./detail/ui_detail_saham_saya"; import { Investasi_UiPortofolio } from "./main/ui_portofolio"; +import { Investasi_UiDetailPortofolio } from "./detail/ui_detail_portofolio"; +import { Investasi_UiDetailProspektus } from "./detail/ui_detail_prospektus"; +import { Investasi_UiDaftarDokmen } from "./detail/ui_daftar_dokumen"; +import { Investasi_UiEditDokumen } from "./edit/ui_edit_dokumen"; +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"; export { Investasi_UiProsesPembelian }; export { Investasi_UiMetodePembayaran }; @@ -25,3 +33,11 @@ export { Investasi_UiFileViewDokumen }; export { Investasi_UiSahamSaya }; export { Investasi_UiDetailSahamSaya }; export { Investasi_UiPortofolio }; +export { Investasi_UiDetailPortofolio }; +export { Investasi_UiDetailProspektus }; +export { Investasi_UiDaftarDokmen }; +export { Investasi_UiEditDokumen }; +export { Investasi_UiEditInvestasi }; +export { Investasi_UiEditProspektus }; +export { Investasi_UiCreateDocument }; +export { Investasi_UiRekapDokumen }; diff --git a/src/app_modules/investasi/_ui/main/ui_layout_main.tsx b/src/app_modules/investasi/_ui/main/ui_layout_main.tsx index 0f4f6f2b..777f8fe9 100644 --- a/src/app_modules/investasi/_ui/main/ui_layout_main.tsx +++ b/src/app_modules/investasi/_ui/main/ui_layout_main.tsx @@ -1,12 +1,9 @@ "use client"; -import { useAtom } from "jotai"; -import { useRouter } from "next/navigation"; -import React from "react"; -import { gs_investas_menu } from "../../g_state"; -import UIGlobal_LayoutTamplate from "@/app_modules/_global/ui/ui_layout_tamplate"; import { RouterCrowd } from "@/app/lib/router_hipmi/router_crowd"; import UIGlobal_LayoutHeaderTamplate from "@/app_modules/_global/ui/ui_header_tamplate"; +import UIGlobal_LayoutTamplate from "@/app_modules/_global/ui/ui_layout_tamplate"; +import React from "react"; import { Investasi_ComponentFooterMain } from "../../_component"; export function Investasi_UiLayoutMain({ diff --git a/src/app_modules/investasi/_ui/main/ui_portofolio.tsx b/src/app_modules/investasi/_ui/main/ui_portofolio.tsx index 2c60ed5c..54715c0d 100644 --- a/src/app_modules/investasi/_ui/main/ui_portofolio.tsx +++ b/src/app_modules/investasi/_ui/main/ui_portofolio.tsx @@ -1,28 +1,70 @@ "use client"; +import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; +import { AccentColor, MainColor } from "@/app_modules/_global/color"; +import { MODEL_NEW_DEFAULT_MASTER } from "@/app_modules/model_global/interface"; +import { Stack, Tabs } from "@mantine/core"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; import { Investasi_ViewPortofolio } from "../../_view"; export function Investasi_UiPortofolio({ listStatus, - listDataPublish, - listDataReview, - listDataDraft, - listDataReject, + statusId, + dataPortofolio, }: { - listStatus: any[]; - listDataPublish: any[]; - listDataReview: any[]; - listDataDraft: any[]; - listDataReject: any[]; + listStatus: MODEL_NEW_DEFAULT_MASTER[]; + statusId: string; + dataPortofolio: any[]; }) { + const [activeTab, setActiveTab] = useState(statusId); + const router = useRouter(); + const [data, setData] = useState(dataPortofolio); + return ( <> - + { + setActiveTab(val); + router.push(NEW_RouterInvestasi.portofolio({ id: val })); + }} + > + + + {listStatus.map((e) => ( + + {e.name} + + ))} + + + + + ); } diff --git a/src/app_modules/investasi/_view/create/view_create_document.tsx b/src/app_modules/investasi/_view/create/view_create_document.tsx new file mode 100644 index 00000000..807fe19c --- /dev/null +++ b/src/app_modules/investasi/_view/create/view_create_document.tsx @@ -0,0 +1,159 @@ +import { MainColor } from "@/app_modules/_global/color"; +import { + ComponentGlobal_BoxInformation, + ComponentGlobal_CardStyles, +} from "@/app_modules/_global/component"; +import { + Stack, + Grid, + Center, + Group, + FileButton, + Button, + Text, + TextInput, +} from "@mantine/core"; +import { IconCircleCheck, IconCamera } from "@tabler/icons-react"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; +import { investasi_funCreateDocument } from "../../_fun"; +import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun"; +import { DIRECTORY_ID } from "@/app/lib"; +import { + ComponentGlobal_NotifikasiBerhasil, + ComponentGlobal_NotifikasiPeringatan, +} from "@/app_modules/_global/notif_global"; + +export function Investasi_ViewCreateDocument({ + investasiId, +}: { + investasiId: string; +}) { + const router = useRouter(); + const [filePdf, setFilePdf] = useState(null); + const [isLoading, setIsLoading] = useState(false); + const [title, setTitle] = useState(""); + + async function onCreate() { + setIsLoading(true); + const uploadFileDokumen = await funGlobal_UploadToStorage({ + file: filePdf as any, + dirId: DIRECTORY_ID.investasi_dokumen, + }); + if (!uploadFileDokumen.success) { + setIsLoading(false); + ComponentGlobal_NotifikasiPeringatan("Gagal upload file pdf"); + } + + try { + const create = await investasi_funCreateDocument({ + data: { + investasiId: investasiId, + fileId: uploadFileDokumen.data.id, + title: title, + }, + }); + + if (create.status !== 201) + ComponentGlobal_NotifikasiPeringatan(create.message); + + router.back(); + ComponentGlobal_NotifikasiBerhasil(create.message); + } catch (error) { + console.log(error); + } finally { + setIsLoading(false); + } + } + + return ( + <> + + + + + setTitle(val.currentTarget.value)} + /> + + {!filePdf ? ( + + Upload Dokumen + + ) : ( + + + + + {filePdf.name} + + + +
+ +
+
+
+ )} +
+ + + { + try { + const buffer = URL.createObjectURL( + new Blob([new Uint8Array(await files.arrayBuffer())]) + ); + + setFilePdf(files); + } catch (error) { + console.log(error); + } + }} + > + {(props) => ( + + )} + + +
+ + +
+ + ); +} diff --git a/src/app_modules/investasi/_view/detail/portofolio/view_detai_publish.tsx b/src/app_modules/investasi/_view/detail/portofolio/view_detai_publish.tsx new file mode 100644 index 00000000..e0ad99f7 --- /dev/null +++ b/src/app_modules/investasi/_view/detail/portofolio/view_detai_publish.tsx @@ -0,0 +1,232 @@ +"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: , + route: RouterInvestasi_OLD.detail_prospektus, + }, + { + id: 2, + name: "Dokumen", + icon: , + route: RouterInvestasi_OLD.edit_dokumen, + }, + { + id: 3, + name: "Berita", + icon: , + route: RouterInvestasi_OLD.list_edit_berita, + }, + ]; + + return ( + + {Number(investasi.MasterPencarianInvestor.name) - + moment(new Date()).diff(new Date(investasi.countDown), "days") <= + 0 ? ( + + + Selesai + + ) : ( + + + Sisa waktu :{" "} + {Number(investasi.MasterPencarianInvestor.name) - + moment(new Date()).diff( + new Date(investasi.countDown), + "days" + )}{" "} + hari + + + )} + + + + + + {/* Title dan Persentase */} + + + {investasi.title} + + + + + {/* Rincian Data */} + + + + + Dana Dibutuhkan + + Rp.{" "} + {new Intl.NumberFormat("id-ID", { + maximumSignificantDigits: 10, + }).format(+investasi.targetDana)} + + + + Harga Per Lembar + + Rp.{" "} + {new Intl.NumberFormat("id-ID", { + maximumSignificantDigits: 10, + }).format(+investasi.hargaLembar)} + + + + Jadwal Pembagian + {investasi.MasterPembagianDeviden.name} bulan + + + Pembagian Deviden + {investasi.MasterPeriodeDeviden.name} + + + + + + + ROI + {investasi.roi}% + + + Total Lembar + + {new Intl.NumberFormat("id-ID", { + maximumSignificantDigits: 10, + }).format(+investasi.totalLembar)}{" "} + lembar + + + + Sisa Lembar + + {new Intl.NumberFormat("id-ID", { + maximumSignificantDigits: 10, + }).format(+investasi.sisaLembar)}{" "} + lembar + + + + + + + {/* List Box */} + + {listBox.map((e, i) => ( + + + {e.name} + router.push(e.route + `${investasi.id}`)} + > + {e.icon} + + + + ))} + + + ); +} diff --git a/src/app_modules/investasi/_view/detail/portofolio/view_detail_draft.tsx b/src/app_modules/investasi/_view/detail/portofolio/view_detail_draft.tsx new file mode 100644 index 00000000..980a2a56 --- /dev/null +++ b/src/app_modules/investasi/_view/detail/portofolio/view_detail_draft.tsx @@ -0,0 +1,92 @@ +"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_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"; +import mqtt_client from "@/util/mqtt_client"; +import { Button, Stack } from "@mantine/core"; +import { useAtom } from "jotai"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; + +export default function Investasi_ViewDetailDraft({ + dataInvestasi, +}: { + dataInvestasi: MODEL_INVESTASI; +}) { + const router = useRouter(); + const [isLoading, setIsLoading] = useState(false); + const [activeTab, setActiveTab] = useAtom(gs_investasi_status); + + async function onAjukanReview() { + const res = await investasi_funEditStatusById({ + investasiId: dataInvestasi.id, + statusId: "2", + }); + + if (res.status === 200) { + const dataNotif = { + appId: res.data?.id, + userId: res.data?.authorId, + pesan: res.data?.title, + status: res.data?.MasterStatusInvestasi?.name, + kategoriApp: "INVESTASI", + title: "Mengajukan review", + }; + + const notif = await notifikasiToAdmin_funCreate({ + data: dataNotif as any, + }); + + if (notif.status === 201) { + mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 })); + + setIsLoading(true); + ComponentGlobal_NotifikasiBerhasil("Review Berhasil Diajukan"); + router.push(NEW_RouterInvestasi.portofolio({ id: dataInvestasi.id })); + setActiveTab("Review"); + } + } else { + ComponentGlobal_NotifikasiGagal(res.message); + } + } + + return ( + <> + + {dataInvestasi.catatan && ( + + )} + + + + + + + + ); +} diff --git a/src/app_modules/investasi/_view/detail/portofolio/view_detail_reject.tsx b/src/app_modules/investasi/_view/detail/portofolio/view_detail_reject.tsx new file mode 100644 index 00000000..c2926b2a --- /dev/null +++ b/src/app_modules/investasi/_view/detail/portofolio/view_detail_reject.tsx @@ -0,0 +1,114 @@ +"use client"; + +import { + NEW_RouterInvestasi, + RouterInvestasi_OLD, +} from "@/app/lib/router_hipmi/router_investasi"; +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 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"; +import { Button, Group, Stack } from "@mantine/core"; +import { useAtom } from "jotai"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; + +export default function Investasi_ViewDetailReject({ + dataInvestasi, +}: { + dataInvestasi: MODEL_INVESTASI; +}) { + const router = useRouter(); + const [investasi, setInvestasi] = useState(dataInvestasi); + const [activeTab, setActiveTab] = useAtom(gs_investasi_status); + const [openModal, setOpenModal] = useState(false); + + async function onAjukan() { + const res = await investasi_funEditStatusById({ + investasiId: dataInvestasi.id, + statusId: "3", + }); + + if (res.status === 200) { + ComponentGlobal_NotifikasiBerhasil("Project Diajukan Kembali"); + setActiveTab("Draft"); + router.push(RouterInvestasi_OLD.portofolio); + } else { + ComponentGlobal_NotifikasiGagal("Gagal Pengajuan"); + } + } + + async function onDelete() { + await funDeleteInvestasi(investasi.id).then((res) => { + if (res.status === 200) { + ComponentGlobal_NotifikasiBerhasil(res.message); + setOpenModal(false); + router.push(NEW_RouterInvestasi.portofolio({ id: dataInvestasi.id })); + } else { + ComponentGlobal_NotifikasiGagal(res.message); + } + }); + // setActiveTab("Reject"); + } + + return ( + <> + {/* Pop up */} + setOpenModal(false)} + buttonKiri={ + + } + buttonKanan={ + + } + /> + + + {/* Alasan */} + + + + + + {/* Tombol Ajukan */} + + + {/* Tombol Hapus */} + + + + + ); +} diff --git a/src/app_modules/investasi/_view/detail/portofolio/view_detail_review.tsx b/src/app_modules/investasi/_view/detail/portofolio/view_detail_review.tsx new file mode 100644 index 00000000..5089a906 --- /dev/null +++ b/src/app_modules/investasi/_view/detail/portofolio/view_detail_review.tsx @@ -0,0 +1,85 @@ +"use client"; + +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"; +import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface"; +import { investasi_funEditStatusById } from "@/app_modules/investasi/fun/edit/fun_edit_status_by_id"; +import { gs_investasi_status } from "@/app_modules/investasi/g_state"; +import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin"; +import mqtt_client from "@/util/mqtt_client"; +import { Button, Stack } from "@mantine/core"; +import { useAtom } from "jotai"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; + + +export default function Investasi_ViewDetailReview({ + dataInvestasi, +}: { + dataInvestasi: MODEL_INVESTASI; +}) { + const router = useRouter(); + const [isLoading, setLoading] = useState(false); + + const [activeTab, setActiveTab] = useAtom(gs_investasi_status); + const [data, setData] = useState(dataInvestasi); + + async function onCancleReview() { + const res = await investasi_funEditStatusById({ + investasiId: data.id, + statusId: "3", + }); + if (res.status === 200) { + const dataNotif = { + appId: res.data?.id, + userId: res.data?.authorId, + pesan: res.data?.title, + status: res.data?.MasterStatusInvestasi?.name, + kategoriApp: "INVESTASI", + title: "Membatalkan review", + }; + + const notif = await notifikasiToAdmin_funCreate({ + data: dataNotif as any, + }); + + if (notif.status === 201) { + mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 })); + + setLoading(true); + ComponentGlobal_NotifikasiBerhasil("Review Dibatalkan"); + setActiveTab("Draft"); + router.push(NEW_RouterInvestasi.portofolio({id: data.id})); + } + } else { + ComponentGlobal_NotifikasiPeringatan(res.message); + } + } + + return ( + <> + + + {/* Tombol Ajukan */} + + + + + + ); +} diff --git a/src/app_modules/investasi/_view/detail/view_daftar_dokemen.tsx b/src/app_modules/investasi/_view/detail/view_daftar_dokemen.tsx new file mode 100644 index 00000000..d00df146 --- /dev/null +++ b/src/app_modules/investasi/_view/detail/view_daftar_dokemen.tsx @@ -0,0 +1,61 @@ +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"; + +export function Investasi_ViewDaftarDokumen({ + dataDokumen, + investasiId, +}: { + dataDokumen: any[]; + investasiId: string; +}) { + const [data, setData] = useState(dataDokumen); + const [activePage, setActivePage] = useState(1); + + return ( + <> + + <> + {_.isEmpty(data) ? ( + + ) : ( + + ( +
+ +
+ )} + data={data} + setData={setData} + moreData={async () => { + const loadData = await investasi_funGetAllDocumentById({ + investasiId: investasiId, + page: activePage + 1, + }); + + setActivePage((val) => val + 1); + + return loadData; + }} + > + {(item) => ( + + )} +
+
+ )} + +
+ + ); +} diff --git a/src/app_modules/investasi/_view/detail/view_detail_prospektusl.tsx b/src/app_modules/investasi/_view/detail/view_detail_prospektusl.tsx new file mode 100644 index 00000000..3c3c95cc --- /dev/null +++ b/src/app_modules/investasi/_view/detail/view_detail_prospektusl.tsx @@ -0,0 +1,46 @@ +import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; +import { MainColor } from "@/app_modules/_global/color"; +import { + ComponentGlobal_CardLoadingOverlay, + ComponentGlobal_CardStyles, +} from "@/app_modules/_global/component"; +import { Center, Group, Text } from "@mantine/core"; +import { IconFileTypePdf } from "@tabler/icons-react"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; +import { MODEL_INVESTASI } from "../../_lib/interface"; + +export function Investasi_ViewDetailProspektus({ + dataInvestasi, +}: { + dataInvestasi: MODEL_INVESTASI; +}) { + const router = useRouter(); + const [visible, setVisible] = useState(false); + + return ( + <> + { + router.push( + NEW_RouterInvestasi.file_prospektus({ + id: dataInvestasi.prospektusFileId, + }), + { scroll: false } + ); + setVisible(true); + }} + > + + + Prospektus {dataInvestasi?.title} + +
+ +
+
+ {visible && } +
+ + ); +} diff --git a/src/app_modules/investasi/_view/detail/view_rekap_dokumen.tsx b/src/app_modules/investasi/_view/detail/view_rekap_dokumen.tsx new file mode 100644 index 00000000..5b0e0285 --- /dev/null +++ b/src/app_modules/investasi/_view/detail/view_rekap_dokumen.tsx @@ -0,0 +1,60 @@ +import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data"; +import ComponentGlobal_Loader from "@/app_modules/_global/component/loader"; +import { Box, Center } from "@mantine/core"; +import _ from "lodash"; +import { ScrollOnly } from "next-scroll-loader"; +import { useState } from "react"; +import { Investasi_ComponentCardRekapDocument } from "../../_component"; +import { investasi_funGetAllDocumentById } from "../../_fun"; +import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface"; +import { useShallowEffect } from "@mantine/hooks"; + +export function Investasi_ViewRekapDokumen({ + dataDokumen, + investasiId, +}: { + dataDokumen: any[]; + investasiId: string; +}) { + const [data, setData] = useState(dataDokumen); + const [activePage, setActivePage] = useState(1); + + + return ( + <> + {_.isEmpty(data) ? ( + + ) : ( + + ( +
+ +
+ )} + data={data} + setData={setData} + moreData={async () => { + const loadData = await investasi_funGetAllDocumentById({ + investasiId: investasiId, + page: activePage + 1, + }); + + setActivePage((val) => val + 1); + + return loadData; + }} + > + {(item) => ( + setData(val) as any} + /> + )} +
+
+ )} + + ); +} diff --git a/src/app_modules/investasi/_view/edit/view_edit_dokumen.tsx b/src/app_modules/investasi/_view/edit/view_edit_dokumen.tsx new file mode 100644 index 00000000..802b36ec --- /dev/null +++ b/src/app_modules/investasi/_view/edit/view_edit_dokumen.tsx @@ -0,0 +1,180 @@ +import { DIRECTORY_ID } from "@/app/lib"; +import { MainColor } from "@/app_modules/_global/color"; +import { + ComponentGlobal_CardStyles +} from "@/app_modules/_global/component"; +import { + funGlobal_DeleteFileById, + funGlobal_UploadToStorage, +} from "@/app_modules/_global/fun"; +import { + ComponentGlobal_NotifikasiBerhasil, + ComponentGlobal_NotifikasiPeringatan, +} from "@/app_modules/_global/notif_global"; +import { + Button, + Center, + FileButton, + Grid, + Group, + Stack, + Text, + TextInput, +} from "@mantine/core"; +import { IconCamera, IconCircleCheck } from "@tabler/icons-react"; +import _ from "lodash"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; +import { investasi_funUpdateDocument } from "../../_fun"; +import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface"; + +export function Investasi_ViewEditDokumen({ + dataDokumen, +}: { + dataDokumen: MODEL_INVESTASI_DOKUMEN; +}) { + const router = useRouter(); + const [filePdf, setFilePdf] = useState(null); + const [isLoading, setIsLoading] = useState(false); + const [data, setData] = useState(dataDokumen); + const [title, setTitle] = useState(data.title); + + async function onUpdate() { + try { + setIsLoading(true); + if (filePdf) { + const delfile = await funGlobal_DeleteFileById({ fileId: data.fileId }); + + if (!delfile.success) { + ComponentGlobal_NotifikasiPeringatan("Gagal hapus file lama"); + } + + const uploadFile = await funGlobal_UploadToStorage({ + file: filePdf, + dirId: DIRECTORY_ID.investasi_dokumen, + }); + + if (!uploadFile.success) { + setIsLoading(false); + ComponentGlobal_NotifikasiPeringatan("Gagal upload file dokumen"); + } + + const updateWithFile = await investasi_funUpdateDocument({ + data: data, + fileId: uploadFile.data.id, + }); + + if (updateWithFile.status !== 200) { + ComponentGlobal_NotifikasiPeringatan(updateWithFile.message); + } + ComponentGlobal_NotifikasiBerhasil(updateWithFile.message); + } else { + const updateNoFile = await investasi_funUpdateDocument({ + data: data, + }); + + if (updateNoFile.status !== 200) { + ComponentGlobal_NotifikasiPeringatan(updateNoFile.message); + } + ComponentGlobal_NotifikasiBerhasil(updateNoFile.message); + } + } catch (error) { + console.log(error); + } finally { + router.back(); + setIsLoading(false); + } + } + + return ( + <> + + {/* */} + + + setData({ ...data, title: val.target.value })} + /> + + {!filePdf ? ( + + Dokumen {_.startCase(title)}.pdf + + ) : ( + + + + + {filePdf.name} + + + +
+ +
+
+
+ )} +
+ + + { + try { + const buffer = URL.createObjectURL( + new Blob([new Uint8Array(await files.arrayBuffer())]) + ); + + setFilePdf(files); + } catch (error) { + console.log(error); + } + }} + > + {(props) => ( + + )} + + +
+ + +
+ + ); +} diff --git a/src/app_modules/investasi/_view/edit/view_edit_investasi.tsx b/src/app_modules/investasi/_view/edit/view_edit_investasi.tsx new file mode 100644 index 00000000..56d9f9b8 --- /dev/null +++ b/src/app_modules/investasi/_view/edit/view_edit_investasi.tsx @@ -0,0 +1,328 @@ +import { APIs, DIRECTORY_ID } from "@/app/lib"; +import { MainColor } from "@/app_modules/_global/color"; +import { + ComponentGlobal_BoxInformation, + ComponentGlobal_BoxUploadImage, + ComponentGlobal_LoadImage, +} from "@/app_modules/_global/component"; +import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global"; +import { MODEL_DEFAULT_MASTER_OLD } from "@/app_modules/model_global/interface"; +import { + AspectRatio, + Box, + Button, + FileButton, + Group, + Image, + Select, + Stack, + Text, + TextInput, +} from "@mantine/core"; +import { IconCamera } from "@tabler/icons-react"; +import _ from "lodash"; +import { useState } from "react"; +import { MODEL_INVESTASI } from "../../_lib/interface"; +import { investasi_funUpdateInvestasi } from "../../_fun"; +import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun"; +import { Investasi_ComponentButtonUpdateDataInvestasi } from "../../_component"; +import { useShallowEffect } from "@mantine/hooks"; + +export function Investasi_ViewEditInvestasi({ + dataInvestasi, + pencarianInvestor, + periodeDeviden, + pembagianDeviden, +}: { + dataInvestasi: any; + pencarianInvestor: MODEL_DEFAULT_MASTER_OLD[]; + periodeDeviden: MODEL_DEFAULT_MASTER_OLD[]; + pembagianDeviden: MODEL_DEFAULT_MASTER_OLD[]; +}) { + const [data, setData] = useState(dataInvestasi); + const [file, setFile] = useState(null); + const [img, setImg] = useState(); + const [target, setTarget] = useState(""); + const [harga, setHarga] = useState(""); + const [totalLembar, setTotalLembar] = useState(data.totalLembar); + + async function onTotalLembar({ + target, + harga, + }: { + target?: number | any; + harga?: number | any; + }) { + if (target !== 0 && harga !== 0) { + const hasil: any = target / harga; + const result = _.floor(hasil === Infinity ? 0 : hasil); + setTotalLembar(result.toString()); + } + } + + return ( + <> + + + + + + + {img ? ( + + Avatar + + ) : ( + + )} + + {/* Upload Foto */} + + { + 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) => ( + + )} + + + + + {/* +
{JSON.stringify(data.targetDana)}
+
{JSON.stringify(data.hargaLembar)}
+
{JSON.stringify(data.totalLembar)}
+
{JSON.stringify(totalLembar)}
+
*/} + + { + setData({ + ...data, + title: val.target.value, + }); + }} + /> + + Rp.} + min={0} + withAsterisk + label="Dana Dibutuhkan" + placeholder="0" + value={target ? target : data.targetDana} + onChange={(val) => { + // console.log(typeof val) + const match = val.currentTarget.value + .replace(/\./g, "") + .match(/^[0-9]+$/); + + if (val.currentTarget.value === "") return setTarget(0 + ""); + if (!match?.[0]) return null; + + const nilai = val.currentTarget.value.replace(/\./g, ""); + const targetNilai = Intl.NumberFormat("id-ID").format(+nilai); + + onTotalLembar({ + target: +nilai, + harga: +data.hargaLembar, + }); + + setTarget(targetNilai); + setData({ + ...data, + targetDana: nilai as string, + }); + }} + /> + + Rp.} + min={0} + withAsterisk + label="Harga Per Lembar" + placeholder="0" + value={harga ? harga : data.hargaLembar} + onChange={(val) => { + try { + // console.log(typeof +val.currentTarget.value); + + const match = val.currentTarget.value + .replace(/\./g, "") + .match(/^[0-9]+$/); + + if (val.currentTarget.value === "") return setHarga(0 + ""); + + if (!match?.[0]) return null; + + const nilai = val.currentTarget.value.replace(/\./g, ""); + const targetNilai = Intl.NumberFormat("id-ID").format(+nilai); + + onTotalLembar({ + harga: +nilai, + target: +data.targetDana, + }); + + setHarga(targetNilai); + setData({ + ...data, + hargaLembar: nilai as string, + }); + } catch (error) { + console.log(error); + } + }} + /> + + + + + % + + } + withAsterisk + type="number" + label={"Rasio Keuntungan / ROI %"} + placeholder="Masukan rasio keuntungan" + value={data.roi} + onChange={(val) => { + setData({ + ...data, + roi: val.target.value, + }); + }} + /> + + ({ value: e.id, label: e.name }))} + value={data.masterPeriodeDevidenId} + onChange={(val) => { + setData({ + ...(data as any), + masterPeriodeDevidenId: val, + }); + }} + /> + + ({ + value: e.id, + label: e.name + " " + "hari", + }))} + onChange={(val) => { + setValue({ + ...(value as any), + pencarianInvestorId: val, + }); + }} + /> + + ({ + value: e.id, + label: e.name + " " + "bulan", + }))} + onChange={(val) => { + setValue({ + ...(value as any), + pembagianDevidenId: val, + }); + }} + />
- - % - - } - withAsterisk - type="number" - label={"Rasio Keuntungan / ROI %"} - placeholder="Masukan rasio keuntungan" - onChange={(val) => { - setValue({ - ...value, - roi: _.toNumber(val.target.value), - }); - }} + - - ({ value: e.id, label: e.name }))} - onChange={(val) => { - setValue({ - ...(value as any), - periodeDevidenId: val, - }); - }} - /> - ("changeColor", 0); + +/** + * @param key | "Publish", "Review", "Draft", "Reject" + * @type string + */ export const gs_investasi_status = atomWithStorage( "gs_TabPortoInvestasi", "Publish" diff --git a/src/app_modules/investasi/index.ts b/src/app_modules/investasi/index.ts index 5ce4f341..12aa9453 100644 --- a/src/app_modules/investasi/index.ts +++ b/src/app_modules/investasi/index.ts @@ -12,8 +12,6 @@ import CountDownTransaksiInvestasi from "./dialog_page/transaksi_saham/view"; import LayoutCountDownTransaksiInvestasi from "./dialog_page/transaksi_saham/layout"; import PortofolioInvestasi from "./portofolio/view"; import LayoutPortofolioInvestasi from "./portofolio/layout"; -import EditInvestasi from "./edit/view"; -import LayoutEditInvestasi from "./edit/layout"; import EditIntroInvestasi from "./edit_intro/view"; import LayoutEditIntroInvestasi from "./edit_intro/layout"; import EditProspektusInvestasi from "./edit_propektus/view"; @@ -79,8 +77,6 @@ export { LayoutCountDownTransaksiInvestasi as LayoutKonfirmasiBuktiInvestasi, PortofolioInvestasi, LayoutPortofolioInvestasi, - EditInvestasi, - LayoutEditInvestasi, EditIntroInvestasi, LayoutEditIntroInvestasi, EditProspektusInvestasi, diff --git a/src/app_modules/map/ui/ui_edit_map.tsx b/src/app_modules/map/ui/ui_edit_map.tsx index d791a0a8..9cabf547 100644 --- a/src/app_modules/map/ui/ui_edit_map.tsx +++ b/src/app_modules/map/ui/ui_edit_map.tsx @@ -1,14 +1,15 @@ "use client"; -import { RouterPortofolio } from "@/app/lib/router_hipmi/router_katalog"; -import { RouterMap } from "@/app/lib/router_hipmi/router_map"; +import { APIs } from "@/app/lib"; import { AccentColor, MainColor, } from "@/app_modules/_global/color/color_pallet"; +import { + ComponentGlobal_BoxUploadImage, + ComponentGlobal_LoadImage, +} from "@/app_modules/_global/component"; 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 { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan"; import { AspectRatio, @@ -19,12 +20,9 @@ import { Image, Paper, Stack, - Text, TextInput, - Title, } from "@mantine/core"; import { IconCamera } from "@tabler/icons-react"; -import { useRouter } from "next/navigation"; import { useState } from "react"; import Map, { AttributionControl, @@ -32,15 +30,9 @@ import Map, { NavigationControl, ScaleControl, } from "react-map-gl"; -import { map_funEditMap } from "../fun/edit/fun_edit_map"; +import { ComponentMap_ButtonUpdateDataMap } from "../_component"; import { defaultMapZoom } from "../lib/default_lat_long"; import { MODEL_MAP } from "../lib/interface"; -import { APIs } from "@/app/lib"; -import { - ComponentGlobal_BoxUploadImage, - ComponentGlobal_LoadImage, -} from "@/app_modules/_global/component"; -import { ComponentMap_ButtonUpdateDataMap } from "../_component"; export function UiMap_EditMap({ mapboxToken,