2019-12-15 19:29:45 +00:00
|
|
|
import map from 'lodash/map'
|
2020-12-12 12:17:42 +00:00
|
|
|
import groupBy from 'lodash/groupBy'
|
|
|
|
import { mapGetters, mapState } from 'vuex'
|
2019-11-09 05:21:07 +00:00
|
|
|
import BasicUserCard from '../basic_user_card/basic_user_card.vue'
|
|
|
|
|
|
|
|
const StaffPanel = {
|
2020-07-07 12:44:29 +00:00
|
|
|
created () {
|
2020-07-07 12:39:43 +00:00
|
|
|
const nicknames = this.$store.state.instance.staffAccounts
|
|
|
|
nicknames.forEach(nickname => this.$store.dispatch('fetchUserIfMissing', nickname))
|
|
|
|
},
|
2019-11-09 05:21:07 +00:00
|
|
|
components: {
|
|
|
|
BasicUserCard
|
|
|
|
},
|
|
|
|
computed: {
|
2020-12-12 12:17:42 +00:00
|
|
|
groupedStaffAccounts () {
|
|
|
|
const staffAccounts = map(this.staffAccounts, this.findUser).filter(_ => _)
|
|
|
|
const groupedStaffAccounts = groupBy(staffAccounts, 'role')
|
|
|
|
|
|
|
|
return [
|
|
|
|
{ role: 'admin', users: groupedStaffAccounts['admin'] },
|
|
|
|
{ role: 'moderator', users: groupedStaffAccounts['moderator'] }
|
|
|
|
].filter(group => group.users)
|
|
|
|
},
|
|
|
|
...mapGetters([
|
|
|
|
'findUser'
|
|
|
|
]),
|
|
|
|
...mapState({
|
|
|
|
staffAccounts: state => state.instance.staffAccounts
|
|
|
|
})
|
2019-11-09 05:21:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default StaffPanel
|