API Dashboard Collab & API Table forum

This commit is contained in:
2025-02-07 17:15:59 +08:00
parent 9eb7abd376
commit cca6442936
18 changed files with 185 additions and 155 deletions

View File

@@ -1 +1,6 @@
{"digest":"DYNAMIC_SERVER_USAGE","level":"error","message":"Error get data detail event: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error","originalColumn":16,"originalLine":1069,"stack":"Error: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error\n at new eS (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:26724)\n at e_ (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:27574)\n at i (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32507)\n at get (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32603)\n at <anonymous> (/Users/lukman/Documents/projects/BIP/hipmi/.next/server/app/api/event/check-peserta/route.js:1:1217)\n at GET (/Users/lukman/Documents/projects/BIP/hipmi/.next/server/app/api/event/check-peserta/route.js:1:1084)\n at <anonymous> (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:39714)\n at <anonymous> (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:33303)\n at <anonymous> (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/server/lib/trace/tracer.js:121:36)\n at run (node:async_hooks:64:22)","timestamp":"2025-02-07T07:12:35.321Z"}
{"level":"info","message":"Server status code: 201","timestamp":"2025-02-07T07:55:45.205Z"}
{"level":"info","message":"Success upload investasi_image: {\"id\":\"cm6uh26w9003tc9dc5jueuafw\",\"name\":\"cr.jpeg\",\"path\":\"/cm0ur1yxw000056nsjlr6187p/2025/02/07/cr.jpeg\",\"mime\":\"image/jpeg\",\"ext\":\".jpeg\",\"desc\":null,\"size\":187018,\"active\":true,\"createdAt\":\"2025-02-07T07:55:45.128Z\",\"updatedAt\":\"2025-02-07T07:55:45.130Z\",\"userId\":\"cm0ur1yxw000056nsjlr6187p\",\"dirId\":\"cm0yjs35h000b10njb35o12h1\"}","timestamp":"2025-02-07T07:55:45.210Z"}
{"level":"info","message":"Server status code: 201","timestamp":"2025-02-07T07:55:45.782Z"}
{"level":"info","message":"Success upload investasi_prospektus: {\"id\":\"cm6uh27cb003hhcxk3f84hwnz\",\"name\":\"dummy.pdf\",\"path\":\"/cm0ur1yxw000056nsjlr6187p/2025/02/07/dummy.pdf\",\"mime\":\"application/pdf\",\"ext\":\".pdf\",\"desc\":null,\"size\":55840,\"active\":true,\"createdAt\":\"2025-02-07T07:55:45.707Z\",\"updatedAt\":\"2025-02-07T07:55:45.708Z\",\"userId\":\"cm0ur1yxw000056nsjlr6187p\",\"dirId\":\"cm1soio74003p38bjyciwf1oy\"}","timestamp":"2025-02-07T07:55:45.782Z"}
{"digest":"DYNAMIC_SERVER_USAGE","level":"error","message":"Error get data detail event: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error","stack":"Error: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error\n at Object.e_ [as staticGenerationBailout] (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:27571)\n at i (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32508)\n at Object.get (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32604)\n at GET (/Users/lukman/Documents/projects/BIP/hipmi/.next/server/app/api/event/check-peserta/route.js:1:1219)\n at /Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:39715\n at /Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/server/lib/trace/tracer.js:121:36\n at NoopContextManager.with (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7057)\n at ContextAPI.with (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:516)\n at NoopTracer.startActiveSpan (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18086)\n at ProxyTracer.startActiveSpan (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18847)","timestamp":"2025-02-07T09:12:39.860Z"}

View File

