Merge pull request #287 from bipproduction/Nico/07-feb-25

Perbaikan Dashboard API Collaboration dan proses table API forum
This commit is contained in:
Bagasbanuna02
2025-02-07 17:32:29 +08:00
committed by GitHub
24 changed files with 386 additions and 189 deletions

View File

@@ -0,0 +1,65 @@
import { prisma } from "@/app/lib";
import backendLogger from "@/util/backendLogger";
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;
const fixStatus = _.startCase(name);
if (fixStatus === "Publish") {
fixData = await prisma.projectCollaboration.count({
where: {
isActive: true,
},
});
} else if (fixStatus === "Reject") {
fixData = await prisma.projectCollaboration.count({
where: {
isReject: true,
},
});
} else if (fixStatus === "Room") {
fixData = await prisma.projectCollaboration_RoomChat.count({
where: {
isActive: true,
},
});
}
return NextResponse.json({
success: true,
message: `Success Get Data ${fixStatus}`,
data: fixData,
},
{ status: 200 }
)
} catch (error) {
backendLogger.error("Error get count group chat", error);
return NextResponse.json({
success: false,
message: "Error get data count group chat ",
reason: (error as Error).message
},
{ status: 500 }
)
} finally {
await prisma.$disconnect
}
}

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

@@ -4,16 +4,13 @@ import adminColab_countIsPublish from "@/app_modules/admin/colab/fun/count/count
import adminColab_countIsReject from "@/app_modules/admin/colab/fun/count/count_reject";
export default async function Page() {
const countPublish = await adminColab_countIsPublish();
const countRoom = await adminColab_countGroupChat();
const countReject = await adminColab_countIsReject()
// const countPublish = await adminColab_countIsPublish();
// const countRoom = await adminColab_countGroupChat();
// const countReject = await adminColab_countIsReject()
return (
<>
<AdminColab_Dashboard
countPublish={countPublish}
countRoom={countRoom}
countReject={countReject}
/>
</>
);

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 />
</>
);
}