27 lines
583 B
TypeScript
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,
|
|
},
|
|
});
|
|
}
|
|
};
|