diff --git a/src/app/api/admin/collaboration/[status]/route.ts b/src/app/api/admin/collaboration/[status]/route.ts index 6faf5146..34b49e8e 100644 --- a/src/app/api/admin/collaboration/[status]/route.ts +++ b/src/app/api/admin/collaboration/[status]/route.ts @@ -10,7 +10,6 @@ export async function GET(request: Request, { params }: const { status } = params; const { searchParams } = new URL(request.url); - const search = searchParams.get("search"); const page = searchParams.get("page"); const takeData = 10; const skipData = Number(page) * takeData - takeData; @@ -21,8 +20,6 @@ export async function GET(request: Request, { params }: if (!page) { fixData = await prisma.projectCollaboration.findMany({ - skip: skipData, - take: takeData, orderBy: { createdAt: "desc", }, @@ -32,10 +29,7 @@ export async function GET(request: Request, { params }: Author: { active: true, }, - title: { - contains: search ? search : "", - mode: "insensitive", - }, + }, select: { id: true, @@ -82,10 +76,6 @@ export async function GET(request: Request, { params }: Author: { active: true, }, - title: { - contains: search ? search : "", - mode: "insensitive", - }, }, select: { id: true, diff --git a/src/app/api/admin/collaboration/dashboard/[name]/route.ts b/src/app/api/admin/collaboration/dashboard/[name]/route.ts index 6ed3befe..2021194c 100644 --- a/src/app/api/admin/collaboration/dashboard/[name]/route.ts +++ b/src/app/api/admin/collaboration/dashboard/[name]/route.ts @@ -6,15 +6,6 @@ import { NextResponse } from "next/server"; export async function GET(request: Request, { params }: { params: { name: string } }) { - const method = request.method; - if (method !== "GET") { - return NextResponse.json({ - success: false, - message: "Method not allowed", - }, - { status: 405 } - ); - } const { name } = params; try { let fixData; @@ -59,7 +50,5 @@ export async function GET(request: Request, { params }: { }, { status: 500 } ) - } finally { - await prisma.$disconnect } } \ No newline at end of file diff --git a/src/app/api/admin/donasi/[status]/route.ts b/src/app/api/admin/donasi/[status]/route.ts index 6d5756b1..9b1930eb 100644 --- a/src/app/api/admin/donasi/[status]/route.ts +++ b/src/app/api/admin/donasi/[status]/route.ts @@ -7,15 +7,6 @@ import { NextResponse } from "next/server"; export async function GET(request: Request, { params }: { params: { status: string } }) { - const method = request.method; - if (method !== "GET") { - return NextResponse.json({ - succes: false, - message: "Method not allowed" - }, - { status: 405 } - ); - } const { status } = params; const { searchParams } = new URL(request.url); @@ -30,7 +21,7 @@ export async function GET(request: Request, if (!page) { - const data = await prisma.donasi.findMany({ + fixData = await prisma.donasi.findMany({ orderBy: { createdAt: "desc", }, @@ -83,7 +74,7 @@ export async function GET(request: Request, DonasiMaster_Ketegori: true, DonasiMaster_Durasi: true, imageId: true, - + }, }) @@ -120,7 +111,5 @@ export async function GET(request: Request, }, { status: 500 } ); - } finally { - await prisma.$disconnect(); } } \ No newline at end of file diff --git a/src/app/api/admin/donasi/dashboard/[name]/route.ts b/src/app/api/admin/donasi/dashboard/[name]/route.ts index 8b164d12..887dbfad 100644 --- a/src/app/api/admin/donasi/dashboard/[name]/route.ts +++ b/src/app/api/admin/donasi/dashboard/[name]/route.ts @@ -7,15 +7,6 @@ import { NextResponse } from "next/server"; export async function GET(request: Request, { params }: { params: { name: string } }) { - const method = request.method; - if (method !== "GET") { - return NextResponse.json({ - success: false, - message: "Method not allowed", - }, - { status: 405 } - ); - } const { name } = params; try { @@ -44,7 +35,5 @@ export async function GET(request: Request, { params }: { }, { status: 500 } ) - } finally { - await prisma.$disconnect(); } } diff --git a/src/app/api/admin/donasi/kategori/route.ts b/src/app/api/admin/donasi/kategori/route.ts index de7e7c72..dc082a86 100644 --- a/src/app/api/admin/donasi/kategori/route.ts +++ b/src/app/api/admin/donasi/kategori/route.ts @@ -4,14 +4,6 @@ import { NextResponse } from "next/server"; export async function GET(request: Request) { const method = request.method; - if (method !== "GET") { - return NextResponse.json({ - success: false, - message: "Method nol allowed" - }, - { status: 405 } - ) - } try { const data = await prisma.donasiMaster_Kategori.findMany({ orderBy: { @@ -38,7 +30,5 @@ export async function GET(request: Request) { }, { status: 500 } ) - } finally { - await prisma.$disconnect } } \ No newline at end of file diff --git a/src/app/api/admin/event/[status]/route.ts b/src/app/api/admin/event/[status]/route.ts index 5c402e80..9876e90f 100644 --- a/src/app/api/admin/event/[status]/route.ts +++ b/src/app/api/admin/event/[status]/route.ts @@ -8,13 +8,7 @@ export async function GET( request: Request, { params }: { params: { status: string } } ) { - const method = request.method; - if (method !== "GET") { - return NextResponse.json( - { success: false, message: "Method not allowed" }, - { status: 405 } - ); - } + const { status } = params; const { searchParams } = new URL(request.url); @@ -249,7 +243,5 @@ export async function GET( }, { status: 500 } ); - } finally { - await prisma.$disconnect(); - } + } } diff --git a/src/app/api/admin/event/dashboard/[name]/route.ts b/src/app/api/admin/event/dashboard/[name]/route.ts index 9ebc3310..efde57e9 100644 --- a/src/app/api/admin/event/dashboard/[name]/route.ts +++ b/src/app/api/admin/event/dashboard/[name]/route.ts @@ -7,13 +7,6 @@ export async function GET( request: Request, { params }: { params: { name: string } } ) { - const method = request.method; - if (method !== "GET") { - return NextResponse.json( - { success: false, message: "Method not allowed" }, - { status: 405 } - ); - } const { name } = params; @@ -47,7 +40,5 @@ export async function GET( }, { status: 500 } ); - } finally { - await prisma.$disconnect(); - } + } } diff --git a/src/app/api/admin/event/dashboard/riwayat/route.ts b/src/app/api/admin/event/dashboard/riwayat/route.ts index 377d371d..568879d3 100644 --- a/src/app/api/admin/event/dashboard/riwayat/route.ts +++ b/src/app/api/admin/event/dashboard/riwayat/route.ts @@ -4,14 +4,6 @@ import _ from "lodash"; import { NextResponse } from "next/server"; export async function GET(request: Request) { - const method = request.method; - if (method !== "GET") { - return NextResponse.json( - { success: false, message: "Method not allowed" }, - { status: 405 } - ); - } - try { let fixData; fixData = await prisma.event.count({ @@ -41,7 +33,5 @@ export async function GET(request: Request) { }, { status: 500 } ); - } finally { - await prisma.$disconnect(); } } diff --git a/src/app/api/admin/event/riwayat/route.ts b/src/app/api/admin/event/riwayat/route.ts index a863c095..6d656ad7 100644 --- a/src/app/api/admin/event/riwayat/route.ts +++ b/src/app/api/admin/event/riwayat/route.ts @@ -4,14 +4,7 @@ import _ from "lodash"; import { NextResponse } from "next/server"; export async function GET(request: Request) { - const method = request.method; - if (method !== "GET") { - return NextResponse.json( - { success: false, message: "Method not allowed" }, - { status: 405 } - ); - } - + const { searchParams } = new URL(request.url); const search = searchParams.get("search"); const page = searchParams.get("page"); @@ -195,7 +188,5 @@ export async function GET(request: Request) { }, { status: 500 } ); - } finally { - await prisma.$disconnect(); } } diff --git a/src/app/api/admin/forum/dashboard/report_komentar/route.ts b/src/app/api/admin/forum/dashboard/report_komentar/route.ts index f397cb7c..3bea3768 100644 --- a/src/app/api/admin/forum/dashboard/report_komentar/route.ts +++ b/src/app/api/admin/forum/dashboard/report_komentar/route.ts @@ -3,15 +3,7 @@ import backendLogger from "@/util/backendLogger"; import { NextResponse } from "next/server"; export async function GET(request: Request) { - const method = request.method; - if (method !== "GET") { - return NextResponse.json({ - success: false, - message: "Method not allowed", - }, - { status: 405 } - ) - } + try { let fixData; fixData = await prisma.forum_ReportKomentar.count({ @@ -35,7 +27,5 @@ export async function GET(request: Request) { }, { status: 500 } ) - } finally { - await prisma.$disconnect(); } } \ No newline at end of file diff --git a/src/app/api/admin/forum/dashboard/report_posting/route.ts b/src/app/api/admin/forum/dashboard/report_posting/route.ts index c0b5e3fb..21a325be 100644 --- a/src/app/api/admin/forum/dashboard/report_posting/route.ts +++ b/src/app/api/admin/forum/dashboard/report_posting/route.ts @@ -3,15 +3,6 @@ import backendLogger from "@/util/backendLogger"; import { NextResponse } from "next/server"; export async function GET(request: Request) { - const method = request.method; - if (method !== "GET") { - return NextResponse.json({ - success: false, - message: "Method not allowed", - }, - { status: 405 } - ) - } try { let fixData; fixData = await prisma.forum_ReportPosting.count({ @@ -35,7 +26,5 @@ export async function GET(request: Request) { }, { status: 500 } ) - } finally { - await prisma.$disconnect(); } } \ No newline at end of file diff --git a/src/app/api/admin/forum/komentar/route.ts b/src/app/api/admin/forum/komentar/route.ts index 830d34d1..3fdf5cd6 100644 --- a/src/app/api/admin/forum/komentar/route.ts +++ b/src/app/api/admin/forum/komentar/route.ts @@ -5,15 +5,6 @@ import { NextResponse } from "next/server"; import _ from 'lodash'; export async function GET(request: Request) { - const method = request.method; - if (method !== "GET") { - return NextResponse.json({ - success: false, - message: "Method not allowed" - }, - { status: 405 } - ); - } const { searchParams } = new URL(request.url); const search = searchParams.get("search"); @@ -127,7 +118,5 @@ export async function GET(request: Request) { reason: (error as Error).message }, ) - } finally { - await prisma.$disconnect(); } } \ No newline at end of file diff --git a/src/app/api/admin/forum/posting/route.ts b/src/app/api/admin/forum/posting/route.ts index 9e4dbed9..c163a8b1 100644 --- a/src/app/api/admin/forum/posting/route.ts +++ b/src/app/api/admin/forum/posting/route.ts @@ -5,16 +5,6 @@ import { NextResponse } from "next/server"; export async function GET(request: Request, { postingId }: { postingId: string }) { - const method = request.method; - if (method !== "GET") { - return NextResponse.json({ - success: false, - message: "Method not allowed", - }, - { status: 405 } - ) - } - const { searchParams } = new URL(request.url); const search = searchParams.get('search'); @@ -144,7 +134,5 @@ export async function GET(request: Request, }, { status: 500 } ) - } finally { - await prisma.$disconnect(); - } + } } \ No newline at end of file diff --git a/src/app/api/admin/forum/publish/route.ts b/src/app/api/admin/forum/publish/route.ts index 43403b86..e53fa56f 100644 --- a/src/app/api/admin/forum/publish/route.ts +++ b/src/app/api/admin/forum/publish/route.ts @@ -4,15 +4,6 @@ import _ from "lodash"; import { NextResponse } from "next/server"; export async function GET(request: Request) { - const method = request.method; - if (method !== "GET") { - return NextResponse.json({ - success: false, - message: "Method not allowed", - }, - { status: 405 } - ) - } const { searchParams } = new URL(request.url); const search = searchParams.get("search"); @@ -124,7 +115,5 @@ export async function GET(request: Request) { }, { status: 500 } ) - } finally { - await prisma.$disconnect() } } \ No newline at end of file diff --git a/src/app/api/admin/investasi/dashboard/[name]/route.ts b/src/app/api/admin/investasi/dashboard/[name]/route.ts index c577c34b..04c15e6d 100644 --- a/src/app/api/admin/investasi/dashboard/[name]/route.ts +++ b/src/app/api/admin/investasi/dashboard/[name]/route.ts @@ -4,15 +4,7 @@ import _ from "lodash"; import { NextResponse } from "next/server"; export async function GET(request: Request, { params }: { params: { name: string } }) { - const method = request.method; - if (method !== "GET") { - return NextResponse.json({ - success: false, - message: "Method not allowed", - }, - { status: 405 } - ); - } + const { name } = params; try { let fixData; @@ -40,7 +32,5 @@ export async function GET(request: Request, { params }: { params: { name: string }, { status: 500 } ) - } finally { - await prisma.$disconnect(); } } diff --git a/src/app/api/admin/investasi/detail/[id]/route.ts b/src/app/api/admin/investasi/detail/[id]/route.ts new file mode 100644 index 00000000..dfcddaa5 --- /dev/null +++ b/src/app/api/admin/investasi/detail/[id]/route.ts @@ -0,0 +1,79 @@ +import { prisma } from "@/app/lib"; +import backendLogger from "@/util/backendLogger"; +import { NextResponse } from "next/server"; + +export async function GET(req: Request, + { params }: { params: { id: string } }) { + + console.log("Ini ID", params.id); + + try { + const { id } = params; + 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 detail investasi", + data: data, + }, + { status: 200 } + ) + } catch (error) { + backendLogger.error("Error get detail investasi", error); + return NextResponse.json({ + success: false, + message: "Error get detail investasi", + reason: (error as Error).message + }, + { status: 500 } + ); + + } +} \ No newline at end of file diff --git a/src/app/api/admin/job/dashboard/[status]/route.ts b/src/app/api/admin/job/dashboard/[status]/route.ts index dd45ec7e..cd39017e 100644 --- a/src/app/api/admin/job/dashboard/[status]/route.ts +++ b/src/app/api/admin/job/dashboard/[status]/route.ts @@ -6,15 +6,7 @@ import { NextResponse } from "next/server"; export async function GET(request: Request, { params }: { params: { status: string } }) { - const method = request.method; - if (method !== "GET") { - return NextResponse.json({ - success: false, - message: "Method not allowed", - }, - { status: 405 } - ) - } + const { status } = params; try { let fixData; @@ -44,7 +36,5 @@ export async function GET(request: Request, { params }: { }, { status: 500 } ) - } finally { - await prisma.$disconnect(); - } + } } \ No newline at end of file diff --git a/src/app/api/admin/job/dashboard/arsip/route.ts b/src/app/api/admin/job/dashboard/arsip/route.ts index fd1d45c5..9ba4f236 100644 --- a/src/app/api/admin/job/dashboard/arsip/route.ts +++ b/src/app/api/admin/job/dashboard/arsip/route.ts @@ -4,14 +4,7 @@ import { NextResponse } from "next/server"; export async function GET(request: Request) { const method = request.method; - if (method !== "GET") { - return NextResponse.json({ - success: false, - message: "Method not allowed", - }, - { status: 405 } - ); - } + try { let fixData; fixData = await prisma.job.count({ @@ -38,7 +31,5 @@ export async function GET(request: Request) { }, { status: 500 } ) - } finally { - await prisma.$disconnect(); - } + } } \ No newline at end of file diff --git a/src/app/api/admin/main_dashboard/portofolio/route.ts b/src/app/api/admin/main_dashboard/portofolio/route.ts index fa56632d..44b5b070 100644 --- a/src/app/api/admin/main_dashboard/portofolio/route.ts +++ b/src/app/api/admin/main_dashboard/portofolio/route.ts @@ -25,7 +25,5 @@ export async function GET(request: Request) { }, { status: 500 } ); - } finally { - await prisma.$disconnect(); - } + } } \ No newline at end of file diff --git a/src/app/api/admin/main_dashboard/user/route.ts b/src/app/api/admin/main_dashboard/user/route.ts index 2470f74b..9357f032 100644 --- a/src/app/api/admin/main_dashboard/user/route.ts +++ b/src/app/api/admin/main_dashboard/user/route.ts @@ -4,12 +4,7 @@ import { NextResponse } from "next/server"; export async function GET(request: Request) { const method = request.method; - if (method !== "GET") { - return NextResponse.json( - { success: false, message: "Method not allowed" }, - { status: 405 } - ); - } + try { const data = await prisma.user.count({ where: { @@ -35,8 +30,6 @@ export async function GET(request: Request) { { status: 500 } ) - } finally { - await prisma.$disconnect(); } } \ No newline at end of file diff --git a/src/app/api/admin/voting/dashboard/[name]/route.ts b/src/app/api/admin/voting/dashboard/[name]/route.ts index 3f498707..f952b5a0 100644 --- a/src/app/api/admin/voting/dashboard/[name]/route.ts +++ b/src/app/api/admin/voting/dashboard/[name]/route.ts @@ -6,16 +6,7 @@ import { NextResponse } from "next/server"; export async function GET(request: Request, { params }: { params: { name: string } }) { - const method = request.method; - if (method !== "GET") { - return NextResponse.json({ - success: false, - message: "Method not allowed", - }, - { status: 405 } - ) - } - + const { name } = params; try { let fixData; @@ -45,7 +36,5 @@ export async function GET(request: Request, { params }: { }, { status: 500 } ) - } finally { - await prisma.$disconnect(); } } \ No newline at end of file diff --git a/src/app/api/admin/voting/dashboard/riwayat/route.ts b/src/app/api/admin/voting/dashboard/riwayat/route.ts index c377c3de..c6288571 100644 --- a/src/app/api/admin/voting/dashboard/riwayat/route.ts +++ b/src/app/api/admin/voting/dashboard/riwayat/route.ts @@ -3,15 +3,6 @@ import backendLogger from "@/util/backendLogger"; import { NextResponse } from "next/server"; export async function GET(request: Request) { - if (request.method !== "GET") { - return NextResponse.json( - { - success: false, - message: "Method not allowed", - }, - { status: 405 } - ); - } try { let fixData; @@ -42,7 +33,5 @@ export async function GET(request: Request) { }, { status: 500 } ); - } finally { - await prisma.$disconnect(); - } + } } diff --git a/src/app_modules/admin/colab/lib/api_fetch_admin_collaboration.ts b/src/app_modules/admin/colab/lib/api_fetch_admin_collaboration.ts index d6375f84..4f873df8 100644 --- a/src/app_modules/admin/colab/lib/api_fetch_admin_collaboration.ts +++ b/src/app_modules/admin/colab/lib/api_fetch_admin_collaboration.ts @@ -25,18 +25,17 @@ const apiGetAdminCollaborationStatusCountDashboard = async ({ // console.log("Ini Response", await response.json()); return await response.json().catch(() => null); } -const apiGetAdminCollaborationStatusById = async ({ status, page, search }: { +const apiGetAdminCollaborationStatusById = async ({ status, page}: { status: "Publish" | "Reject", page: string, - search: string + }) => { const { token } = await fetch("/api/get-cookie").then((res) => res.json()); if (!token) return await token.json().catch(() => null); const isPage = page ? `?page=${page}` : ""; - const isSearch = search ? `&search=${search}` : ""; - const response = await fetch(`/api/admin/collaboration/${status}${isPage}${isSearch}`, { + const response = await fetch(`/api/admin/collaboration/${status}${isPage}`, { headers: { "Content-Type": "application/json", Accept: "application/json", diff --git a/src/app_modules/admin/investasi/_lib/api_fetch_admin_investasi.ts b/src/app_modules/admin/investasi/_lib/api_fetch_admin_investasi.ts index ea29f62b..dc1d4ed9 100644 --- a/src/app_modules/admin/investasi/_lib/api_fetch_admin_investasi.ts +++ b/src/app_modules/admin/investasi/_lib/api_fetch_admin_investasi.ts @@ -1,6 +1,8 @@ export { apiGetAdminInvestasiCountDashboard, apiGetAdminInvestasiByStatus, + apiGetAdminInvestasiById, + } const apiGetAdminInvestasiCountDashboard = async ({ name }: { name: "Publish" | "Review" | "Reject" }) => { @@ -37,6 +39,7 @@ const apiGetAdminInvestasiByStatus = async ({ status, page, search }: { const isPage = page ? `?page=${page}` : ""; const isSearch = search ? `&search=${search}` : ""; const response = await fetch(`/api/admin/investasi/${status}${isPage}${isSearch}`, { + method: "GET", headers: { "Content-Type": "application/json", Accept: "application/json", @@ -45,5 +48,24 @@ const apiGetAdminInvestasiByStatus = async ({ status, page, search }: { }, }) + return await response.json().catch(() => null); +} + +const apiGetAdminInvestasiById = async ({id} : {id: string}) => { + const { token } = await fetch ("/api/get-cookie").then((res) => res.json()); + if (!token) return await token.json().catch(() => null); + + + const response = await fetch(`/api/admin/investasi/detail/${id}`, { + method: "GET", + headers: { + "Content-Type": "application/json", + Accept: "application/json", + "Access-Control-Allow-Origin": "*", + Authorization: `Bearer ${token}`, + } + }) + + console.log("Ini data Response", await response.json()) return await response.json().catch(() => null); } \ No newline at end of file diff --git a/src/middleware.ts b/src/middleware.ts index 4dbd6ca6..4b86c388 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -35,6 +35,7 @@ const middlewareConfig: MiddlewareConfig = { // ADMIN API // >> buat dibawah sini << "/api/admin/collaboration/*", + "/api/admin/investasi/*", // Akses awal "/api/get-cookie",