diff --git a/src/components/Events/EventList.vue b/src/components/Events/EventList.vue new file mode 100644 index 0000000..389f3f7 --- /dev/null +++ b/src/components/Events/EventList.vue @@ -0,0 +1,32 @@ + + + + + diff --git a/src/components/Events/EventListItem.vue b/src/components/Events/EventListItem.vue new file mode 100644 index 0000000..ea3cc06 --- /dev/null +++ b/src/components/Events/EventListItem.vue @@ -0,0 +1,45 @@ + + + + + diff --git a/src/lib/date.ts b/src/lib/date.ts new file mode 100644 index 0000000..bd4015f --- /dev/null +++ b/src/lib/date.ts @@ -0,0 +1,15 @@ +export const getTimeString = (date: Date): string => + date.getHours().toString().padStart(2, '0') + + ':' + + date.getMinutes().toString().padStart(2, '0') + +export const getDayString = (date: Date): string => + (date.getMonth() + 1).toString().padStart(2, '0') + + '/' + + date.getDate().toString().padStart(2, '0') + +export const getFullDayString = (date: Date): string => + date.getFullYear() + '/' + getDayString(date) + +export const getFullDayWithTimeString = (date: Date): string => + getFullDayString(date) + ' ' + getTimeString(date) diff --git a/src/pages/Events.vue b/src/pages/Events.vue index db7a7c0..e49cd05 100644 --- a/src/pages/Events.vue +++ b/src/pages/Events.vue @@ -1,11 +1,41 @@ + + diff --git a/src/store/actions.ts b/src/store/actions.ts index 8daf120..28edc87 100644 --- a/src/store/actions.ts +++ b/src/store/actions.ts @@ -1,6 +1,6 @@ import { defineActions } from 'direct-vuex' import { rootActionContext } from '.' -import apis, { Group } from '/@/lib/apis' +import apis, { Group, Event } from '/@/lib/apis' export const actions = defineActions({ async fetchGroups(context): Promise { @@ -13,5 +13,16 @@ export const actions = defineActions({ const res = await apis.getGroups() commit.setGroups(res.data) return res.data + }, + async fetchEvents(context): Promise { + const { state, commit } = rootActionContext(context) + + if (state.events !== null) { + return state.events + } + + const res = await apis.getEvents() + commit.setEvents(res.data) + return res.data } }) diff --git a/src/store/mutations.ts b/src/store/mutations.ts index 91eef68..3aa705d 100644 --- a/src/store/mutations.ts +++ b/src/store/mutations.ts @@ -1,9 +1,12 @@ import { defineMutations } from 'direct-vuex' import { S } from './state' -import { Group } from '/@/lib/apis' +import { Group, Event } from '/@/lib/apis' export const mutations = defineMutations()({ setGroups(state: S, groups: Group[]) { state.groups = groups + }, + setEvents(state: S, events: Event[]) { + state.events = events } }) diff --git a/src/store/state.ts b/src/store/state.ts index eb7b80a..b03bbe5 100644 --- a/src/store/state.ts +++ b/src/store/state.ts @@ -1,9 +1,11 @@ -import { Group } from '/@/lib/apis' +import { Group, Event } from '/@/lib/apis' export interface S { groups: Group[] | null + events: Event[] | null } export const state: S = { - groups: null + groups: null, + events: null }