diff --git a/frontend/src/api/courses.ts b/frontend/src/api/courses.ts index 23919d1d535b6d74882568816c597fdff90af252..28a090cfce029d5b4f29374c2ec3c8eac86d6ab1 100644 --- a/frontend/src/api/courses.ts +++ b/frontend/src/api/courses.ts @@ -1,19 +1,38 @@ +// src/api/courses.ts import $axios from '@/interceptors/axios' +import type { Course } from '@/interfaces' -export async function registerCourse(courseData: { - title: string - description: string - long_description: string - unit_id: number - keywords: string - level: string - learning_outcomes: string - code: string - hours?: number | null - date_published?: string - flavour?: number | null - question_set?: number | null -}) { - const response = await $axios.post('/api/courses/', courseData) - return response.data +export async function getCourses() { + const { data } = await $axios.get('/api/courses/') + return data +} + +export async function getCourseDetail(id: number | string) { + const { data } = await $axios.get(`/api/courses/${id}/`) + return data +} + +export async function createCourse(payload: Partial) { + const { data } = await $axios.post('/api/courses/', payload) + return data +} + +export async function updateCourse(id: number | string, payload: Partial) { + const { data } = await $axios.put(`/api/courses/${id}/`, payload) + return data +} + +export async function deleteCourse(id: number | string) { + const { data } = await $axios.delete(`/api/courses/${id}/`) + return data +} + +export async function addCourseInterest(courseId: number) { + const { data } = await $axios.post(`/api/courses/${courseId}/interest/`) + return data +} + +export async function removeCourseInterest(courseId: number) { + const { data } = await $axios.delete(`/api/courses/${courseId}/interest/`) + return data } diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.ts index ddc3bd08306c999798aaf2e2a5f35fcf5e72e763..a346350a6a24af8c544f989dcb573ddbab514f52 100644 --- a/frontend/src/api/index.ts +++ b/frontend/src/api/index.ts @@ -1,3 +1,6 @@ export * from './courses' export * from './sessions' export * from './units' +export * from './users' +export * from './locations' +export * from './questionSets' diff --git a/frontend/src/api/locations.ts b/frontend/src/api/locations.ts new file mode 100644 index 0000000000000000000000000000000000000000..2b22957e8cf06b3248915ade589dd3c813a73996 --- /dev/null +++ b/frontend/src/api/locations.ts @@ -0,0 +1,15 @@ +import $axios from '@/interceptors/axios' +import type { Location } from '@/interfaces' + +export interface LocationOption { + value: number + label: string +} + +export async function getLocations(): Promise { + const { data } = await $axios.get('/api/locations/') + return data.map(loc => ({ + value: loc.id, + label: loc.name + })) +} diff --git a/frontend/src/api/questionSets.ts b/frontend/src/api/questionSets.ts new file mode 100644 index 0000000000000000000000000000000000000000..604f52d87fe6fca2f5387d99f05b9c91f2f92bb1 --- /dev/null +++ b/frontend/src/api/questionSets.ts @@ -0,0 +1,46 @@ +import $axios from '@/interceptors/axios' +import type { QuestionSet } from '@/interfaces' + +/** + * Fetch all question sets, optionally filtered by level + */ +export async function getQuestionSets(level?: string): Promise { + const url = level ? `/api/question-sets/?level=${level}` : '/api/question-sets/' + const { data } = await $axios.get(url) + return data +} + +/** + * Fetch a single question set by ID + */ +export async function getQuestionSetDetail(id: number | string): Promise { + const { data } = await $axios.get(`/api/question-sets/${id}`) + return data +} + +/** + * Create a new question set + */ +export async function createQuestionSet(payload: Partial): Promise { + const { data } = await $axios.post('/api/question-sets/', payload) + return data +} + +/** + * Update an existing question set + */ +export async function updateQuestionSet( + id: number | string, + payload: Partial +): Promise { + const { data } = await $axios.put(`/api/question-sets/${id}`, payload) + return data +} + +/** + * Delete a question set + */ +export async function deleteQuestionSet(id: number | string): Promise { + const { data } = await $axios.delete(`/api/question-sets/${id}`) + return data +} diff --git a/frontend/src/api/sessions.ts b/frontend/src/api/sessions.ts index 05b30d4d23a156f8b69075f77588e26c0d2abbf2..eb9f9871eda37ed2f91249994ec6019b464d0997 100644 --- a/frontend/src/api/sessions.ts +++ b/frontend/src/api/sessions.ts @@ -45,3 +45,44 @@ export async function getSessionDetails(sessionId: number | string) { const response = await $axios.get(`/api/sessions/${sessionId}/`) return response.data } + +export async function createSession(payload: Record) { + const { data } = await $axios.post('/api/sessions/', payload) + return data +} + +export async function updateSession(sessionId: number | string, payload: Record) { + const { data } = await $axios.put(`/api/sessions/${sessionId}/`, payload) + return data +} + +export async function deleteSession(sessionId: number | string) { + const { data } = await $axios.delete(`/api/sessions/${sessionId}/`) + return data +} + +// Fetch registrations for a session +export async function getSessionRegistrations(sessionId: string | number) { + const { data } = await $axios.get(`/api/sessions/${sessionId}/registrations/`) + return data +} + +// Register user for a session +export async function registerSessionUser( + sessionId: string | number, + answers: Record +) { + const { data } = await $axios.post(`/api/sessions/${sessionId}/user-register/`, { answers }) + return data +} + +// Cancel user registration for a session +export async function cancelSessionRegistration(sessionId: string | number) { + const { data } = await $axios.delete(`/api/sessions/${sessionId}/user-register/`) + return data +} + +export async function getSessionsByCourse(): Promise> { + const { data } = await $axios.get('/api/sessions/list/by-course/') + return data +} diff --git a/frontend/src/api/users.ts b/frontend/src/api/users.ts new file mode 100644 index 0000000000000000000000000000000000000000..04cde3806d96618d0764e34861cf5b9e6d455f25 --- /dev/null +++ b/frontend/src/api/users.ts @@ -0,0 +1,27 @@ +import $axios from '@/interceptors/axios' +import type { CourseInterest } from '@/interfaces' + +export interface UserRegistrationsResponse { + upcoming: Registration[] + past: Registration[] +} + +export async function getUserCourseInterests() { + const { data } = await $axios.get('/api/users/course_interests/') + return data +} + +export async function getUsers(): Promise { + const { data } = await $axios.get('/api/users/') + return data +} + +export async function getLoggedUser(): Promise { + const { data } = await $axios.get('/api/users/logged_user/') + return data +} + +export async function getUserRegistrations(): Promise { + const { data } = await $axios.get('/api/users/registrations/') + return data +} diff --git a/frontend/src/composables/useCourseForm.ts b/frontend/src/composables/useCourseForm.ts index ad5b17221e3b5fcab7d7f5e42d5ce9d144ddd4a3..78ea8eedb55027ec9e6222db8759458fbfbdff57 100644 --- a/frontend/src/composables/useCourseForm.ts +++ b/frontend/src/composables/useCourseForm.ts @@ -1,19 +1,27 @@ +// src/composables/useCourseForm.ts import { ref } from 'vue' -import $axios from '@/interceptors/axios' import { useApiError } from './useApiError' -import type { Course, Unit } from '@/interfaces' + +import { + getUnits, + getCourses, + getCourseDetail, + createCourse as apiCreateCourse, + updateCourse as apiUpdateCourse, + deleteCourse as apiDeleteCourse +} from '@/api' export function useCourseForm() { - const units = ref([]) - const courses = ref([]) + const units = ref([]) + const courses = ref([]) const loading = ref(false) - const error = ref(null) + const error = ref(null) + const { handleError } = useApiError() async function fetchUnits() { try { - const res = await $axios.get('/api/units/') - units.value = res.data + units.value = await getUnits() return units.value } catch (err) { handleError(err, 'Fetch units') @@ -23,8 +31,7 @@ export function useCourseForm() { async function fetchCourses() { try { - const res = await $axios.get('/api/courses/') - courses.value = res.data + courses.value = await getCourses() return courses.value } catch (err) { handleError(err, 'Fetch courses') @@ -32,22 +39,20 @@ export function useCourseForm() { } } - async function fetchCourseDetail(courseId: number | string) { + async function fetchCourseDetail(id) { try { - const res = await $axios.get(`/api/courses/${courseId}/`) - return res.data + return await getCourseDetail(id) } catch (err) { handleError(err, 'Fetch course detail') throw err } } - async function createCourse(payload: Partial) { + async function createCourse(payload) { loading.value = true error.value = null try { - const res = await $axios.post('/api/courses/', payload) - return res.data + return await apiCreateCourse(payload) } catch (err) { error.value = err handleError(err, 'Create course') @@ -57,12 +62,11 @@ export function useCourseForm() { } } - async function updateCourse(courseId: number | string, payload: Partial) { + async function updateCourse(id, payload) { loading.value = true error.value = null try { - const res = await $axios.put(`/api/courses/${courseId}/`, payload) - return res.data + return await apiUpdateCourse(id, payload) } catch (err) { error.value = err handleError(err, 'Update course') @@ -72,11 +76,11 @@ export function useCourseForm() { } } - async function deleteCourse(courseId: number | string) { + async function deleteCourse(id) { loading.value = true error.value = null try { - await $axios.delete(`/api/courses/${courseId}/`) + await apiDeleteCourse(id) } catch (err) { error.value = err handleError(err, 'Delete course') diff --git a/frontend/src/composables/useCourseInterests.ts b/frontend/src/composables/useCourseInterests.ts index 4b98214417e5311b171fa6def7668945bccb061f..a8b0d8ed94ad37dea2c002fd4048f5a137fcfe7e 100644 --- a/frontend/src/composables/useCourseInterests.ts +++ b/frontend/src/composables/useCourseInterests.ts @@ -1,20 +1,25 @@ import { ref } from 'vue' -import $axios from '@/interceptors/axios' import { useApiError } from './useApiError' import type { CourseInterest } from '@/interfaces' +import { + getUserCourseInterests, + addCourseInterest as apiAddCourseInterest, + removeCourseInterest as apiRemoveCourseInterest +} from '@/api' + export function useCourseInterests() { const interests = ref([]) const loading = ref(false) const error = ref(null) + const { handleError } = useApiError() async function fetchCourseInterests() { loading.value = true error.value = null try { - const res = await $axios.get('/api/users/course_interests/') - interests.value = res.data + interests.value = await getUserCourseInterests() } catch (err) { error.value = err handleError(err, 'Fetch course interests') @@ -25,7 +30,7 @@ export function useCourseInterests() { async function addCourseInterest(courseId: number) { try { - await $axios.post(`/api/courses/${courseId}/interest/`) + await apiAddCourseInterest(courseId) await fetchCourseInterests() } catch (err) { handleError(err, 'Add course interest') @@ -35,7 +40,7 @@ export function useCourseInterests() { async function removeCourseInterest(courseId: number) { try { - await $axios.delete(`/api/courses/${courseId}/interest/`) + await apiRemoveCourseInterest(courseId) await fetchCourseInterests() } catch (err) { handleError(err, 'Remove course interest') diff --git a/frontend/src/composables/useCourses.ts b/frontend/src/composables/useCourses.ts index 653ebb3afa389bdb182309ddccb36c390606c226..a9617320ced1ac6c8c46c61282c67fb910b5a483 100644 --- a/frontend/src/composables/useCourses.ts +++ b/frontend/src/composables/useCourses.ts @@ -1,20 +1,20 @@ import { ref } from 'vue' -import $axios from '@/interceptors/axios' import { useApiError } from './useApiError' import type { Course } from '@/interfaces' +import { getCourses } from '@/api' export function useCourses() { const courses = ref([]) const loading = ref(false) const error = ref(null) + const { handleError } = useApiError() async function fetchCourses() { loading.value = true error.value = null try { - const res = await $axios.get('/api/courses/') - courses.value = res.data + courses.value = await getCourses() } catch (err) { error.value = err handleError(err, 'Fetch courses') diff --git a/frontend/src/composables/useDateHelpers.ts b/frontend/src/composables/useDateHelpers.ts index c228d1e29687ca86d293b9f24bae7b8b197397ff..80919e7ed40108390d4d4ebe38ce042e928cd8b2 100644 --- a/frontend/src/composables/useDateHelpers.ts +++ b/frontend/src/composables/useDateHelpers.ts @@ -1,4 +1,4 @@ -// src/composables/useDateHelpers.ts +// src/composable/useDateHelpers.ts export function formatDate(isoDate: string): string { return new Date(isoDate).toLocaleString('en-GB', { day: 'numeric', diff --git a/frontend/src/composables/useLocations.ts b/frontend/src/composables/useLocations.ts index 7edddc5be84c91c3ac13ab790c17f32b48bc156b..e22b3d0e65b8cae1af2d07594a250a553ef1860b 100644 --- a/frontend/src/composables/useLocations.ts +++ b/frontend/src/composables/useLocations.ts @@ -1,27 +1,20 @@ import { ref } from 'vue' -import $axios from '@/interceptors/axios' import { useApiError } from './useApiError' - -export interface LocationOption { - value: number - label: string -} +import type { LocationOption } from '@/api' +import { getLocations } from '@/api' export function useLocations() { const locations = ref([]) const loading = ref(false) const error = ref(null) + const { handleError } = useApiError() async function fetchLocations() { loading.value = true error.value = null try { - const res = await $axios.get('/api/locations/') - locations.value = res.data.map((loc: { id: number; name: string }) => ({ - value: loc.id, - label: loc.name - })) + locations.value = await getLocations() } catch (err) { error.value = err handleError(err, 'Fetch locations') diff --git a/frontend/src/composables/useQuestionSetMutations.ts b/frontend/src/composables/useQuestionSetMutations.ts index b269f1e19fbf42be0ed42e51253dc2ad0e6c999d..d51d28de597e1ab214a51e9a9fb84643f1a97062 100644 --- a/frontend/src/composables/useQuestionSetMutations.ts +++ b/frontend/src/composables/useQuestionSetMutations.ts @@ -1,19 +1,42 @@ import { ref } from 'vue' -import $axios from '@/interceptors/axios' import { useApiError } from './useApiError' import type { QuestionSet } from '@/interfaces' +import { + getQuestionSets, + getQuestionSetDetail, + createQuestionSet as apiCreateQuestionSet, + updateQuestionSet as apiUpdateQuestionSet, + deleteQuestionSet as apiDeleteQuestionSet +} from '@/api' export function useQuestionSetMutations() { const loading = ref(false) const error = ref(null) const { handleError } = useApiError() + async function fetchQuestionSets(level?: string) { + try { + return await getQuestionSets(level) + } catch (err) { + handleError(err, 'Fetch question sets') + throw err + } + } + + async function fetchQuestionSetDetail(id: number | string) { + try { + return await getQuestionSetDetail(id) + } catch (err) { + handleError(err, 'Fetch question set detail') + throw err + } + } + async function createQuestionSet(payload: Partial) { loading.value = true error.value = null try { - const res = await $axios.post('/api/question-sets/', payload) - return res.data + return await apiCreateQuestionSet(payload) } catch (err) { error.value = err handleError(err, 'Create question set') @@ -27,8 +50,7 @@ export function useQuestionSetMutations() { loading.value = true error.value = null try { - const res = await $axios.put(`/api/question-sets/${id}`, payload) - return res.data + return await apiUpdateQuestionSet(id, payload) } catch (err) { error.value = err handleError(err, 'Update question set') @@ -42,7 +64,7 @@ export function useQuestionSetMutations() { loading.value = true error.value = null try { - await $axios.delete(`/api/question-sets/${id}`) + await apiDeleteQuestionSet(id) } catch (err) { error.value = err handleError(err, 'Delete question set') @@ -52,35 +74,13 @@ export function useQuestionSetMutations() { } } - async function fetchQuestionSets(level?: string) { - try { - const res = await $axios.get( - level ? `/api/question-sets/?level=${level}` : '/api/question-sets/' - ) - return res.data - } catch (err) { - handleError(err, 'Fetch question sets') - throw err - } - } - - async function fetchQuestionSetDetail(id: number | string) { - try { - const res = await $axios.get(`/api/question-sets/${id}`) - return res.data - } catch (err) { - handleError(err, 'Fetch question set detail') - throw err - } - } - return { loading, error, + fetchQuestionSets, + fetchQuestionSetDetail, createQuestionSet, updateQuestionSet, - deleteQuestionSet, - fetchQuestionSets, - fetchQuestionSetDetail + deleteQuestionSet } } diff --git a/frontend/src/composables/useSessionForm.ts b/frontend/src/composables/useSessionForm.ts index c734831b67a68861be6c02e091d47e9659e7a342..863fb1296f794cf5c479a6ceaff737376faa8277 100644 --- a/frontend/src/composables/useSessionForm.ts +++ b/frontend/src/composables/useSessionForm.ts @@ -1,6 +1,17 @@ import { ref } from 'vue' -import $axios from '@/interceptors/axios' import { useApiError } from './useApiError' +import { + getCourses, + getUsers, + getLocations, + getQuestionSets, + getQuestionSetDetail, + getSessionDetails, + createSession as apiCreateSession, + updateSession as apiUpdateSession, + deleteSession as apiDeleteSession, +} from '@/api' + import type { Course, Location, QuestionSet, User } from '@/interfaces' export function useSessionForm() { @@ -14,8 +25,7 @@ export function useSessionForm() { async function fetchCourses(): Promise { try { - const res = await $axios.get('/api/courses/') - courses.value = res.data + courses.value = await getCourses() return courses.value } catch (err) { handleError(err, 'Fetch courses') @@ -25,8 +35,7 @@ export function useSessionForm() { async function fetchUsers(): Promise { try { - const res = await $axios.get('/api/users/') - users.value = res.data + users.value = await getUsers() return users.value } catch (err) { handleError(err, 'Fetch users') @@ -36,8 +45,7 @@ export function useSessionForm() { async function fetchLocations(): Promise { try { - const res = await $axios.get('/api/locations/') - locations.value = res.data + locations.value = await getLocations() return locations.value } catch (err) { handleError(err, 'Fetch locations') @@ -47,8 +55,7 @@ export function useSessionForm() { async function fetchQuestionSets(level = 'S'): Promise { try { - const res = await $axios.get(`/api/question-sets/?level=${level}`) - questionSets.value = res.data + questionSets.value = await getQuestionSets(level) return questionSets.value } catch (err) { handleError(err, 'Fetch question sets') @@ -58,8 +65,7 @@ export function useSessionForm() { async function fetchQuestionSetDetail(id: number): Promise { try { - const res = await $axios.get(`/api/question-sets/${id}`) - return res.data + return await getQuestionSetDetail(id) } catch (err) { handleError(err, 'Fetch question set') throw err @@ -68,8 +74,7 @@ export function useSessionForm() { async function fetchSessionDetail(sessionId: number | string) { try { - const res = await $axios.get(`/api/sessions/${sessionId}/`) - return res.data + return await getSessionDetails(sessionId) } catch (err) { handleError(err, 'Fetch session detail') throw err @@ -79,9 +84,9 @@ export function useSessionForm() { async function createSession(payload: Record) { loading.value = true error.value = null + try { - const res = await $axios.post('/api/sessions/', payload) - return res.data + return await apiCreateSession(payload) } catch (err) { error.value = err handleError(err, 'Create session') @@ -94,9 +99,9 @@ export function useSessionForm() { async function updateSession(sessionId: number | string, payload: Record) { loading.value = true error.value = null + try { - const res = await $axios.put(`/api/sessions/${sessionId}/`, payload) - return res.data + return await apiUpdateSession(sessionId, payload) } catch (err) { error.value = err handleError(err, 'Update session') @@ -109,8 +114,9 @@ export function useSessionForm() { async function deleteSession(sessionId: number | string) { loading.value = true error.value = null + try { - await $axios.delete(`/api/sessions/${sessionId}/`) + return await apiDeleteSession(sessionId) } catch (err) { error.value = err handleError(err, 'Delete session') @@ -135,6 +141,6 @@ export function useSessionForm() { fetchSessionDetail, createSession, updateSession, - deleteSession + deleteSession, } } diff --git a/frontend/src/composables/useSessionRegistrations.ts b/frontend/src/composables/useSessionRegistrations.ts index 00bd074c5872536209771fb9f33d050bed98bb7b..00b7afd1065c28a949ea6620b7fb72c39c6d27fb 100644 --- a/frontend/src/composables/useSessionRegistrations.ts +++ b/frontend/src/composables/useSessionRegistrations.ts @@ -1,6 +1,11 @@ import { ref, isRef, type Ref } from 'vue' -import $axios from '@/interceptors/axios' import { useApiError } from './useApiError' +import { + getSessionRegistrations, + registerSessionUser, + cancelSessionRegistration, +} from '@/api' + export interface SessionRegistrationPayload { questions: Array<{ @@ -28,9 +33,7 @@ export function useSessionRegistrations(sessionId: Ref | string loading.value = true error.value = null try { - const res = await $axios.get( - `/api/sessions/${id.value}/registrations/` - ) + const res = await getSessionRegistrations(id.value) questions.value = res.data.questions registrations.value = res.data.registrations isRegistered.value = res.data.registered @@ -47,7 +50,7 @@ export function useSessionRegistrations(sessionId: Ref | string answers: Record ) { try { - await $axios.post(`/api/sessions/${sessionIdentifier}/user-register/`, { answers }) + await registerSessionUser(sessionIdentifier, answers) isRegistered.value = true await fetchRegistrations() } catch (err) { @@ -59,7 +62,7 @@ export function useSessionRegistrations(sessionId: Ref | string async function cancelRegistration() { if (!id.value) return try { - await $axios.delete(`/api/sessions/${id.value}/user-register/`) + await cancelSessionRegistration(id.value) isRegistered.value = false await fetchRegistrations() } catch (err) { @@ -76,6 +79,6 @@ export function useSessionRegistrations(sessionId: Ref | string error, fetchRegistrations, registerForSession, - cancelRegistration + cancelRegistration, } } diff --git a/frontend/src/composables/useSessionsListByCourse.ts b/frontend/src/composables/useSessionsListByCourse.ts index 5a48637c27cf0cc5afcaf7abe266e4fe5ac38b10..6962aa3ce5b3f9f4e67a05589b399c3a3520d19b 100644 --- a/frontend/src/composables/useSessionsListByCourse.ts +++ b/frontend/src/composables/useSessionsListByCourse.ts @@ -1,6 +1,6 @@ import { ref } from 'vue' -import $axios from '@/interceptors/axios' import { useApiError } from './useApiError' +import { getSessionsByCourse } from '@/api' import type { Session } from '@/interfaces' export function useSessionsListByCourse() { @@ -13,8 +13,7 @@ export function useSessionsListByCourse() { loading.value = true error.value = null try { - const res = await $axios.get('/api/sessions/list/by-course/') - sessionsByCourse.value = res.data + sessionsByCourse.value = await getSessionsByCourse() } catch (err) { error.value = err handleError(err, 'Fetch sessions by course') @@ -27,6 +26,6 @@ export function useSessionsListByCourse() { sessionsByCourse, loading, error, - fetchSessionsByCourse + fetchSessionsByCourse, } } diff --git a/frontend/src/composables/useUser.ts b/frontend/src/composables/useUser.ts index 815612cec5cc58e3ebf3cf8294960055d217e425..081c488cccbb2358b4da761e7474e946201daa21 100644 --- a/frontend/src/composables/useUser.ts +++ b/frontend/src/composables/useUser.ts @@ -1,6 +1,6 @@ import { ref } from 'vue' -import $axios from '@/interceptors/axios' import { useApiError } from './useApiError' +import { getLoggedUser } from '@/api' import type { User } from '@/interfaces' export function useUser() { @@ -13,8 +13,7 @@ export function useUser() { loading.value = true error.value = null try { - const res = await $axios.get('/api/users/logged_user/') - user.value = res.data + user.value = await getLoggedUser() } catch (err) { error.value = err handleError(err, 'Fetch user') @@ -27,6 +26,6 @@ export function useUser() { user, loading, error, - fetchLoggedUser + fetchLoggedUser, } } diff --git a/frontend/src/composables/useUserRegistrations.ts b/frontend/src/composables/useUserRegistrations.ts index f69b20118feb1de210a1cef0ed816e10ae795876..ca22c3317584b7de807ea1bf0dc5f1ca835c4595 100644 --- a/frontend/src/composables/useUserRegistrations.ts +++ b/frontend/src/composables/useUserRegistrations.ts @@ -1,6 +1,6 @@ import { ref } from 'vue' -import $axios from '@/interceptors/axios' import { useApiError } from './useApiError' +import { getUserRegistrations, type UserRegistrationsResponse } from '@/api' import type { Registration } from '@/interfaces' export function useUserRegistrations() { @@ -14,9 +14,9 @@ export function useUserRegistrations() { loading.value = true error.value = null try { - const res = await $axios.get('/api/users/registrations/') - upcoming.value = res.data.upcoming - past.value = res.data.past + const res: UserRegistrationsResponse = await getUserRegistrations() + upcoming.value = res.upcoming + past.value = res.past } catch (err) { error.value = err handleError(err, 'Fetch registrations') @@ -30,6 +30,6 @@ export function useUserRegistrations() { past, loading, error, - fetchUserRegistrations + fetchUserRegistrations, } }