Files
var-monorepo/apps/hub/app/(app)/admin/event/action.ts
2026-01-18 01:09:39 +01:00

34 lines
985 B
TypeScript

"use server";
import { prisma, Prisma, Event, Participant } from "@repo/db";
//############# Event //#############
export const upsertEvent = async (event: Prisma.EventCreateInput, id?: Event["id"]) => {
const newEvent = id
? await prisma.event.update({
where: { id: id },
data: event,
})
: await prisma.event.create({ data: event });
return newEvent;
};
export const deleteEvent = async (id: Event["id"]) => {
await prisma.event.delete({ where: { id: id } });
};
//############# Participant //#############
export const upsertParticipant = async (participant: Prisma.ParticipantUncheckedCreateInput) => {
const newParticipant = participant.id
? await prisma.participant.update({
where: { id: participant.id },
data: participant,
})
: await prisma.participant.create({ data: participant });
return newParticipant;
};
export const deleteParticipant = async (id: Participant["id"]) => {
await prisma.participant.delete({ where: { id: id } });
};