removed event-chronjobs, used Events in hub-app insteand, added admin Btn to set Discord-User and run Event-completed-workflow. Fixed Bug of wrong participants-count in Event-Modal
This commit is contained in:
@@ -14,53 +14,32 @@ const page = async () => {
|
||||
if (!user) return null;
|
||||
|
||||
const events = await prisma.event.findMany({
|
||||
where: {
|
||||
type: "OBLIGATED_COURSE",
|
||||
},
|
||||
include: {
|
||||
appointments: {
|
||||
where: {
|
||||
appointmentDate: {
|
||||
gte: new Date(),
|
||||
},
|
||||
},
|
||||
},
|
||||
participants: {
|
||||
where: {
|
||||
userId: user.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const userAppointments = await prisma.eventAppointment.findMany({
|
||||
where: {
|
||||
Participants: {
|
||||
some: {
|
||||
userId: user.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const appointments = await prisma.eventAppointment.findMany({
|
||||
where: {
|
||||
appointmentDate: {
|
||||
gte: new Date(),
|
||||
},
|
||||
},
|
||||
include: {
|
||||
Participants: {
|
||||
where: {
|
||||
userId: user.id,
|
||||
},
|
||||
},
|
||||
_count: {
|
||||
select: {
|
||||
Participants: true,
|
||||
appointments: {
|
||||
include: {
|
||||
Participants: {
|
||||
where: {
|
||||
appointmentCancelled: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const filteredEvents = events.filter((event) => {
|
||||
if (eventCompleted(event, event.participants[0])) return false;
|
||||
const userParticipant = event.participants.find(
|
||||
(participant) => participant.userId === user.id,
|
||||
);
|
||||
if (eventCompleted(event, userParticipant)) return false;
|
||||
if (event.type === "OBLIGATED_COURSE" && !eventCompleted(event, event.participants[0]))
|
||||
return true;
|
||||
return false;
|
||||
@@ -78,8 +57,10 @@ const page = async () => {
|
||||
{filteredEvents.map((event) => {
|
||||
return (
|
||||
<KursItem
|
||||
appointments={appointments}
|
||||
selectedAppointments={userAppointments}
|
||||
appointments={event.appointments}
|
||||
selectedAppointments={event.appointments.filter((a) =>
|
||||
a.Participants.find((p) => p.userId == user.id),
|
||||
)}
|
||||
user={user}
|
||||
event={event}
|
||||
key={event.id}
|
||||
Reference in New Issue
Block a user