From 8ee62b875daa293de18101237b15f52f34f2ec91 Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Thu, 14 Dec 2023 10:19:40 +0800 Subject: [PATCH] Payment gateaway # fix - Alur setelah pembayaran ### Issue: - Payment notif akan di perbaharui --- src/app/dev/investasi/detail/[id]/page.tsx | 4 + src/app/dev/investasi/main/page.tsx | 3 +- src/app_modules/investasi/detail/view.tsx | 80 +++++--- .../detail_portofolio/publish/page.tsx | 28 ++- .../investasi/detail_saham_terbeli/view.tsx | 171 ++++++++++++----- .../investasi/fun/fun_total_investor_by_id.ts | 2 +- .../investasi/fun/get_list_all_publish.ts | 2 +- .../fun/get_list_transaksi_berhasil_by_id.ts | 13 +- .../investasi/fun/get_token_transaksi.js | 16 +- src/app_modules/investasi/index.ts | 2 +- src/app_modules/investasi/main/saham_saya.tsx | 152 --------------- src/app_modules/investasi/main/view.tsx | 94 ++++++---- .../investasi/proses_transaksi/view.jsx | 173 +++++++++-------- .../investasi/saham_saya/saham_saya.tsx | 174 ++++++++++++++++++ src/app_modules/investasi/transaksi/view.tsx | 2 +- 15 files changed, 549 insertions(+), 367 deletions(-) delete mode 100644 src/app_modules/investasi/main/saham_saya.tsx create mode 100644 src/app_modules/investasi/saham_saya/saham_saya.tsx diff --git a/src/app/dev/investasi/detail/[id]/page.tsx b/src/app/dev/investasi/detail/[id]/page.tsx index ba8680e5..fccfe11f 100644 --- a/src/app/dev/investasi/detail/[id]/page.tsx +++ b/src/app/dev/investasi/detail/[id]/page.tsx @@ -7,6 +7,7 @@ import fs from "fs"; import { cookies } from "next/headers"; import { unsealData } from "iron-session"; import funProgressBar from "@/app_modules/investasi/fun/fun_progress_bar"; +import funTotalInvestorByIdInvestasi from "@/app_modules/investasi/fun/fun_total_investor_by_id"; const config = yaml.parse(fs.readFileSync("config.yaml").toString()); export default async function Page({ params }: { params: { id: string } }) { @@ -25,6 +26,8 @@ export default async function Page({ params }: { params: { id: string } }) { let beli = Number(dataInvestasi?.lembarTerbeli) const progress = await funProgressBar(total, beli) + const totalInvestor = await funTotalInvestorByIdInvestasi(dataInvestasi?.id) + return ( <> ); diff --git a/src/app/dev/investasi/main/page.tsx b/src/app/dev/investasi/main/page.tsx index c118016f..b7f12dfe 100644 --- a/src/app/dev/investasi/main/page.tsx +++ b/src/app/dev/investasi/main/page.tsx @@ -1,4 +1,5 @@ import { MainInvestasi } from "@/app_modules/investasi"; +import funTotalInvestorByIdInvestasi from "@/app_modules/investasi/fun/fun_total_investor_by_id"; import { getListAllPublish } from "@/app_modules/investasi/fun/get_list_all_publish"; import getPembagianDeviden from "@/app_modules/investasi/fun/master/get_pembagian_deviden"; import getPencarianInvestor from "@/app_modules/investasi/fun/master/get_pencarian_investor"; @@ -10,8 +11,6 @@ export default async function Page() { const periodeDeviden = await getPeriodeDeviden(); const pembagianDeviden = await getPembagianDeviden(); - - // console.log(data) return ( <> diff --git a/src/app_modules/investasi/detail/view.tsx b/src/app_modules/investasi/detail/view.tsx index 65524e5d..d3194459 100644 --- a/src/app_modules/investasi/detail/view.tsx +++ b/src/app_modules/investasi/detail/view.tsx @@ -34,17 +34,20 @@ import { MODEL_User_profile } from "@/app_modules/home/models/user_profile"; import { RouterUserProfile } from "@/app/lib/router_hipmi/router_user_profile"; import { gs_TransferValue } from "../g_state"; import { useAtom } from "jotai"; +import _ from "lodash"; export default function DetailInvestasi({ dataInvestasi, dataUser, loginUserId, - progress + progress, + totalInvestor }: { dataInvestasi: MODEL_Investasi; dataUser: MODEL_User_profile; loginUserId: string; - progress: number + progress: number; + totalInvestor: number }) { const router = useRouter(); const [investasi, setInvestasi] = useState(dataInvestasi); @@ -81,7 +84,6 @@ export default function DetailInvestasi({ nomorRekening: "", totalTransfer: "", }); - } return ( @@ -89,16 +91,19 @@ export default function DetailInvestasi({ {/* Foto username dan sisa waktu */} - + + {(() => { + const usr = investasi.author.username; + const splt = usr.split(""); + const Up = _.upperCase(splt[0]); + + return Up; + })()} + {user.username} {Number(investasi.MasterPencarianInvestor.name) - - moment(new Date()).diff(new Date(investasi.updatedAt), "days") <= + moment(new Date()).diff(new Date(investasi.countDown), "days") <= 0 ? ( @@ -109,7 +114,7 @@ export default function DetailInvestasi({ Sisa waktu: {Number(investasi.MasterPencarianInvestor.name) - - moment(new Date()).diff(new Date(investasi.updatedAt), "days")} + moment(new Date()).diff(new Date(investasi.countDown), "days")} Hari @@ -131,12 +136,25 @@ export default function DetailInvestasi({ {investasi.title} @@ -146,15 +164,21 @@ export default function DetailInvestasi({ Dana Dibutuhkan - Rp. {new Intl.NumberFormat("id-ID", { + + Rp.{" "} + {new Intl.NumberFormat("id-ID", { maximumSignificantDigits: 10, - }).format(+investasi.targetDana)} + }).format(+investasi.targetDana)} + Harga Per Lembar - Rp. {new Intl.NumberFormat("id-ID", { + + Rp.{" "} + {new Intl.NumberFormat("id-ID", { maximumSignificantDigits: 10, - }).format(+investasi.hargaLembar)} + }).format(+investasi.hargaLembar)} + Jadwal Pembagian @@ -168,21 +192,31 @@ export default function DetailInvestasi({ + + Investor + {new Intl.NumberFormat("id-ID", {maximumSignificantDigits: 10}).format(totalInvestor)} + ROI {investasi.roi}% Total Lembar - {new Intl.NumberFormat("id-ID", { + + {new Intl.NumberFormat("id-ID", { maximumSignificantDigits: 10, - }).format(+investasi.totalLembar)} lembar + }).format(+investasi.totalLembar)}{" "} + lembar + Sisa Lembar - {new Intl.NumberFormat("id-ID", { + + {new Intl.NumberFormat("id-ID", { maximumSignificantDigits: 10, - }).format(+investasi.sisaLembar)} lembar + }).format(+investasi.sisaLembar)}{" "} + lembar + @@ -221,7 +255,7 @@ export default function DetailInvestasi({ w={350} bg={Warna.biru} onClick={() => { - onSubmit() + onSubmit(); }} > Beli Saham diff --git a/src/app_modules/investasi/detail_portofolio/publish/page.tsx b/src/app_modules/investasi/detail_portofolio/publish/page.tsx index fac7f618..68bd9ad0 100644 --- a/src/app_modules/investasi/detail_portofolio/publish/page.tsx +++ b/src/app_modules/investasi/detail_portofolio/publish/page.tsx @@ -66,9 +66,9 @@ export default function DetailPublishInvestasi({ return ( <> {Number(investasi.MasterPencarianInvestor.name) - - moment(new Date()).diff(new Date(investasi.updatedAt), "days") <= + moment(new Date()).diff(new Date(investasi.countDown), "days") <= 0 ? ( - + Selesai @@ -78,7 +78,7 @@ export default function DetailPublishInvestasi({ Sisa waktu :{" "} {Number(investasi.MasterPencarianInvestor.name) - moment(new Date()).diff( - new Date(investasi.updatedAt), + new Date(investasi.countDown), "days" )}{" "} hari @@ -100,7 +100,27 @@ export default function DetailPublishInvestasi({ {investasi.title} - + {/* Rincian Data */} diff --git a/src/app_modules/investasi/detail_saham_terbeli/view.tsx b/src/app_modules/investasi/detail_saham_terbeli/view.tsx index 04370656..44caf969 100644 --- a/src/app_modules/investasi/detail_saham_terbeli/view.tsx +++ b/src/app_modules/investasi/detail_saham_terbeli/view.tsx @@ -31,13 +31,14 @@ import { useRouter } from "next/navigation"; import { MODEL_Transaksi_Investasi } from "../model/model_investasi"; import { useState } from "react"; import moment from "moment"; +import _ from "lodash"; export default function DetailSahamTerbeli({ dataTransaksi, - investor + investor, }: { dataTransaksi: MODEL_Transaksi_Investasi; - investor: number + investor: number; }) { const router = useRouter(); const [investasi, setINvestasi] = useState(dataTransaksi); @@ -61,11 +62,20 @@ export default function DetailSahamTerbeli({ route: RouterInvestasi.berita, }, ]; + return ( <> - + + {(() => { + const usr = investasi.Investasi.author.username; + const splt = usr.split(""); + const Up = _.upperCase(splt[0]); + + return Up; + })()} + {investasi.Investasi.author.username} {(() => { @@ -86,15 +96,53 @@ export default function DetailSahamTerbeli({ return ( <> - Sisa waktu: - - {Number(investasi.Investasi.MasterPencarianInvestor.name) - - moment(new Date()).diff( - new Date(investasi.Investasi.countDown), - "days" - )}{" "} - Hari - + {(() => { + if ( + Number(investasi.Investasi.MasterPencarianInvestor.name) - + moment(new Date()).diff( + new Date(investasi.Investasi.countDown), + "days" + ) <= + 0 + ) { + return ( + <> + + + + Waktu Habis + + + + ); + } else { + return ( + <> + + Sisa waktu: + + {Number( + investasi.Investasi.MasterPencarianInvestor.name + ) - + moment(new Date()).diff( + new Date(investasi.Investasi.countDown), + "days" + )} + + Hari + + + ); + } + })()} ); @@ -105,7 +153,10 @@ export default function DetailSahamTerbeli({ {/* Gambar Investasi */} - + @@ -115,26 +166,28 @@ export default function DetailSahamTerbeli({ {investasi.Investasi.title} + label={ + "" + + ( + ((+investasi.Investasi.totalLembar - + +investasi.Investasi.sisaLembar) / + +investasi.Investasi.totalLembar) * + 100 + ).toFixed(1) + + "%" + } + value={ + +( + ((+investasi.Investasi.totalLembar - + +investasi.Investasi.sisaLembar) / + +investasi.Investasi.totalLembar) * + 100 + ).toFixed(2) + } + color="teal" + size="xl" + radius="xl" + /> {/* Rincian Data */} @@ -147,19 +200,27 @@ export default function DetailSahamTerbeli({ */} Dana Dibutuhkan - Rp. {new Intl.NumberFormat("id-ID", { + + Rp.{" "} + {new Intl.NumberFormat("id-ID", { maximumSignificantDigits: 10, - }).format(+investasi.Investasi.targetDana)} + }).format(+investasi.Investasi.targetDana)} + Harga Per Lembar - Rp. {new Intl.NumberFormat("id-ID", { + + Rp.{" "} + {new Intl.NumberFormat("id-ID", { maximumSignificantDigits: 10, - }).format(+investasi.Investasi.hargaLembar)} + }).format(+investasi.Investasi.hargaLembar)} + Jadwal Pembagian - {investasi.Investasi.MasterPembagianDeviden.name} bulan + + {investasi.Investasi.MasterPembagianDeviden.name} bulan{" "} + Pembagian Deviden @@ -171,7 +232,7 @@ export default function DetailSahamTerbeli({ Investor - {investor} pengguna + {new Intl.NumberFormat("id-ID", {maximumSignificantDigits: 10}).format(investor)} ROI @@ -179,15 +240,21 @@ export default function DetailSahamTerbeli({ Total Lembar - {new Intl.NumberFormat("id-ID", { + + {new Intl.NumberFormat("id-ID", { maximumSignificantDigits: 10, - }).format(+investasi.Investasi.totalLembar)} lembar + }).format(+investasi.Investasi.totalLembar)}{" "} + lembar + Sisa Lembar - {new Intl.NumberFormat("id-ID", { + + {new Intl.NumberFormat("id-ID", { maximumSignificantDigits: 10, - }).format(+investasi.Investasi.sisaLembar)} lembar + }).format(+investasi.Investasi.sisaLembar)}{" "} + lembar + @@ -205,9 +272,12 @@ export default function DetailSahamTerbeli({ Total Pembelian - Rp. {new Intl.NumberFormat("id-ID", { - maximumSignificantDigits: 10, - }).format(+investasi.gross_amount)} + + Rp.{" "} + {new Intl.NumberFormat("id-ID", { + maximumSignificantDigits: 10, + }).format(+investasi.gross_amount)} + @@ -215,9 +285,12 @@ export default function DetailSahamTerbeli({ Lembar Dibeli - {new Intl.NumberFormat("id-ID", { - maximumSignificantDigits: 10, - }).format(+investasi.quantity)} lembar + + {new Intl.NumberFormat("id-ID", { + maximumSignificantDigits: 10, + }).format(+investasi.quantity)}{" "} + lembar + diff --git a/src/app_modules/investasi/fun/fun_total_investor_by_id.ts b/src/app_modules/investasi/fun/fun_total_investor_by_id.ts index 8eb8febe..486223ee 100644 --- a/src/app_modules/investasi/fun/fun_total_investor_by_id.ts +++ b/src/app_modules/investasi/fun/fun_total_investor_by_id.ts @@ -2,7 +2,7 @@ import prisma from "@/app/lib/prisma"; -export default async function funTotalInvestorByIdInvestasi(id: string) { +export default async function funTotalInvestorByIdInvestasi(id: any) { // console.log(id) const data = await prisma.transaksiInvestasi.count({ where: { diff --git a/src/app_modules/investasi/fun/get_list_all_publish.ts b/src/app_modules/investasi/fun/get_list_all_publish.ts index 25c4e1ea..6751508f 100644 --- a/src/app_modules/investasi/fun/get_list_all_publish.ts +++ b/src/app_modules/investasi/fun/get_list_all_publish.ts @@ -5,7 +5,7 @@ import prisma from "@/app/lib/prisma"; export async function getListAllPublish() { const data = await prisma.investasi.findMany({ orderBy: { - updatedAt: "desc", + countDown: "asc", }, where: { MasterStatusInvestasi: { diff --git a/src/app_modules/investasi/fun/get_list_transaksi_berhasil_by_id.ts b/src/app_modules/investasi/fun/get_list_transaksi_berhasil_by_id.ts index 894eb092..4c8650a2 100644 --- a/src/app_modules/investasi/fun/get_list_transaksi_berhasil_by_id.ts +++ b/src/app_modules/investasi/fun/get_list_transaksi_berhasil_by_id.ts @@ -7,7 +7,7 @@ export default async function getListTransaksiBerhasilInvestasi( ) { const data = await prisma.transaksiInvestasi.findMany({ orderBy: { - createdAt: "desc" + createdAt: "desc", }, where: { authorId: idAuthor, @@ -15,7 +15,16 @@ export default async function getListTransaksiBerhasilInvestasi( }, select: { id: true, - Investasi: true, + Investasi: { + select: { + author: true, + imagesId: true, + title: true, + totalLembar: true, + sisaLembar: true, + + }, + }, Author: true, gross_amount: true, quantity: true, diff --git a/src/app_modules/investasi/fun/get_token_transaksi.js b/src/app_modules/investasi/fun/get_token_transaksi.js index 87200106..2affe0ab 100644 --- a/src/app_modules/investasi/fun/get_token_transaksi.js +++ b/src/app_modules/investasi/fun/get_token_transaksi.js @@ -3,14 +3,6 @@ import prisma from "@/app/lib/prisma"; import MidTrans from "midtrans-client"; -// const midtransClient = require("midtrans-client"); - -// const snap = new midtransClient.Snap({ -// isProduction: false, -// serverKey: process.env.Server_KEY, -// clientKey: process.env.Client_KEY, -// }); - const snap = new MidTrans.Snap({ isProduction: false, serverKey: process.env.Server_KEY, @@ -58,14 +50,14 @@ export default async function getTokenTransaksi(data) { free_text: { inquiry: [ { - en: "text in English", - id: "text in Bahasa Indonesia", + en: "Pay according to the invoice", + id: "Bayar sesuai faktur", }, ], payment: [ { - en: "text in English", - id: "text in Bahasa Indonesia", + en: "Pay according to the invoice", + id: "Bayar sesuai faktur", }, ], }, diff --git a/src/app_modules/investasi/index.ts b/src/app_modules/investasi/index.ts index 9d6a0911..febf9db1 100644 --- a/src/app_modules/investasi/index.ts +++ b/src/app_modules/investasi/index.ts @@ -46,7 +46,7 @@ import CreateBeritaInvestasi from "./create_berita/view"; import LayoutCreateBeritaInvestasi from "./create_berita/layout"; import ListEditBeritaInvestasi from "./list_edit_berita/view"; import LayoutListEditBeritaInvestasi from "./list_edit_berita/layout"; -import InvestasiSahamTerbeli from "./main/saham_saya"; +import InvestasiSahamTerbeli from "./saham_saya/saham_saya"; import DetailDraftInvestasi from "./detail_portofolio/draft/page"; import LayoutDetailDraftInvestasi from "./detail_portofolio/draft/layout"; import DetailReviewInvestasi from "./detail_portofolio/review/page"; diff --git a/src/app_modules/investasi/main/saham_saya.tsx b/src/app_modules/investasi/main/saham_saya.tsx deleted file mode 100644 index 70a1a639..00000000 --- a/src/app_modules/investasi/main/saham_saya.tsx +++ /dev/null @@ -1,152 +0,0 @@ -"use client"; - -import { RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; -import { - Title, - Card, - CardSection, - Group, - Flex, - Avatar, - AspectRatio, - Box, - Slider, - Grid, - Stack, - Divider, - Badge, - Image, - Text, - Button, - Paper, - Progress, - Center, -} from "@mantine/core"; -import { IconCircleCheck } from "@tabler/icons-react"; -import moment from "moment"; -import { useRouter } from "next/navigation"; -import dataDummy from "../dummy/data_dummy.json"; -import { MODEL_Transaksi_Investasi } from "../model/model_investasi"; -import { useState } from "react"; -import { Warna } from "@/app/lib/warna"; - -export default function InvestasiSahamTerbeli({ - listTransaksi, -}: { - listTransaksi: MODEL_Transaksi_Investasi[]; -}) { - const router = useRouter(); - const [investasi, setInvestasi] = useState(listTransaksi); - - return ( - <> - {/* {investasi.map((e) => ( - - - - - {e.Investasi.imagesId ? ( - - ) : ( - - )} - - - - - - - -
- {e.Investasi.title} -
- -
-
- - - - - Saham Terbeli : - {new Intl.NumberFormat("id-ID", {maximumFractionDigits: 10}).format(+ e.quantity)} Lembar - - - Total Pembelian : - Rp. {new Intl.NumberFormat("id-ID", {maximumFractionDigits: 10}).format(+ e.gross_amount)} - - - - - - - - - -
- ))} */} - - - - - - Username - - - - - -
- Judul Investasi -
- - -
- - -
- - ); -} diff --git a/src/app_modules/investasi/main/view.tsx b/src/app_modules/investasi/main/view.tsx index ea1472cc..11d16a3b 100644 --- a/src/app_modules/investasi/main/view.tsx +++ b/src/app_modules/investasi/main/view.tsx @@ -46,7 +46,7 @@ export default function MainInvestasi({ }) { const router = useRouter(); const [investasi, setInvestasi] = useState(listData); - const [progres, setProgres] = useState(0); + const [statusPublish, setStatusPublish] = useState(false); async function onProgres(data: MODEL_Investasi) { // console.log(data) @@ -59,6 +59,14 @@ export default function MainInvestasi({ return progres; } + // useShallowEffect(() => { + // onStatusPublish(investasi) + // },[investasi]) + + // async function onStatusPublish(investasi : MODEL_Investasi[]) { + + // } + if (_.isEmpty(investasi)) return ( <> @@ -85,7 +93,10 @@ export default function MainInvestasi({ {e.imagesId ? ( - + ) : ( )} @@ -110,7 +121,7 @@ export default function MainInvestasi({ +( ((+e.totalLembar - +e.sisaLembar) / +e.totalLembar) * 100 - ).toFixed(2) + ).toFixed(1) } color="teal" size="xl" @@ -122,41 +133,45 @@ export default function MainInvestasi({ - - - Dana Dibutuhkan - - Rp.{" "} - {new Intl.NumberFormat("id-ID", { - maximumSignificantDigits: 10, - }).format(+e.targetDana)} - - - - Harga Per Lembar - - Rp.{" "} - {new Intl.NumberFormat("id-ID", { - maximumSignificantDigits: 10, - }).format(+e.hargaLembar)} - {/* {e.hargaLembar} */} - - - +
+ + + Dana Dibutuhkan + + Rp.{" "} + {new Intl.NumberFormat("id-ID", { + maximumSignificantDigits: 10, + }).format(+e.targetDana)} + + + + Harga Per Lembar + + Rp.{" "} + {new Intl.NumberFormat("id-ID", { + maximumSignificantDigits: 10, + }).format(+e.hargaLembar)} + {/* {e.hargaLembar} */} + + + +
- - - ROI - {e.roi}% - - - Sisa Lembar - - {new Intl.NumberFormat("id-ID").format(+e.sisaLembar)} - - - +
+ + + ROI + {e.roi}% + + + Sisa Lembar + + {new Intl.NumberFormat("id-ID").format(+e.sisaLembar)} + + + +
@@ -194,6 +209,7 @@ export default function MainInvestasi({ - Sisa waktu: - + Sisa waktu: + {Number(e.MasterPencarianInvestor.name) - moment(new Date()).diff( new Date(e.countDown), "days" )} - Hari + Hari ); diff --git a/src/app_modules/investasi/proses_transaksi/view.jsx b/src/app_modules/investasi/proses_transaksi/view.jsx index 37e2c9d8..81faf4f9 100644 --- a/src/app_modules/investasi/proses_transaksi/view.jsx +++ b/src/app_modules/investasi/proses_transaksi/view.jsx @@ -9,6 +9,8 @@ import { Center, Button, Text, + Container, + Flex, } from "@mantine/core"; import { useFocusTrap } from "@mantine/hooks"; import { useRouter } from "next/navigation"; @@ -34,6 +36,7 @@ export default function ProsesTransaksiInvestasi({ dataInvestasi, userLogin }) { const [total, setTotal] = useState(0); const [jumlah, setJumlah] = useState(0); const [hotmenu, setHotmenu] = useAtom(gs_investasiFooter); + const [snapShow, setSnapShow] = useState(false); // console.log(userLogin.id); // console.log(investasi); @@ -58,13 +61,17 @@ export default function ProsesTransaksiInvestasi({ dataInvestasi, userLogin }) { await getTokenTransaksi(body).then(async (res) => { if (res.token.status === 200) { // console.log(res.token.value.token) - snap.pay(res.token.value.token, { + setSnapShow(true); + snap.embed(res.token.value.token, { + embedId: "embedId", onSuccess: async function (result) { console.log(result); // console.log("success"); + setSnapShow(false); + await funUpdatePaymentInvestasi(result, res.dataTransaksi.id).then( - async (resUp) => { - if (resUp.status === 200) { + async (resUpdate) => { + if (resUpdate.status === 200) { const hasil = investasi.sisaLembar - res.dataTransaksi.quantity; @@ -85,7 +92,8 @@ export default function ProsesTransaksiInvestasi({ dataInvestasi, userLogin }) { }, onPending: async function (result) { await funUpdatePaymentInvestasi(result, res.dataTransaksi.id); - router.push(RouterInvestasi.main_transaksi); + router.push(RouterInvestasi.proses_transaksi + `${investasi.id}`); + setSnapShow(false); console.log("pending"); console.log(result); @@ -93,6 +101,7 @@ export default function ProsesTransaksiInvestasi({ dataInvestasi, userLogin }) { onError: async function (result) { await funUpdatePaymentInvestasi(result, res.dataTransaksi.id); router.push(RouterInvestasi.main_transaksi); + setSnapShow(false); console.log("error"); console.log(result); @@ -104,7 +113,7 @@ export default function ProsesTransaksiInvestasi({ dataInvestasi, userLogin }) { }; await funUpdatePaymentInvestasi(data, res.dataTransaksi.id); router.push(RouterInvestasi.main_transaksi); - + setSnapShow(false); // router.push(RouterPay.home); console.log(data); } @@ -134,85 +143,89 @@ export default function ProsesTransaksiInvestasi({ dataInvestasi, userLogin }) { return ( <> - - {/* Sisa Lembar Saham */} - - Sisa Lembar Saham - - {new Intl.NumberFormat("id-ID", { - maximumFractionDigits: 10, - }).format(+investasi.sisaLembar)}{" "} - - - - {/* Harga perlembar saham */} - - Harga Perlembar - - Rp.{" "} - {new Intl.NumberFormat("id-ID", { - maximumFractionDigits: 10, - }).format(+investasi.hargaLembar)}{" "} - - - - {/* Lembar saham */} - - - Jumlah Pembelian - - minimal pembelian 10 lembar + {!snapShow && ( + + {/* Sisa Lembar Saham */} + + Sisa Lembar Saham + + {new Intl.NumberFormat("id-ID", { + maximumFractionDigits: 10, + }).format(+investasi.sisaLembar)}{" "} - {/* - maximal pembelian {maxPembelian} lembar - */} - - { - setTotal(val * +investasi.hargaLembar); - setJumlah(val); - // console.log(val); - }} - /> - + - + {/* Harga perlembar saham */} + + Harga Perlembar + + Rp.{" "} + {new Intl.NumberFormat("id-ID", { + maximumFractionDigits: 10, + }).format(+investasi.hargaLembar)}{" "} + + - - - Total Harga - - - Rp.{" "} - {new Intl.NumberFormat("id-ID", { - maximumFractionDigits: 10, - }).format(total)} - - - -
- {jumlah < 10 ? ( - - ) : ( - - )} -
-
+ /> +
+ + + + + + Total Harga + + + Rp.{" "} + {new Intl.NumberFormat("id-ID", { + maximumFractionDigits: 10, + }).format(total)} + + + +
+ {jumlah < 10 ? ( + + ) : ( + + )} +
+ + )} + + ); } diff --git a/src/app_modules/investasi/saham_saya/saham_saya.tsx b/src/app_modules/investasi/saham_saya/saham_saya.tsx new file mode 100644 index 00000000..56d379c4 --- /dev/null +++ b/src/app_modules/investasi/saham_saya/saham_saya.tsx @@ -0,0 +1,174 @@ +"use client"; + +import { RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi"; +import { + Title, + Card, + CardSection, + Group, + Flex, + Avatar, + AspectRatio, + Box, + Slider, + Grid, + Stack, + Divider, + Badge, + Image, + Text, + Button, + Paper, + Progress, + Center, + SimpleGrid, +} from "@mantine/core"; +import { IconCircleCheck } from "@tabler/icons-react"; +import moment from "moment"; +import { useRouter } from "next/navigation"; +import dataDummy from "../dummy/data_dummy.json"; +import { MODEL_Transaksi_Investasi } from "../model/model_investasi"; +import { useState } from "react"; +import { Warna } from "@/app/lib/warna"; +import _ from "lodash"; + +export default function InvestasiSahamTerbeli({ + listTransaksi, +}: { + listTransaksi: MODEL_Transaksi_Investasi[]; +}) { + const router = useRouter(); + const [transaksi, setTransaksi] = useState(listTransaksi); + + if (_.isEmpty(transaksi)) { + return ( + <> +
+ Saham Anda Kosong +
+ + ); + } + + return ( + <> + + {transaksi.map((e) => ( + + + + + + {(() => { + const usr = e.Investasi.author.username; + const splt = usr.split(""); + const Up = _.upperCase(splt[0]); + + return Up; + })()} + + {e.Investasi.author.username} + + + + + + + + + +
+ + {e.Investasi.title} + +
+ +
+ + + + + Lembar Saham: + + {new Intl.NumberFormat("id-ID", { + maximumFractionDigits: 10, + }).format(+e.quantity)} + + + + Total: + + Rp.{" "} + {new Intl.NumberFormat("id-ID", { + maximumFractionDigits: 10, + }).format(+e.gross_amount)} + + + + + + + + {e.Investasi.imagesId ? ( + + ) : ( + + )} + + + + +
+ +
+
+ ))} +
+ + ); +} diff --git a/src/app_modules/investasi/transaksi/view.tsx b/src/app_modules/investasi/transaksi/view.tsx index 415130e3..e720ae68 100644 --- a/src/app_modules/investasi/transaksi/view.tsx +++ b/src/app_modules/investasi/transaksi/view.tsx @@ -59,7 +59,7 @@ export default function TransaksiInvestasi({ return ( <>
- Tidak Ada Transaksi + Tidak Ada Transaksi
);