Merge pull request 'mobile-api/3-nov-25' (#7) from mobile-api/3-nov-25 into staging
Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi/pulls/7
This commit is contained in:
@@ -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.10](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.9...v1.5.10) (2025-11-03)
|
||||
|
||||
## [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,6 +1,6 @@
|
||||
{
|
||||
"name": "hipmi",
|
||||
"version": "1.5.9",
|
||||
"version": "1.5.10",
|
||||
"private": true,
|
||||
"prisma": {
|
||||
"seed": "bun prisma/seed.ts"
|
||||
|
||||
@@ -65,10 +65,10 @@ async function PUT(req: Request, { params }: { params: { id: string } }) {
|
||||
data: {
|
||||
statusInvoiceId: "4",
|
||||
},
|
||||
select: {
|
||||
StatusInvoice: true,
|
||||
authorId: true,
|
||||
},
|
||||
// select: {
|
||||
// StatusInvoice: true,
|
||||
// authorId: true,
|
||||
// },
|
||||
});
|
||||
|
||||
fixData = updt;
|
||||
|
||||
@@ -5,7 +5,7 @@ export { GET, PUT };
|
||||
|
||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
|
||||
|
||||
try {
|
||||
const data = await prisma.investasi.findUnique({
|
||||
where: {
|
||||
@@ -49,9 +49,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
countDown: true,
|
||||
Investasi_Invoice: {
|
||||
where: {
|
||||
statusInvoiceId: {
|
||||
in: ["1", "2", "3", "4"],
|
||||
},
|
||||
statusInvoiceId: "2",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -83,11 +81,11 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const status = searchParams.get("status");
|
||||
|
||||
console.log("[=======Start Investment console=======]")
|
||||
console.log("[=======Start Investment console=======]");
|
||||
console.log("[ID]", id);
|
||||
console.log("[DATA]", data);
|
||||
console.log("[STATUS]", status);
|
||||
console.log("[=======End Investment console=======]")
|
||||
console.log("[=======End Investment console=======]");
|
||||
|
||||
const publishTime = new Date();
|
||||
|
||||
|
||||
48
src/app/api/mobile/investment/[id]/investor/route.ts
Normal file
48
src/app/api/mobile/investment/[id]/investor/route.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export { GET };
|
||||
|
||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
|
||||
try {
|
||||
const data = await prisma.investasi_Invoice.findMany({
|
||||
where: {
|
||||
investasiId: id,
|
||||
statusInvoiceId: "1",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
nominal: true,
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
imageId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
status: 200,
|
||||
success: true,
|
||||
message: "Berhasil Mendapatkan Data",
|
||||
data: data,
|
||||
});
|
||||
} catch (error) {
|
||||
return NextResponse.json({
|
||||
status: 500,
|
||||
success: false,
|
||||
message: "Error Mendapatkan Data",
|
||||
reason: (error as Error).message,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,9 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
const category = searchParams.get("category");
|
||||
const authorId = searchParams.get("authorId");
|
||||
|
||||
console.log("[ID INVOICE]", id);
|
||||
|
||||
|
||||
let fixData;
|
||||
|
||||
try {
|
||||
@@ -80,6 +83,8 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[DATA INVOICE]", data ? true : false);
|
||||
|
||||
const { ...allData } = data;
|
||||
const Investor = data?.Investasi?.Investasi_Invoice;
|
||||
fixData = { ...allData, Investor };
|
||||
|
||||
@@ -17,7 +17,11 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
Investasi_Invoice: true,
|
||||
Investasi_Invoice: {
|
||||
where: {
|
||||
statusInvoiceId: "1"
|
||||
}
|
||||
},
|
||||
MasterStatusInvestasi: true,
|
||||
BeritaInvestasi: true,
|
||||
DokumenInvestasi: true,
|
||||
|
||||
@@ -47,82 +47,112 @@ async function POST(request: Request) {
|
||||
}
|
||||
|
||||
async function GET(request: Request) {
|
||||
let fixData;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const category = searchParams.get("category");
|
||||
const authorId = searchParams.get("authorId");
|
||||
|
||||
console.log("[CATEGORY]", category);
|
||||
console.log("[AUTHOR ID]", authorId);
|
||||
let fixData;
|
||||
try {
|
||||
const data = await prisma.investasi.findMany({
|
||||
where: {
|
||||
masterStatusInvestasiId: "1",
|
||||
masterProgresInvestasiId: "1",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
MasterPencarianInvestor: true,
|
||||
countDown: true,
|
||||
progress: true,
|
||||
},
|
||||
});
|
||||
if (category === "bursa") {
|
||||
const data = await prisma.investasi.findMany({
|
||||
where: {
|
||||
masterStatusInvestasiId: "1",
|
||||
masterProgresInvestasiId: "1",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
MasterPencarianInvestor: true,
|
||||
countDown: true,
|
||||
progress: true,
|
||||
},
|
||||
});
|
||||
|
||||
for (let a of data) {
|
||||
if (
|
||||
(a.MasterPencarianInvestor?.name as any) -
|
||||
moment(new Date()).diff(new Date(a.countDown as any), "days") <=
|
||||
0
|
||||
) {
|
||||
await prisma.investasi.update({
|
||||
where: {
|
||||
id: a.id,
|
||||
},
|
||||
data: {
|
||||
masterProgresInvestasiId: "3",
|
||||
},
|
||||
});
|
||||
for (let a of data) {
|
||||
if (
|
||||
(a.MasterPencarianInvestor?.name as any) -
|
||||
moment(new Date()).diff(new Date(a.countDown as any), "days") <=
|
||||
0
|
||||
) {
|
||||
await prisma.investasi.update({
|
||||
where: {
|
||||
id: a.id,
|
||||
},
|
||||
data: {
|
||||
masterProgresInvestasiId: "3",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (a.progress === "100") {
|
||||
await prisma.investasi.update({
|
||||
where: {
|
||||
id: a.id,
|
||||
},
|
||||
data: {
|
||||
masterProgresInvestasiId: "2",
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (a.progress === "100") {
|
||||
await prisma.investasi.update({
|
||||
where: {
|
||||
id: a.id,
|
||||
},
|
||||
data: {
|
||||
masterProgresInvestasiId: "2",
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const dataAwal = await prisma.investasi.findMany({
|
||||
orderBy: [
|
||||
{
|
||||
masterProgresInvestasiId: "asc",
|
||||
const dataAwal = await prisma.investasi.findMany({
|
||||
orderBy: [
|
||||
{
|
||||
masterProgresInvestasiId: "asc",
|
||||
},
|
||||
{
|
||||
countDown: "desc",
|
||||
},
|
||||
],
|
||||
where: {
|
||||
masterStatusInvestasiId: "1",
|
||||
},
|
||||
{
|
||||
countDown: "desc",
|
||||
},
|
||||
],
|
||||
where: {
|
||||
masterStatusInvestasiId: "1",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
imageId: true,
|
||||
title: true,
|
||||
progress: true,
|
||||
countDown: true,
|
||||
MasterPencarianInvestor: {
|
||||
select: {
|
||||
name: true,
|
||||
select: {
|
||||
id: true,
|
||||
imageId: true,
|
||||
title: true,
|
||||
progress: true,
|
||||
countDown: true,
|
||||
MasterPencarianInvestor: {
|
||||
select: {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
fixData = dataAwal.map((v: any) => ({
|
||||
..._.omit(v, ["MasterPencarianInvestor"]),
|
||||
pencarianInvestor: v.MasterPencarianInvestor.name,
|
||||
}));
|
||||
fixData = dataAwal.map((v: any) => ({
|
||||
..._.omit(v, ["MasterPencarianInvestor"]),
|
||||
pencarianInvestor: v.MasterPencarianInvestor.name,
|
||||
}));
|
||||
} else if (category === "my-holding") {
|
||||
const data = await prisma.investasi_Invoice.findMany({
|
||||
where: {
|
||||
authorId: authorId,
|
||||
statusInvoiceId: "1",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
investasiId: true,
|
||||
nominal: true,
|
||||
lembarTerbeli: true,
|
||||
Investasi: {
|
||||
select: {
|
||||
title: true,
|
||||
progress: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
fixData = data.map((v: any) => ({
|
||||
..._.omit(v, ["Investasi"]),
|
||||
title: v.Investasi.title,
|
||||
progress: v.Investasi.progress,
|
||||
}));
|
||||
}
|
||||
return NextResponse.json({
|
||||
status: 200,
|
||||
success: true,
|
||||
|
||||
Reference in New Issue
Block a user