remove appointment from events
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
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({
|
||||
@@ -11,34 +12,22 @@ export const upsertEvent = async (event: Prisma.EventCreateInput, id?: Event["id
|
||||
: await prisma.event.create({ data: event });
|
||||
return newEvent;
|
||||
};
|
||||
|
||||
export const deleteEvent = async (id: Event["id"]) => {
|
||||
await prisma.event.delete({ where: { id: id } });
|
||||
};
|
||||
|
||||
export const upsertAppointment = async (
|
||||
eventAppointment: Prisma.EventAppointmentUncheckedCreateInput,
|
||||
) => {
|
||||
const newEventAppointment = eventAppointment.id
|
||||
? await prisma.eventAppointment.update({
|
||||
where: { id: eventAppointment.id },
|
||||
data: eventAppointment,
|
||||
//############# Participant //#############
|
||||
|
||||
export const upsertParticipant = async (participant: Prisma.ParticipantUncheckedCreateInput) => {
|
||||
const newParticipant = participant.id
|
||||
? await prisma.participant.update({
|
||||
where: { id: participant.id },
|
||||
data: participant,
|
||||
})
|
||||
: await prisma.eventAppointment.create({ data: eventAppointment });
|
||||
return newEventAppointment;
|
||||
: await prisma.participant.create({ data: participant });
|
||||
return newParticipant;
|
||||
};
|
||||
|
||||
export const deleteAppoinement = async (id: Event["id"]) => {
|
||||
await prisma.eventAppointment.delete({ where: { id: id } });
|
||||
prisma.eventAppointment.findMany({
|
||||
where: {
|
||||
eventId: id,
|
||||
},
|
||||
orderBy: {
|
||||
// TODO: add order by in relation to table selected column
|
||||
},
|
||||
});
|
||||
};
|
||||
export const deleteParticipant = async (id: Participant["id"]) => {
|
||||
await prisma.participant.delete({ where: { id: id } });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user