2026-09-03 13:20:24 +03:00
|
|
|
import { groupBy, map } from 'lodash-es'
|
2026-08-10 15:48:27 +03:00
|
|
|
import { mapState } from 'pinia'
|
2026-01-08 17:26:52 +02:00
|
|
|
|
2026-06-04 21:56:25 +03:00
|
|
|
import BasicUserCard from 'src/components/basic_user_card/basic_user_card.vue'
|
2019-11-08 23:21:07 -06:00
|
|
|
|
2026-01-29 20:40:00 +02:00
|
|
|
import { useInstanceStore } from 'src/stores/instance.js'
|
2026-08-10 15:48:27 +03:00
|
|
|
import { useUsersStore } from 'src/stores/users.js'
|
2026-01-29 20:40:00 +02:00
|
|
|
|
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-08-10 16:37:36 +03:00
|
|
|
nicknames.forEach((name) => useUsersStore().fetchUserIfMissing({ name }))
|
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-08-10 15:48:27 +03:00
|
|
|
...mapState(useUsersStore, ['findUserByName']),
|
|
|
|
|
...mapState(useInstanceStore, ['staffAccounts']),
|
2026-01-06 16:22:52 +02:00
|
|
|
},
|
2019-11-08 23:21:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default StaffPanel
|