From 850affbd55fee9cd48a82ade94a3a5e60fd737a8 Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Wed, 22 Jan 2025 02:09:56 +0000 Subject: Add version and some icons --- composables/fetch-schedule.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 composables/fetch-schedule.ts (limited to 'composables/fetch-schedule.ts') diff --git a/composables/fetch-schedule.ts b/composables/fetch-schedule.ts new file mode 100644 index 0000000..09d0a25 --- /dev/null +++ b/composables/fetch-schedule.ts @@ -0,0 +1,24 @@ +export default function useFetchFavourites() { + const scheduleStore = useScheduleStore(); + const errorStore = useErrorStore(); + const config = useRuntimeConfig(); + + useFetch(config.public.baseURL + '/schedule', { + method: 'GET', + server: false, + lazy: true, + onResponse: ({ response }) => { + if (!response.ok) { + if (response.status === 401) { + navigateTo({ name: 'login', state: { error: 'Sorry, your session has expired' } }); + } else { + errorStore.setError(response._data.message || 'An unknown error occurred'); + } + } + + if (response._data) { + scheduleStore.setSchedule((response._data as any).data.schedule); + } + }, + }); +} \ No newline at end of file -- cgit v1.2.3-70-g09d2