From d7d8bcaf8609231d90e2b4b3c09ac9ac9e9f9a9d Mon Sep 17 00:00:00 2001 From: BobChao87 Date: Tue, 16 Nov 2021 02:37:21 -0800 Subject: [PATCH] Calendar API call forDates is potentially a proxy for a future method Related to Issue #38 --- store/api/marathon.ts | 7 ++++++- types/api/marathon.d.ts | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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 {