diff --git a/src/app/api/new/investasi/[id]/route.ts b/src/app/api/new/investasi/[id]/route.ts new file mode 100644 index 00000000..ef327393 --- /dev/null +++ b/src/app/api/new/investasi/[id]/route.ts @@ -0,0 +1,39 @@ +import { prisma } from "@/app/lib"; +import { NextResponse } from "next/server"; +export const dynamic = "force-dynamic"; + + + +// GET ONE DATA INVESTASI BY ID +export async function GET(request: Request, context: { params: { id: string } }) { + try { + const { id } = context.params + const data = await prisma.investasi.findUnique({ + where: { + id: id, + }, + select: { + id: true, + title: true, + targetDana: true, + hargaLembar: true, + totalLembar: true, + roi: true, + countDown: true, + catatan: true, + sisaLembar: true, + imageId: true, + masterPencarianInvestorId: true, + masterPeriodeDevidenId: true, + masterPembagianDevidenId: true, + } + }); + + return NextResponse.json({ success: true, message: "Berhasil mendapatkan data", data }, { status: 200 }); + + } + catch (error) { + console.error(error); + return NextResponse.json({ success: false, message: "Gagal mendapatkan data, coba lagi nanti ", reason: (error as Error).message, }, { status: 500 }); + } +} \ No newline at end of file diff --git a/src/app/dev/investasi/edit/[id]/page.tsx b/src/app/dev/investasi/edit/[id]/page.tsx index 5d91e4d2..a81633bb 100644 --- a/src/app/dev/investasi/edit/[id]/page.tsx +++ b/src/app/dev/investasi/edit/[id]/page.tsx @@ -1,39 +1,39 @@ import { investasi_funGetOneInvestasiById } from "@/app_modules/investasi/_fun"; -import { Investasi_UiEditInvestasi } from "@/app_modules/investasi/_ui"; +import { Investasi_UiEditInvestasi, Investasi_UiEditInvestasiNew } 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 investasiId = params.id; - const allData = await investasi_funGetOneInvestasiById({ investasiId }); - const dataInvestasi = _.omit(allData, [ - "BeritaInvestasi", - "DokumenInvestasi", - "MasterPembagianDeviden", - "MasterPencarianInvestor", - "MasterProgresInvestasi", - "MasterStatusInvestasi", - "ProspektusInvestasi", - "MasterPeriodeDeviden", - "author", - ]); + // 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(); + // const listPencarian = await getPencarianInvestor(); + // const listPeriode = await getPeriodeDeviden(); + // const listPembagian = await getPembagianDeviden(); return ( <> - + /> */} + ); } 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 index 5556c207..c2cc815e 100644 --- a/src/app_modules/investasi/_component/button/comp_button_update_investasi.tsx +++ b/src/app_modules/investasi/_component/button/comp_button_update_investasi.tsx @@ -25,6 +25,7 @@ export function Investasi_ComponentButtonUpdateDataInvestasi({ const [isLoading, setIsLoading] = useState(false); async function onUpdate() { + setIsLoading(true); if (totalLembar === "0") return ComponentGlobal_NotifikasiPeringatan("Total lembar kosong"); @@ -74,6 +75,8 @@ export function Investasi_ComponentButtonUpdateDataInvestasi({ return ( + )} + + + + + + { + setData({ + ...data as any, + title: val.target.value, + }); + }} + /> + + Rp.} + min={0} + withAsterisk + label="Dana Dibutuhkan" + placeholder="0" + value={target ? target : data?.targetDana} + onChange={(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: +Number(data?.hargaLembar), + }); + + setTarget(targetNilai); + setData({ + ...data as any, + targetDana: nilai as string, + }); + }} + /> + + Rp.} + min={0} + withAsterisk + label="Harga Per Lembar" + placeholder="0" + value={harga ? harga : data?.hargaLembar} + onChange={(val) => { + try { + 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: +Number(data?.targetDana), + }); + + setHarga(targetNilai); + setData({ + ...data as any, + 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 as any, + roi: val.target.value, + }); + }} + /> + + ({ value: e.id, label: e.name }))} + value={data?.masterPeriodeDevidenId} + onChange={(val) => { + setData({ + ...(data as any), + masterPeriodeDevidenId: val, + }); + }} + /> + +