New and Improved Screens (#1151)

This commit is contained in:
Luke Vella 2024-06-19 11:14:18 +01:00 committed by GitHub
parent 5461c57228
commit 997a1eec78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
75 changed files with 1517 additions and 743 deletions

View file

@ -0,0 +1,49 @@
import { prisma } from "@rallly/database";
export type EventPeriod = "upcoming" | "past";
/**
* List upcoming events for a user grouped by day
* @param userId
*/
export async function listScheduledEvents({
userId,
period,
}: {
userId: string;
period: EventPeriod;
}) {
const events = await prisma.event.findMany({
select: {
id: true,
title: true,
start: true,
duration: true,
poll: {
select: {
timeZone: true,
participants: {
select: {
id: true,
name: true,
},
},
},
},
},
where: {
userId,
start: period === "upcoming" ? { gte: new Date() } : { lt: new Date() },
},
orderBy: [
{
start: "desc",
},
{
title: "asc",
},
],
});
return events;
}