Skip to content

Commit

Permalink
Calendar API call
Browse files Browse the repository at this point in the history
forDates is potentially a proxy for a future method

Related to Issue #38
  • Loading branch information
BobChao87 committed Nov 16, 2021
1 parent 0c0328e commit d7d8bca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion store/api/marathon.ts
Original file line number Diff line number Diff line change
@@ -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<MarathonState>('marathons');

export const state = (): MarathonState => ({
marathons: { },
calendars: { },
frontPage: undefined,
});

Expand All @@ -17,9 +18,13 @@ export const mutations: MutationTree<MarathonState> = {
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<MarathonState, MarathonState> = {
get: MarathonOengusAPI.get<FullMarathon>({ key: 'marathons', mutation: 'addMarathon' }),
frontPage: MarathonOengusAPI.get<FrontPageMarathons>({ key: 'frontPage' }),
calendar: MarathonOengusAPI.get<Array<Marathon>>({ path: 'forDates', key: 'calendars' }),
};
10 changes: 10 additions & 0 deletions types/api/marathon.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,19 @@ export interface FrontPageMarathons {

export interface MarathonState extends OengusState {
marathons: { [id: string]: FullMarathon };
calendars: { [date: string]: Array<Marathon> };
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 {
Expand Down

0 comments on commit d7d8bca

Please sign in to comment.