Files
var-monorepo/apps/hub/app/(app)/events/actions.ts
2025-02-28 07:21:07 +01:00

27 lines
583 B
TypeScript

"use server";
import { enrollUserInCourse } from "../../../helper/moodle";
import { prisma } from "@repo/db";
export const inscribeToMoodleCourse = async (
moodleCourseId: string | number,
userMoodleId: string | number,
) => {
await enrollUserInCourse(moodleCourseId, userMoodleId);
};
export const addParticipant = async (eventId: number, userId: string) => {
const participant = await prisma.participant.findFirst({
where: {
userId: userId,
},
});
if (!participant) {
await prisma.participant.create({
data: {
userId: userId,
eventId,
},
});
}
};