From b209a12315a515e1c31106ae84066e8e20bc2e65 Mon Sep 17 00:00:00 2001 From: bagasbanuna Date: Thu, 30 Oct 2025 17:41:59 +0800 Subject: [PATCH 1/2] Mobile Api: Admin investasi Add: - src/app/api/mobile/admin/investment/ Fix: - src/app/api/mobile/investment/route.ts ### No Issue --- .../admin/investment/[id]/investor/route.ts | 70 +++++++++ .../admin/investment/[id]/invoice/route.ts | 45 ++++++ .../api/mobile/admin/investment/[id]/route.ts | 137 ++++++++++++++++++ src/app/api/mobile/admin/investment/route.ts | 104 +++++++++++++ src/app/api/mobile/investment/route.ts | 1 + 5 files changed, 357 insertions(+) create mode 100644 src/app/api/mobile/admin/investment/[id]/investor/route.ts create mode 100644 src/app/api/mobile/admin/investment/[id]/invoice/route.ts create mode 100644 src/app/api/mobile/admin/investment/[id]/route.ts create mode 100644 src/app/api/mobile/admin/investment/route.ts diff --git a/src/app/api/mobile/admin/investment/[id]/investor/route.ts b/src/app/api/mobile/admin/investment/[id]/investor/route.ts new file mode 100644 index 00000000..7a5f0d45 --- /dev/null +++ b/src/app/api/mobile/admin/investment/[id]/investor/route.ts @@ -0,0 +1,70 @@ +import _ from "lodash"; +import { NextResponse } from "next/server"; +import prisma from "@/lib/prisma"; + +export async function GET( + request: Request, + { params }: { params: { id: string } } +) { + try { + let fixData; + const { id } = params; + const { searchParams } = new URL(request.url); + const page = searchParams.get("page"); + const status = searchParams.get("status"); + const takeData = 10; + const skipData = Number(page) * takeData - takeData; + + const fixStatus = _.startCase(status ? status : ""); + + const checkStatus = await prisma.investasiMaster_StatusInvoice.findFirst({ + where: { + name: fixStatus, + }, + }); + + const data = await prisma.investasi_Invoice.findMany({ + take: page ? takeData : undefined, + skip: page ? skipData : undefined, + orderBy: { + createdAt: "desc", + }, + where: { + investasiId: id, + isActive: true, + StatusInvoice: { + name: { + contains: checkStatus?.name, + mode: "insensitive", + }, + }, + }, + select: { + id: true, + Author: true, + StatusInvoice: true, + }, + }); + + fixData = data; + + return NextResponse.json( + { + success: true, + message: "Success get status transaksi", + data: fixData, + }, + { status: 200 } + ); + } catch (error) { + console.error("Eror get status transaksi", error); + return NextResponse.json( + { + success: false, + message: "Error get status transaksi", + reason: (error as Error).message, + }, + { status: 500 } + ); + } +} diff --git a/src/app/api/mobile/admin/investment/[id]/invoice/route.ts b/src/app/api/mobile/admin/investment/[id]/invoice/route.ts new file mode 100644 index 00000000..4fc0a4aa --- /dev/null +++ b/src/app/api/mobile/admin/investment/[id]/invoice/route.ts @@ -0,0 +1,45 @@ +import { NextResponse } from "next/server"; +import { prisma } from "@/lib"; + +export { GET }; + +async function GET(req: Request, { params }: { params: { id: string } }) { + const { id } = params; + + try { + const data = await prisma.investasi_Invoice.findUnique({ + where: { + id: id, + }, + select: { + id: true, + investasiId: true, + nominal: true, + createdAt: true, + Author: true, + StatusInvoice: true, + imageId: true, + MasterBank: true, + }, + }); + + return NextResponse.json( + { + success: true, + message: "Berhasil mendapatkan data", + data: data, + }, + { status: 200 } + ); + } catch (error) { + console.log("[ERROR]", error); + return NextResponse.json( + { + success: false, + message: "Error get detail Investasi", + reason: (error as Error).message, + }, + { status: 500 } + ); + } +} diff --git a/src/app/api/mobile/admin/investment/[id]/route.ts b/src/app/api/mobile/admin/investment/[id]/route.ts new file mode 100644 index 00000000..af81a5b7 --- /dev/null +++ b/src/app/api/mobile/admin/investment/[id]/route.ts @@ -0,0 +1,137 @@ +import { NextResponse } from "next/server"; +import { prisma } from "@/lib"; + +export { GET, PUT }; + +async function GET(request: Request, { params }: { params: { id: string } }) { + const { id } = params; + + try { + const data = await prisma.investasi.findUnique({ + where: { + id: id, + }, + select: { + imageId: true, + prospektusFileId: true, + id: true, + author: { + select: { + id: true, + username: true, + nomor: true, + Profile: true, + }, + }, + title: true, + authorId: true, + hargaLembar: true, + targetDana: true, + totalLembar: true, + sisaLembar: true, + lembarTerbeli: true, + progress: true, + roi: true, + active: true, + createdAt: true, + updatedAt: true, + catatan: true, + imagesId: true, + MasterStatusInvestasi: true, + BeritaInvestasi: true, + DokumenInvestasi: true, + ProspektusInvestasi: true, + MasterPembagianDeviden: true, + MasterPencarianInvestor: true, + MasterPeriodeDeviden: true, + MasterProgresInvestasi: true, + masterStatusInvestasiId: true, + Investasi_Invoice: { + where: { + statusInvoiceId: "1", + }, + }, + countDown: true, + }, + }); + + return NextResponse.json( + { + success: true, + message: "Success get data investment", + data: data, + }, + { status: 200 } + ); + } catch (error) { + return NextResponse.json( + { + success: false, + message: "Error get data investment", + reason: (error as Error).message, + }, + { status: 500 } + ); + } +} + +async function PUT(request: Request, { params }: { params: { id: string } }) { + const { id } = params; + const { data } = await request.json(); + const { searchParams } = new URL(request.url); + const status = searchParams.get("status"); + + console.log("[=======Start Investment console=======]") + console.log("[ID]", id); + console.log("[DATA]", data); + console.log("[STATUS]", status); + console.log("[=======End Investment console=======]") + + const publishTime = new Date(); + + try { + if (status === "reject") { + const updatedData = await prisma.investasi.update({ + where: { + id: id, + }, + data: { + catatan: data, + masterStatusInvestasiId: "4", + }, + }); + + console.log("[UPDATE REJECT]", updatedData); + } else if (status === "publish") { + const updatedData = await prisma.investasi.update({ + where: { + id: id, + }, + data: { + masterStatusInvestasiId: "1", + masterProgresInvestasiId: "1", + countDown: publishTime, + }, + }); + + console.log("[UPDATE PUBLISH]", updatedData); + } + + return NextResponse.json( + { + success: true, + message: "Success update data investment", + }, + { status: 200 } + ); + } catch (error) { + return NextResponse.json( + { + success: false, + message: "Error update data investment", + reason: (error as Error).message, + }, + { status: 500 } + ); + } +} diff --git a/src/app/api/mobile/admin/investment/route.ts b/src/app/api/mobile/admin/investment/route.ts new file mode 100644 index 00000000..e0548821 --- /dev/null +++ b/src/app/api/mobile/admin/investment/route.ts @@ -0,0 +1,104 @@ +import _ from "lodash"; +import { NextResponse } from "next/server"; +import { prisma } from "@/lib"; + +export { GET }; + +async function GET(request: Request) { + const { searchParams } = new URL(request.url); + const category = searchParams.get("category"); + const search = searchParams.get("search"); + const page = searchParams.get("page"); + const takeData = 10; + const skipData = Number(page) * takeData - takeData; + + console.log("[CATEGORY]", category); + console.log("[PAGE]", page); + + let fixData; + try { + if (category === "dashboard") { + const publish = await prisma.investasi.count({ + where: { + MasterStatusInvestasi: { + name: "Publish", + }, + }, + }); + + const review = await prisma.investasi.count({ + where: { + MasterStatusInvestasi: { + name: "Review", + }, + }, + }); + + const reject = await prisma.investasi.count({ + where: { + MasterStatusInvestasi: { + name: "Reject", + }, + }, + }); + + fixData = { + publish, + review, + reject, + }; + } else { + const fixCategoryToStatus = _.startCase(category || ""); + console.log("[STATUS]", fixCategoryToStatus); + + const data = await prisma.investasi.findMany({ + take: page ? takeData : undefined, + skip: page ? skipData : undefined, + orderBy: { + updatedAt: "desc", + }, + where: { + active: true, + MasterStatusInvestasi: { + name: fixCategoryToStatus, + }, + title: { + contains: search || "", + mode: "insensitive", + }, + }, + select: { + id: true, + title: true, + author: { + select: { + id: true, + username: true, + }, + }, + }, + }); + + fixData = data; + } + + return NextResponse.json( + { + success: true, + message: "Success get data investment", + data: fixData, + }, + { status: 200 } + ); + } catch (error) { + console.error("[ERROR GET DATA INVESTMENT]", error); + return NextResponse.json( + { + success: false, + message: "Error get data investment", + reason: (error as Error).message, + }, + { status: 500 } + ); + } +} diff --git a/src/app/api/mobile/investment/route.ts b/src/app/api/mobile/investment/route.ts index 1970c724..c05e30af 100644 --- a/src/app/api/mobile/investment/route.ts +++ b/src/app/api/mobile/investment/route.ts @@ -4,6 +4,7 @@ import prisma from "@/lib/prisma"; import moment from "moment"; export { POST, GET }; + async function POST(request: Request) { const { data } = await request.json(); console.log(["DATA INVESTASI"], data); -- 2.49.1 From a278470dbbdf01ff36c74aaf9163f2455058b76d Mon Sep 17 00:00:00 2001 From: bagasbanuna Date: Thu, 30 Oct 2025 17:42:07 +0800 Subject: [PATCH 2/2] chore(release): 1.5.9 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0fa35c1..248c7df6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines. +## [1.5.9](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.8...v1.5.9) (2025-10-30) + ## [1.5.8](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.7...v1.5.8) (2025-10-29) ## [1.5.7](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.6...v1.5.7) (2025-10-28) diff --git a/package.json b/package.json index cf44c061..3eee853e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hipmi", - "version": "1.5.8", + "version": "1.5.9", "private": true, "prisma": { "seed": "bun prisma/seed.ts" -- 2.49.1