[notification] set notification if new user is set

This commit is contained in:
Tim Gröger 2021-11-21 15:44:15 +01:00
parent b84bfb2cc3
commit c9e8e9cddb
1 changed files with 26 additions and 3 deletions

View File

@ -11,6 +11,7 @@
<script lang="ts">
import { defineComponent, ref } from 'vue';
import { Notify } from 'quasar';
import MainUserSettings from './settings/MainUserSettings.vue';
import { useUserStore } from '@flaschengeist/api';
@ -19,17 +20,39 @@ export default defineComponent({
components: { MainUserSettings },
setup() {
const userStore = useUserStore();
const user = ref<FG.User>({
const emptyUser = {
userid: '',
display_name: '',
firstname: '',
lastname: '',
mail: '',
roles: [],
});
}
const user = ref<FG.User>(emptyUser);
async function setUser(value: FG.User) {
await userStore.createUser(value);
try {
await userStore.createUser(value);
Notify.create({
color: "positive",
message: "Neuer User wurde angelegt.",
timeout: 5000,
group: false,
actions: [{ icon: 'mdi-close', color: 'white' }],
textColor: "white"
})
user.value = emptyUser
} catch {
Notify.create({
color: "negative",
message: "Neuer User konnte nicht angelegt werden.",
timeout: 10000,
group: false,
actions: [{ icon: 'mdi-close', color: 'white' }],
textColor: "white"
})
}
}
return { user, setUser };
},