mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-13 23:38:32 +02:00
Implement twofaccounts & groups stores & Add ActionButtons component
This commit is contained in:
34
resources/js_vue3/stores/groups.js
vendored
Normal file
34
resources/js_vue3/stores/groups.js
vendored
Normal 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
|
||||
})
|
||||
},
|
||||
|
||||
},
|
||||
})
|
Reference in New Issue
Block a user