43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { Event, EventAppointment, Participant, Prisma } from "@repo/db";
|
|
import axios from "axios";
|
|
import { da } from "date-fns/locale";
|
|
|
|
export const getEvents = async (filter: Prisma.EventWhereInput) => {
|
|
const { data } = await axios.get<
|
|
(Event & {
|
|
Appointments: (EventAppointment & {
|
|
Appointments: EventAppointment[];
|
|
Participants: Participant[];
|
|
})[];
|
|
Participants: Participant[];
|
|
})[]
|
|
>(`/api/event`, {
|
|
params: {
|
|
filter: JSON.stringify(filter),
|
|
},
|
|
});
|
|
return data;
|
|
};
|
|
|
|
export const eventCompleted = (event: Event, participant?: Participant) => {
|
|
if (!participant) return false;
|
|
if (event.finisherMoodleCourseId && !participant.finisherMoodleCurseCompleted) return false;
|
|
if (event.hasPresenceEvents && !participant.attended) return false;
|
|
return true;
|
|
};
|
|
|
|
export const handleParticipantFinished = async (participantId: string) =>
|
|
axios.post(`${process.env.NEXT_PUBLIC_HUB_SERVER_URL}/event/handle-participant-finished`, {
|
|
participantId,
|
|
});
|
|
|
|
export const checkMoodleResults = async (participantId: string) =>
|
|
axios.post(`${process.env.NEXT_PUBLIC_HUB_SERVER_URL}/event/check-moodle-results`, {
|
|
participantId,
|
|
});
|
|
|
|
export const handleParticipantEnrolled = async (participantId: string) =>
|
|
axios.post(`${process.env.NEXT_PUBLIC_HUB_SERVER_URL}/event/handle-participant-enrolled`, {
|
|
participantId,
|
|
});
|