fix event button and list peserta
This commit is contained in:
@@ -8,8 +8,6 @@ export async function GET(
|
||||
request: Request,
|
||||
{ params }: { params: { name: string } }
|
||||
) {
|
||||
|
||||
|
||||
const { name } = params;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const search = searchParams.get("search");
|
||||
@@ -21,35 +19,7 @@ export async function GET(
|
||||
let fixData;
|
||||
const fixStatus = _.startCase(name);
|
||||
|
||||
if (!page && !search) {
|
||||
fixData = await prisma.event.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
active: true,
|
||||
isArsip: false,
|
||||
EventMaster_Status: {
|
||||
name: fixStatus,
|
||||
},
|
||||
},
|
||||
include: {
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: {
|
||||
select: {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
EventMaster_Status: true,
|
||||
EventMaster_TipeAcara: true,
|
||||
},
|
||||
});
|
||||
} else if (!page && search) {
|
||||
if (!page) {
|
||||
fixData = await prisma.event.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
@@ -61,7 +31,7 @@ export async function GET(
|
||||
name: fixStatus,
|
||||
},
|
||||
title: {
|
||||
contains: search,
|
||||
contains: search ? search : "",
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
@@ -81,7 +51,7 @@ export async function GET(
|
||||
EventMaster_TipeAcara: true,
|
||||
},
|
||||
});
|
||||
} else if (page && !search) {
|
||||
} else {
|
||||
if (fixStatus === "Publish") {
|
||||
const getAllData = await prisma.event.findMany({
|
||||
where: {
|
||||
@@ -111,77 +81,7 @@ export async function GET(
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
active: true,
|
||||
isArsip: false,
|
||||
EventMaster_Status: {
|
||||
name: fixStatus,
|
||||
},
|
||||
},
|
||||
include: {
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: {
|
||||
select: {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
EventMaster_Status: true,
|
||||
EventMaster_TipeAcara: true,
|
||||
},
|
||||
});
|
||||
|
||||
const nCount = await prisma.event.count({
|
||||
where: {
|
||||
EventMaster_Status: {
|
||||
name: fixStatus,
|
||||
},
|
||||
active: true,
|
||||
isArsip: false,
|
||||
},
|
||||
});
|
||||
|
||||
fixData = {
|
||||
data: data,
|
||||
nPage: _.ceil(nCount / takeData),
|
||||
};
|
||||
} else if (page && search) {
|
||||
if (fixStatus === "Publish") {
|
||||
const getAllData = await prisma.event.findMany({
|
||||
where: {
|
||||
active: true,
|
||||
EventMaster_Status: {
|
||||
name: fixStatus,
|
||||
},
|
||||
isArsip: false,
|
||||
},
|
||||
});
|
||||
|
||||
for (let i of getAllData) {
|
||||
if (moment(i.tanggalSelesai).diff(moment(), "minutes") < 0) {
|
||||
await prisma.event.update({
|
||||
where: {
|
||||
id: i.id,
|
||||
},
|
||||
data: {
|
||||
isArsip: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const data = await prisma.event.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
tanggal: "asc",
|
||||
},
|
||||
where: {
|
||||
active: true,
|
||||
@@ -190,7 +90,7 @@ export async function GET(
|
||||
name: fixStatus,
|
||||
},
|
||||
title: {
|
||||
contains: search,
|
||||
contains: search ? search : "",
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
@@ -215,8 +115,11 @@ export async function GET(
|
||||
where: {
|
||||
active: true,
|
||||
isArsip: false,
|
||||
EventMaster_Status: {
|
||||
name: fixStatus,
|
||||
},
|
||||
title: {
|
||||
contains: search,
|
||||
contains: search ? search : "",
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
@@ -228,11 +131,12 @@ export async function GET(
|
||||
};
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: `Success get data table event ${name}`,
|
||||
data: fixData,
|
||||
},
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
message: `Success get data table event ${name}`,
|
||||
data: fixData,
|
||||
},
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import { Event_DetailDraft } from "@/app_modules/event";
|
||||
import { event_getOneById } from "@/app_modules/event/fun/get/get_one_by_id";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const eventId = params.id;
|
||||
const dataEvent = await event_getOneById(eventId);
|
||||
export default async function Page() {
|
||||
return (
|
||||
<Event_DetailDraft eventId={eventId as any} dataEvent={dataEvent as any} />
|
||||
<Event_DetailDraft />
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,9 @@
|
||||
import { Event_DetailKontribusi } from "@/app_modules/event";
|
||||
import { Event_countTotalPesertaById } from "@/app_modules/event/fun/count/count_total_peserta_by_id";
|
||||
import { Event_getListPesertaById } from "@/app_modules/event/fun/get/get_list_peserta_by_id";
|
||||
import { event_getOneById } from "@/app_modules/event/fun/get/get_one_by_id";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
let eventId = params.id;
|
||||
// const dataEvent = await event_getOneById(eventId);
|
||||
// const listKontributor = await Event_getListPesertaById(eventId);
|
||||
const totalPeserta = await Event_countTotalPesertaById(eventId)
|
||||
export default async function Page() {
|
||||
return (
|
||||
<>
|
||||
<Event_DetailKontribusi
|
||||
totalPeserta={totalPeserta}
|
||||
/>
|
||||
<Event_DetailKontribusi />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
import Event_DaftarPeserta from '@/app_modules/event/detail/peserta';
|
||||
import { Event_countTotalPesertaById } from '@/app_modules/event/fun/count/count_total_peserta_by_id';
|
||||
import { event_getOneById } from '@/app_modules/event/fun/get/get_one_by_id';
|
||||
import React from 'react';
|
||||
|
||||
export default async function Page() {
|
||||
// const dataEvent = await event_getOneById(eventId);
|
||||
// const totalPeserta = await Event_countTotalPesertaById(eventId);
|
||||
|
||||
return (
|
||||
<Event_DaftarPeserta />
|
||||
)
|
||||
|
||||
@@ -1,19 +1,5 @@
|
||||
import { Event_DetailPublish } from "@/app_modules/event";
|
||||
import { Event_countTotalPesertaById } from "@/app_modules/event/fun/count/count_total_peserta_by_id";
|
||||
import { Event_getListPesertaById } from "@/app_modules/event/fun/get/get_list_peserta_by_id";
|
||||
import { event_getOneById } from "@/app_modules/event/fun/get/get_one_by_id";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
let eventId = params.id;
|
||||
const dataEvent = await event_getOneById(eventId);
|
||||
const totalPeserta = await Event_countTotalPesertaById(eventId);
|
||||
|
||||
|
||||
return (
|
||||
<Event_DetailPublish
|
||||
dataEvent={dataEvent as any}
|
||||
totalPeserta={totalPeserta}
|
||||
eventId={eventId}
|
||||
/>
|
||||
);
|
||||
export default async function Page() {
|
||||
return <Event_DetailPublish />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user