fix api klist investor
This commit is contained in:
49
src/app/api/investasi/[id]/route.ts
Normal file
49
src/app/api/investasi/[id]/route.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { prisma } from "@/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,
|
||||
},
|
||||
include: {
|
||||
author: {
|
||||
include: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
Investasi_Invoice: true,
|
||||
MasterStatusInvestasi: true,
|
||||
BeritaInvestasi: true,
|
||||
DokumenInvestasi: true,
|
||||
ProspektusInvestasi: true,
|
||||
MasterPembagianDeviden: true,
|
||||
MasterPencarianInvestor: true,
|
||||
MasterPeriodeDeviden: true,
|
||||
MasterProgresInvestasi: 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 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user