mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-12-02 21:26:42 +01:00
35 lines
755 B
JavaScript
Vendored
35 lines
755 B
JavaScript
Vendored
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
|
|
})
|
|
},
|
|
|
|
},
|
|
})
|