mirror of
https://github.com/mokuappio/serverless-invoices.git
synced 2025-10-29 00:41:08 -04:00
Init commit
This commit is contained in:
49
src/store/teams.js
Normal file
49
src/store/teams.js
Normal 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();
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user