|
|
@@ -6,39 +6,32 @@ const state = {
|
|
6
|
6
|
singleExhibition: null,
|
|
7
|
7
|
}
|
|
8
|
8
|
|
|
|
9
|
+const now = new Date()
|
|
|
10
|
+
|
|
9
|
11
|
const getters = {
|
|
10
|
12
|
allExhibitions: state => state.all,
|
|
11
|
13
|
allExhibitionsLoaded: state => state.loaded,
|
|
12
|
|
- pastExhibitions: state => {
|
|
13
|
|
- return state.all.filter(exhibition => {
|
|
14
|
|
- const now = new Date()
|
|
15
|
|
- return parseInt(exhibition.end) > now
|
|
16
|
|
- })
|
|
17
|
|
- },
|
|
18
|
|
- upcomingAndCurrentExhibitions: state => {
|
|
19
|
|
- return state.all
|
|
20
|
|
- // return state.all.filter(exhibition => {
|
|
21
|
|
- // const now = new Date()
|
|
22
|
|
- // // return parseInt(exhibition.end) <= now
|
|
23
|
|
- // return parseInt(exhibition.end) <= now
|
|
24
|
|
- // })
|
|
25
|
|
- },
|
|
|
14
|
+ pastExhibitions: state => state.all.filter(exhibition => parseInt(exhibition.end) > now),
|
|
|
15
|
+ upcomingAndCurrentExhibitions: state => state.all,
|
|
|
16
|
+ // upcomingAndCurrentExhibitions: state => state.all.filter(exhibition => parseInt(exhibition.end) <= now)
|
|
26
|
17
|
}
|
|
27
|
18
|
|
|
28
|
19
|
const actions = {
|
|
29
|
20
|
getAllExhibitions({ commit },{ sortType, params }) {
|
|
30
|
21
|
commit('CLEAR_EXHIBITIONS')
|
|
31
|
22
|
commit('EXHIBITIONS_LOADED', false)
|
|
32
|
|
- return api.getByType({ type: 'exhibition', sort: sortType, cb: exhibitions => {
|
|
|
23
|
+ const storeFetch = (exhibitions => {
|
|
33
|
24
|
commit('STORE_FETCHED_EXHIBITIONS', { exhibitions })
|
|
34
|
25
|
commit('EXHIBITIONS_LOADED', true)
|
|
35
|
|
- }, params })
|
|
|
26
|
+ })
|
|
|
27
|
+ return api.getByType({ type: 'exhibition', sort: sortType, params, cb: storeFetch })
|
|
36
|
28
|
},
|
|
37
|
|
- getMoreExhibitions({ commit },{ sortType, params }) {
|
|
38
|
|
- return api.getByType({ type: 'exhibition', sort: sortType, cb: exhibitions => {
|
|
|
29
|
+ getMoreExhibitions({ commit }, { sortType, params }) {
|
|
|
30
|
+ const storeFetch = (exhibitions => {
|
|
39
|
31
|
commit('ADD_TO_FETCHED_EXHIBITIONS', { exhibitions })
|
|
40
|
32
|
commit('EXHIBITIONS_LOADED', true)
|
|
41
|
|
- }, params })
|
|
|
33
|
+ })
|
|
|
34
|
+ return api.getByType({ type: 'exhibition', sort: sortType, params, cb: storeFetch })
|
|
42
|
35
|
},
|
|
43
|
36
|
getSingleExhibition({ commit }, id) {
|
|
44
|
37
|
commit('CLEAR_SINGLE_EXHIBITIONS')
|