Init commit

This commit is contained in:
Marek Fraczyk
2021-02-16 16:24:22 +02:00
parent 056a817632
commit 79e9705b01
106 changed files with 18400 additions and 0 deletions

49
src/store/teams.js Normal file
View File

@ -0,0 +1,49 @@
import TeamService from '@/services/team.service';
import Team from '@/store/models/team';
export default {
namespaced: true,
state: {},
mutations: {},
actions: {
async init({ dispatch }) {
dispatch('clients/terminate', null, { root: true });
dispatch('bankAccounts/terminate', null, { root: true });
dispatch('invoices/terminate', null, { root: true });
await dispatch('getTeam');
dispatch('clients/init', null, { root: true });
dispatch('bankAccounts/init', null, { root: true });
dispatch('invoices/init', null, { root: true });
},
async getTeam() {
const team = await TeamService.getTeam();
await Team.create({ data: team });
return team;
},
async teamProps({ state }, props) {
return Team.update({
where: state.teamId,
data: props,
});
},
async updateTeam({ getters, dispatch }, props) {
if (props) {
await dispatch('teamProps', props);
}
return TeamService.updateTeam(getters.team);
},
},
getters: {
team() {
return Team.query().first();
},
all() {
return Team.query()
.with(['logos'])
.where('$isNew', false)
.get();
},
},
};