@@ -1 +1,2 @@
{"digest":"DYNAMIC_SERVER_USAGE","level":"error","message":"Error get data detail event: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error","originalColumn":16,"originalLine":1069,"stack":"Error: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error\n at new eS (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:26724)\n at e_ (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:27574)\n at i (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32507)\n at get (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32603)\n at <anonymous> (/Users/lukman/Documents/projects/BIP/hipmi/.next/server/app/api/event/check-peserta/route.js:1:1217)\n at GET (/Users/lukman/Documents/projects/BIP/hipmi/.next/server/app/api/event/check-peserta/route.js:1:1084)\n at <anonymous> (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:39714)\n at <anonymous> (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:33303)\n at <anonymous> (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/server/lib/trace/tracer.js:121:36)\n at run (node:async_hooks:64:22)","timestamp":"2025-02-07T07:12:35.321Z"}
{"digest":"DYNAMIC_SERVER_USAGE","level":"error","message":"Error get data detail event: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error","stack":"Error: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error\n at Object.e_ [as staticGenerationBailout] (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:27571)\n at i (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32508)\n at Object.get (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32604)\n at GET (/Users/lukman/Documents/projects/BIP/hipmi/.next/server/app/api/event/check-peserta/route.js:1:1219)\n at /Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:39715\n at /Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/server/lib/trace/tracer.js:121:36\n at NoopContextManager.with (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7057)\n at ContextAPI.with (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:516)\n at NoopTracer.startActiveSpan (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18086)\n at ProxyTracer.startActiveSpan (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18847)","timestamp":"2025-02-07T09:12:39.860Z"}

View File

