mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-28 08:16:22 +02:00
✨ New and Improved Screens (#1151)
This commit is contained in:
parent
5461c57228
commit
997a1eec78
75 changed files with 1517 additions and 743 deletions
49
packages/features/scheduled-events/api.ts
Normal file
49
packages/features/scheduled-events/api.ts
Normal 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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue