flatisfy/flatisfy/web/js_src/store/actions.js
Phyks (Lucas Verney) 0e3d1576b2
Use stars to note flats
Instead of a binary "followed" / "not followed" status, use 5 stars to
allow users to give a note to a flat between 0 (not followed) and 5. Any
note different from zero add a "followed" status.

Closes issue #36.
2017-05-03 22:14:51 +02:00

49 lines
1.5 KiB
JavaScript

import * as api from '../api'
import * as types from './mutations-types'
export default {
getAllFlats ({ commit }) {
commit(types.IS_LOADING)
api.getFlats(flats => {
commit(types.REPLACE_FLATS, { flats })
})
},
getFlat ({ commit }, { flatId }) {
commit(types.IS_LOADING)
api.getFlat(flatId, flat => {
const flats = [flat]
commit(types.MERGE_FLATS, { flats })
})
},
getAllTimeToPlaces ({ commit }) {
commit(types.IS_LOADING)
api.getTimeToPlaces(timeToPlaces => {
commit(types.RECEIVE_TIME_TO_PLACES, { timeToPlaces })
})
},
updateFlatStatus ({ commit }, { flatId, newStatus }) {
commit(types.IS_LOADING)
api.updateFlatStatus(flatId, newStatus, response => {
commit(types.UPDATE_FLAT_STATUS, { flatId, newStatus })
})
},
updateFlatNotation ({ commit }, { flatId, newNotation }) {
commit(types.IS_LOADING)
api.updateFlatNotation(flatId, newNotation, response => {
commit(types.UPDATE_FLAT_NOTATION, { flatId, newNotation })
})
},
updateFlatNotes ({ commit }, { flatId, newNotes }) {
commit(types.IS_LOADING)
api.updateFlatNotes(flatId, newNotes, response => {
commit(types.UPDATE_FLAT_NOTES, { flatId, newNotes })
})
},
doSearch ({ commit }, { query }) {
commit(types.IS_LOADING)
api.doSearch(query, flats => {
commit(types.REPLACE_FLATS, { flats })
})
}
}