diff --git a/store/api/marathon.ts b/store/api/marathon.ts index 3e9f5150..9d5327be 100644 --- a/store/api/marathon.ts +++ b/store/api/marathon.ts @@ -18,13 +18,18 @@ export const mutations: MutationTree = { addFrontPage(state, { value: frontPage }): void { Vue.set(state, 'frontPage', frontPage); }, - addSchedule(state, { value: schedule, data }): void { - Vue.set(state.calendars, `${data.start}-${data.end}`, schedule); + addCalendar(state, { value: calendar, data }): void { + Vue.set(state.calendars, `${data.start}-${data.end}`, calendar); }, }; export const actions: ActionTree = { get: MarathonOengusAPI.get({ key: 'marathons', mutation: 'addMarathon' }), frontPage: MarathonOengusAPI.get({ key: 'frontPage' }), - calendar: MarathonOengusAPI.get>({ path: 'forDates', key: 'calendars' }), + calendar: MarathonOengusAPI.get, { calendar: Array }>({ + path: 'forDates', + key: 'calendars', + mutation: 'addCalendar', + transform: ({ value: calendar }) => ({ calendar }), + }), }; diff --git a/types/api/marathon.d.ts b/types/api/marathon.d.ts index b49ae292..96c5f947 100644 --- a/types/api/marathon.d.ts +++ b/types/api/marathon.d.ts @@ -66,9 +66,13 @@ export interface FrontPageMarathons { live: Array; } +export interface Calendars { + [date: string]: { calendar: Array }; +} + export interface MarathonState extends OengusState { marathons: { [id: string]: FullMarathon }; - calendars: { [date: string]: Array }; + calendars: Calendars; frontPage?: FrontPageMarathons; }