2020-12-12 15:17:42 +03:00
|
|
|
import groupBy from 'lodash/groupBy'
|
2026-01-06 16:23:17 +02:00
|
|
|
import map from 'lodash/map'
|
2020-12-12 15:17:42 +03:00
|
|
|
import { mapGetters, mapState } from 'vuex'
|
2026-01-08 17:26:52 +02:00
|
|
|
|
2019-11-08 23:21:07 -06:00
|
|
|
import BasicUserCard from '../basic_user_card/basic_user_card.vue'
|
|
|
|
|
|
2026-01-29 20:40:00 +02:00
|
|
|
import { useInstanceStore } from 'src/stores/instance.js'
|
|
|
|
|
|
2019-11-08 23:21:07 -06:00
|
|
|
const StaffPanel = {
|
2026-01-06 16:22:52 +02:00
|
|
|
created() {
|
2026-01-29 00:49:26 +02:00
|
|
|
const nicknames = useInstanceStore().staffAccounts
|
2026-01-06 16:22:52 +02:00
|
|
|
nicknames.forEach((nickname) =>
|
|
|
|
|
this.$store.dispatch('fetchUserIfMissing', nickname),
|
|
|
|
|
)
|
2020-07-07 14:39:43 +02:00
|
|
|
},
|
2019-11-08 23:21:07 -06:00
|
|
|
components: {
|
2026-01-06 16:22:52 +02:00
|
|
|
BasicUserCard,
|
2019-11-08 23:21:07 -06:00
|
|
|
},
|
|
|
|
|
computed: {
|
2026-01-06 16:22:52 +02:00
|
|
|
groupedStaffAccounts() {
|
|
|
|
|
const staffAccounts = map(this.staffAccounts, this.findUserByName).filter(
|
|
|
|
|
(_) => _,
|
|
|
|
|
)
|
2020-12-12 15:17:42 +03:00
|
|
|
const groupedStaffAccounts = groupBy(staffAccounts, 'role')
|
|
|
|
|
|
|
|
|
|
return [
|
2022-07-31 12:35:48 +03:00
|
|
|
{ role: 'admin', users: groupedStaffAccounts.admin },
|
2026-01-06 16:22:52 +02:00
|
|
|
{ role: 'moderator', users: groupedStaffAccounts.moderator },
|
|
|
|
|
].filter((group) => group.users)
|
2020-12-12 15:17:42 +03:00
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
...mapGetters(['findUserByName']),
|
2020-12-12 15:17:42 +03:00
|
|
|
...mapState({
|
2026-01-29 00:49:26 +02:00
|
|
|
staffAccounts: (state) => useInstanceStore().staffAccounts,
|
2026-01-06 16:22:52 +02:00
|
|
|
}),
|
|
|
|
|
},
|
2019-11-08 23:21:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default StaffPanel
|