Export data.

This commit is contained in:
HenriT
2021-02-16 17:50:17 +02:00
parent db476ff5b3
commit 0ae8bbce91
3 changed files with 59 additions and 2 deletions

View File

@ -12,6 +12,8 @@ import clients from '@/store/clients';
import invoices from '@/store/invoices';
import teams from '@/store/teams';
import themes from '@/store/themes';
import localForage from 'localforage';
import { download } from '../utils/helpers';
Vue.use(Vuex);
@ -35,5 +37,24 @@ export default new Vuex.Store({
},
state: {},
mutations: {},
actions: {},
actions: {
async exportJson() {
let results = [];
const keys = await localForage.keys();
keys.forEach((key) => {
results.push(localForage.getItem(key));
});
results = await Promise.all(results);
const data = {};
keys.forEach((key, index) => {
data[key] = results[index];
});
download(JSON.stringify(data), 'serverless-invoices.json', 'application/json');
},
importJson() {
},
},
});