ff-admin/src/views/admin/management/user/User.vue

51 lines
1.7 KiB
Vue

<template>
<MainTemplate title="Benutzer">
<template #diffMain>
<div class="flex flex-col gap-4 h-full pl-7">
<div class="flex flex-col gap-2 grow overflow-y-scroll pr-7">
<UserListItem v-for="user in users" :key="user.id" :user="user" />
</div>
<div class="flex flex-row gap-4">
<button v-if="can('create', 'management', 'user')" primary class="w-fit!" @click="inviteUser">
Nutzer einladen
</button>
<RouterLink button primary-outline :to="{ name: 'admin-management-user-invites' }" class="w-fit!">
offene Einladungen
</RouterLink>
</div>
</div>
</template>
</MainTemplate>
</template>
<script setup lang="ts">
import { defineComponent, markRaw, defineAsyncComponent } from "vue";
import { RouterLink } from "vue-router";
import { mapState, mapActions } from "pinia";
import MainTemplate from "@/templates/Main.vue";
import { useUserStore } from "@/stores/admin/management/user";
import { useModalStore } from "@/stores/modal";
import UserListItem from "@/components/admin/management/user/UserListItem.vue";
import { useAbilityStore } from "@/stores/ability";
</script>
<script lang="ts">
export default defineComponent({
computed: {
...mapState(useUserStore, ["users"]),
...mapState(useAbilityStore, ["can"]),
},
mounted() {
this.fetchUsers();
},
methods: {
...mapActions(useUserStore, ["fetchUsers"]),
...mapActions(useModalStore, ["openModal"]),
inviteUser() {
this.openModal(
markRaw(defineAsyncComponent(() => import("@/components/admin/management/user/InviteUserModal.vue")))
);
},
},
});
</script>