Implement twofaccounts & groups stores & Add ActionButtons component

This commit is contained in:
Bubka
2023-10-20 17:24:45 +02:00
parent a46084720e
commit 5d568a606e
4 changed files with 318 additions and 280 deletions

34
resources/js_vue3/stores/groups.js vendored Normal file
View File

@ -0,0 +1,34 @@
import { defineStore } from 'pinia'
import { useUserStore } from '@/stores/user'
import groupService from '@/services/groupService'
export const useGroups = defineStore({
id: 'groups',
state: () => {
return {
items: [],
}
},
getters: {
current(state) {
const group = state.items.find(item => item.id === parseInt(useUserStore().preferences.activeGroup))
return group ? group.name : trans('commons.all')
}
},
actions: {
/**
* Refreshes the groups collection using the backend
*/
refresh() {
groupService.getAll().then(response => {
this.items = response.data
})
},
},
})