@@ -19,8 +19,7 @@ export async function GET(request: Request, { params }: {
try {
let fixData;
const fixStatus = _.startCase(name);
// console.log("status >>", fixStatus)
if (fixStatus === "Publish") {
fixData = await prisma.projectCollaboration.count({
where: {

View File

@@ -27,90 +27,64 @@ export async function GET(request: Request,
try {
let fixData;
const fixStatus = _.startCase(status);
if (!page && !search) {
fixData = await prisma.donasi.findMany({
if (!page) {
const data = await prisma.donasi.findMany({
orderBy: {
updatedAt: "desc",
createdAt: "desc",
},
where: {
active: true,
DonasiMaster_Status: {
name: fixStatus
}
},
include: {
Author: {
select: {
id: true,
username: true,
Profile: {
select: {
name: true
}
}
}
name: fixStatus,
},
DonasiMaster_Status: true,
DonasiMaster_Ketegori: true,
DonasiMaster_Durasi: true
}
})
} else if (!page && search) {
fixData = await prisma.donasi.findMany({
orderBy: {
updatedAt: "desc"
},
where: {
active: true,
DonasiMaster_Status: {
name: fixStatus
},
title: {
contains: search,
mode: "insensitive"
}
},
include: {
Author: {
select: {
id: true,
username: true,
Profile: {
select: {
name: true
}
}
}
contains: search ? search : "",
mode: "insensitive",
},
DonasiMaster_Status: true,
},
select: {
id: true,
title: true,
target: true,
authorId: true,
terkumpul: true,
imageDonasi: true,
DonasiMaster_Ketegori: true,
DonasiMaster_Durasi: true
}
DonasiMaster_Durasi: true,
imageId: true,
},
})
} else if (page && !search) {
} else {
const data = await prisma.donasi.findMany({
take: takeData,
skip: skipData,
orderBy: [
{
publishTime: "desc"
}
],
where: {
active: true,
DonasiMaster_Status: {
name: fixStatus
}
orderBy: {
createdAt: "desc",
},
include: {
Author: true,
where: {
DonasiMaster_Status: {
name: fixStatus,
},
active: true,
title: {
contains: search ? search : "",
mode: "insensitive",
},
},
select: {
id: true,
title: true,
target: true,
authorId: true,
terkumpul: true,
imageDonasi: true,
DonasiMaster_Status: true,
DonasiMaster_Ketegori: true,
DonasiMaster_Durasi: true
}
DonasiMaster_Durasi: true,
imageId: true,
},
})
const nCount = await prisma.donasi.count({
@@ -122,7 +96,7 @@ export async function GET(request: Request,
}
})
console.log("data >", data)
fixData = {
data: data,
nCount: _.ceil(nCount / takeData)

View File

@@ -0,0 +1,95 @@
import { prisma } from "@/app/lib";
import backendLogger from "@/util/backendLogger";
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");
const takeData = 10;
const skipData = Number(page) * takeData - takeData;
try {
let fixData;
if (!page) {
const data = await prisma.forum_Posting.findMany({
take: takeData,
skip: skipData,
orderBy: {
createdAt: "desc",
},
where: {
isActive: true,
diskusi: {
contains: search ? search : "",
mode: "insensitive",
},
},
select: {
id: true,
diskusi: true,
isActive: true,
createdAt: true,
Author: {
select: {
id: true,
username: true,
Profile: true,
},
},
Forum_ReportPosting: true,
Forum_Komentar: {
where: {
isActive: true,
},
},
ForumMaster_StatusPosting: true,
},
});
const nCount = await prisma.forum_Posting.count({
where: {
isActive: true,
diskusi: {
contains: search ? search : "",
mode: "insensitive",
},
},
});
fixData = {
data: data,
nCount: _.ceil(nCount / takeData)
}
}
return NextResponse.json({
success: true,
message: "Success get data table forum",
data: fixData
},
{ status: 200 }
)
} catch (error) {
backendLogger.error("Error get data table forum", error)
return NextResponse.json({
success: false,
message: "Error get data table forum",
reason: (error as Error)
},
{ status: 500 }
)
}
}

View File

@@ -24,41 +24,13 @@ export async function GET(request: Request, { params }: {
const takeData = 10
const skipData = Number(page) * takeData - takeData;
console.log("Ini Status", status);
console.log("Ini Page", page)
try {
let fixData;
const fixStatus = _.startCase(status);
if (!page && !search) {
fixData = await prisma.investasi.findMany({
orderBy: {
updatedAt: "desc",
},
where: {
active: true,
MasterStatusInvestasi: {
name: fixStatus
},
},
include: {
author: {
select: {
id: true,
username: true,
Profile: {
select: {
name: true,
},
},
},
},
MasterStatusInvestasi: true,
},
});
} else if (!page && search) {
fixData = await prisma.investasi.findMany({
if (!page) {
const data = await prisma.investasi.findMany({
orderBy: {
updatedAt: "desc",
},
@@ -68,41 +40,40 @@ export async function GET(request: Request, { params }: {
name: fixStatus
},
title: {
contains: search,
mode: "insensitive",
},
contains: search ? search : "",
mode: "insensitive"
}
},
include: {
author: {
select: {
id: true,
username: true,
Profile: {
select: {
name: true,
},
},
MasterStatusInvestasi: true,
BeritaInvestasi: true,
DokumenInvestasi: true,
ProspektusInvestasi: true,
MasterPembagianDeviden: true,
MasterPencarianInvestor: true,
MasterPeriodeDeviden: true,
author: true,
Investasi_Invoice: {
where: {
statusInvoiceId: "2",
},
},
MasterStatusInvestasi: true,
},
});
} else if (page && !search) {
} else {
const data = await prisma.investasi.findMany({
take: takeData,
skip: skipData,
orderBy: [
{
countDown: "desc",
},
],
orderBy: {
updatedAt: "desc",
},
where: {
active: true,
MasterStatusInvestasi: {
name: fixStatus
},
title: {
contains: search ? search : "",
mode: "insensitive"
}
},
include: {
MasterStatusInvestasi: true,
@@ -131,8 +102,6 @@ export async function GET(request: Request, { params }: {
},
});
console.log("data >", data)
fixData = {
data: data,
nPage: _.ceil(nCount / takeData),

View File

@@ -31,7 +31,7 @@ export async function GET(request: Request, { params }: {
const fixStatus = _.startCase(status);
if (!page) {
fixData = await prisma.job.findMany({
const data = await prisma.job.findMany({
orderBy: {
updatedAt: "desc"
},
@@ -53,7 +53,7 @@ export async function GET(request: Request, { params }: {
})
} else {
fixData = await prisma.job.findMany({
const data = await prisma.job.findMany({
take: takeData,
skip: skipData,
orderBy: {
@@ -87,7 +87,7 @@ export async function GET(request: Request, { params }: {
})
fixData = {
data: fixData,
data: data,
nPage: _.ceil(nCount / takeData)
}
}

View File

@@ -2,7 +2,6 @@ import { AdminDonasi_TableKategori } from "@/app_modules/admin/donasi";
import adminDonasi_getMasterKategori from "@/app_modules/admin/donasi/fun/master/get_list_kategori";
export default async function Page() {
// const listKategori = await adminDonasi_getMasterKategori();
return (
<>

View File

@@ -2,10 +2,7 @@ import { AdminDonasi_TablePublish } from "@/app_modules/admin/donasi";
import adminDonasi_getListPublish from "@/app_modules/admin/donasi/fun/get/get_list_publish";
export default async function Page() {
// const listPublish = await adminDonasi_getListPublish({
// page: 1,
// });
// console.log(listPublish)
return<>
<AdminDonasi_TablePublish />
</>

View File

@@ -2,8 +2,7 @@ import { AdminDonasi_TableReject } from "@/app_modules/admin/donasi";
import adminDonasi_getListReject from "@/app_modules/admin/donasi/fun/get/get_list_reject";
export default async function Page() {
// const dataReject = await adminDonasi_getListReject({ page: 1 });
// console.log(dataReject)
return (
<>
<AdminDonasi_TableReject />

View File

@@ -1,8 +1,6 @@
import { AdminDonasi_TableReview } from "@/app_modules/admin/donasi";
import adminDonasi_getListReview from "@/app_modules/admin/donasi/fun/get/get_list_review";
export default async function Page() {
// const listReview = await adminDonasi_getListReview({page: 1});
// console.log(listReview);
return <AdminDonasi_TableReview />;
}

View File

@@ -1,9 +1,7 @@
import { Admin_TablePublishInvestasi } from "@/app_modules/admin/investasi";
import { adminInvestasi_funGetAllPublish } from "@/app_modules/admin/investasi/fun/get/get_all_publish";
export default async function Page() {
// const listInvestasi = await adminInvestasi_funGetAllPublish({page: 1});
return (
<>
<Admin_TablePublishInvestasi />

View File

@@ -2,7 +2,7 @@ import { Admin_TableRejectInvestasi } from "@/app_modules/admin/investasi";
import { adminInvestasi_funGetAllReject } from "@/app_modules/admin/investasi/fun/get/get_all_reject";
export default async function Page() {
// const dataInvestsi = await adminInvestasi_funGetAllReject({page: 1});
return (
<>
<Admin_TableRejectInvestasi />

View File

@@ -2,7 +2,6 @@ import { Admin_TableReviewInvestasi } from "@/app_modules/admin/investasi";
import { adminInvestasi_funGetAllReview } from "@/app_modules/admin/investasi/fun/get/get_all_review";
export default async function Page() {
// const dataInvestsi = await adminInvestasi_funGetAllReview({ page: 1 });
return (
<>
<Admin_TableReviewInvestasi />

View File

@@ -3,11 +3,11 @@ import adminJob_getListReject from "@/app_modules/admin/job/fun/get/get_list_rej
import { AdminJob_getListTableByStatusId } from "@/app_modules/admin/job/fun/get/get_list_table_by_status_id";
export default async function Page() {
const listReject = await adminJob_getListReject({ page: 1 });
return (
<>
<AdminJob_TableReject dataReject={listReject} />
<AdminJob_TableReject />
</>
);
}

View File

@@ -13,6 +13,7 @@ import { ComponentAdminInvestasi_DetailDataAuthor } from "../_component/detail_d
import { ComponentAdminInvestasi_DetailData } from "../_component/detail_data_investasi";
import { ComponentAdminInvestasi_DetailGambar } from "../_component/detail_gambar_investasi";
import { ComponentAdminInvestasi_UIDetailFile } from "../_component/ui_detail_file";
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
export function AdminInvestasi_DetailReject({ data }: { data: MODEL_INVESTASI }) {
return (
@@ -28,15 +29,15 @@ export function AdminInvestasi_DetailReject({ data }: { data: MODEL_INVESTASI })
{ maxWidth: "36rem", cols: 1, spacing: "sm" },
]}
>
<Paper withBorder p={"lg"}>
<Paper bg={AdminColor.softBlue} p={"lg"}>
<Stack>
<Title order={3} c={"red"}>
#{" "}
<Text span inherit c={"black"}>
<Text span inherit c={AdminColor.white}>
Alasan penolakan
</Text>
</Title>
<Text>{data.catatan}</Text>
<Text c={AdminColor.white}>{data.catatan}</Text>
</Stack>
</Paper>
</SimpleGrid>

View File

@@ -35,11 +35,7 @@ import { apiGetAdminJobByStatus } from "../../lib/api_fetch_admin_job";
import { clientLogger } from "@/util/clientLogger";
import { useShallowEffect } from "@mantine/hooks";
export default function AdminJob_TableReject({
dataReject,
}: {
dataReject: any;
}) {
export default function AdminJob_TableReject() {
return (
<>
<Stack>

View File

@@ -38,7 +38,7 @@ const middlewareConfig: MiddlewareConfig = {
// "/api/new/*",
// ADMIN API
// "/api/admin/event/*",
// "/api/admin/investasi/*",
"/api/admin/investasi/*",
// "/api/admin/donasi/*",
// "/api/admin/voting/dashboard/*",
// "/api/admin/job/*",