aboutsummaryrefslogtreecommitdiffstats
path: root/web/composables/fetch-schedule.ts
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.com>2025-08-23 22:29:28 +0100
committerLeonardo Bishop <me@leonardobishop.com>2025-08-23 22:29:28 +0100
commitecc6a55aba7bb35fc778e7a53848396b88214151 (patch)
tree1b37a2dc5f4594155114da1ae0c4529d20a4c548 /web/composables/fetch-schedule.ts
parent8f7dec8ba6b2f9bde01afd0a110596ebbd43e0ed (diff)
Add multiple conferences feature
Diffstat (limited to 'web/composables/fetch-schedule.ts')
-rw-r--r--web/composables/fetch-schedule.ts57
1 files changed, 36 insertions, 21 deletions
diff --git a/web/composables/fetch-schedule.ts b/web/composables/fetch-schedule.ts
index a0e6fec..5e91954 100644
--- a/web/composables/fetch-schedule.ts
+++ b/web/composables/fetch-schedule.ts
@@ -1,24 +1,39 @@
-export default function() {
- 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({ path: '/login', state: { error: 'Sorry, your session has expired' } });
- } else {
- errorStore.setError(response._data.message || 'An unknown error occurred');
- }
- }
+import { useConferenceStore } from "~/stores/conference";
+import { expireAuth } from "./expire-auth";
+
+export default async function() {
+ const conferenceStore = useConferenceStore()
+ const scheduleStore = useScheduleStore();
+ const errorStore = useErrorStore();
+ const config = useRuntimeConfig();
- if (response._data) {
- scheduleStore.setSchedule((response._data as any).data.schedule);
+ scheduleStore.status = 'pending'
+
+ return $api(config.public.baseURL + '/conference/' + conferenceStore.id, {
+ method: 'GET',
+ onResponse: ({ response }) => {
+ if (!response.ok) {
+ if (response.status === 401) {
+ expireAuth()
+ return
+ } else {
+ errorStore.setError(response._data.message || 'An unknown error occurred');
}
- },
- });
+ }
+
+ if (response._data) {
+ let schedule = (response._data as any).data.schedule
+ scheduleStore.setSchedule(schedule);
+
+ conferenceStore.venue = schedule.conference.venue
+ conferenceStore.title = schedule.conference.title
+ conferenceStore.city = schedule.conference.city
+
+ scheduleStore.status = 'idle'
+ }
+ },
+ }).catch(() => {
+ // todo do this better
+ errorStore.setError('An unknown error occurred');
+ });
} \ No newline at end of file