2018-06-26 11:39:43 +02:00
|
|
|
import * as api from '@/api';
|
2018-07-04 18:20:28 +02:00
|
|
|
import { IS_LOADING, IS_DONE_LOADING, PUSH_REPORT, STORE_REPORTS } from './mutations-types';
|
2018-06-26 11:39:43 +02:00
|
|
|
|
|
|
|
export function fetchReports({ commit }) {
|
2018-07-04 18:20:28 +02:00
|
|
|
commit(IS_LOADING);
|
|
|
|
return api.getReports()
|
|
|
|
.then(reports => commit(STORE_REPORTS, { reports }))
|
|
|
|
.finally(() => commit(IS_DONE_LOADING));
|
2018-06-26 11:39:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function saveReport({ commit }, { type, lat, lng }) {
|
2018-07-04 18:20:28 +02:00
|
|
|
commit(IS_LOADING);
|
2018-06-26 11:39:43 +02:00
|
|
|
return api.saveReport(type, lat, lng)
|
2018-07-04 18:20:28 +02:00
|
|
|
.then(report => commit(PUSH_REPORT, { report }))
|
|
|
|
.finally(() => commit(IS_DONE_LOADING));
|
2018-06-26 11:39:43 +02:00
|
|
|
}
|