diff --git a/store/api/marathon.ts b/store/api/marathon.ts index 375cdaf2..3e9f5150 100644 --- a/store/api/marathon.ts +++ b/store/api/marathon.ts @@ -1,12 +1,13 @@ import Vue from 'vue'; import { ActionTree, MutationTree } from 'vuex'; import { OengusAPI } from '~/plugins/oengus'; -import { FrontPageMarathons, FullMarathon, MarathonState } from '~/types/api/marathon'; +import { FrontPageMarathons, FullMarathon, Marathon, MarathonState } from '~/types/api/marathon'; const MarathonOengusAPI = new OengusAPI('marathons'); export const state = (): MarathonState => ({ marathons: { }, + calendars: { }, frontPage: undefined, }); @@ -17,9 +18,13 @@ 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); + }, }; export const actions: ActionTree = { get: MarathonOengusAPI.get({ key: 'marathons', mutation: 'addMarathon' }), frontPage: MarathonOengusAPI.get({ key: 'frontPage' }), + calendar: MarathonOengusAPI.get>({ path: 'forDates', key: 'calendars' }), }; diff --git a/types/api/marathon.d.ts b/types/api/marathon.d.ts index 1462f8aa..d562a7eb 100644 --- a/types/api/marathon.d.ts +++ b/types/api/marathon.d.ts @@ -68,9 +68,19 @@ export interface FrontPageMarathons { export interface MarathonState extends OengusState { marathons: { [id: string]: FullMarathon }; + calendars: { [date: string]: Array }; frontPage?: FrontPageMarathons; } +export interface MarathonForDateParams { + /** ISO Date string */ + start: string; + /** ISO Date string */ + end: string; + /** IANA Time Zone name */ + zoneId: string; +} + export type QuestionType = 'TEXT'|'SELECT'|'TEXTAREA'|'CHECKBOX'|'FREETEXT'; export interface Question {