2020-11-10 00:33:55 +00:00
|
|
|
<template>
|
2021-03-18 16:23:57 +00:00
|
|
|
<q-card style="text-align: center">
|
2020-11-10 00:33:55 +00:00
|
|
|
<q-card-section class="row justify-center content-stretch">
|
|
|
|
<div class="col-4">
|
2021-03-18 16:23:57 +00:00
|
|
|
<div style="width: 100%; padding-bottom: 100%; position: relative">
|
|
|
|
<q-avatar style="position: absolute; top: 0; left: 0; width: 100%; height: 100%">
|
2020-11-16 13:17:26 +00:00
|
|
|
<img :src="avatarLink" />
|
|
|
|
</q-avatar>
|
|
|
|
</div>
|
2020-11-10 00:33:55 +00:00
|
|
|
</div>
|
|
|
|
<div class="col-8">
|
2021-01-27 07:16:44 +00:00
|
|
|
<span class="text-h6">Hallo {{ name }}</span
|
|
|
|
><br />
|
2020-11-15 19:08:24 +00:00
|
|
|
<span v-if="hasBirthday">Herzlichen Glückwunsch zum Geburtstag!<br /></span>
|
2021-01-27 07:16:44 +00:00
|
|
|
<span v-if="birthday.length > 0"
|
|
|
|
>Heute <span v-if="birthday.length === 1">hat </span><span v-else>haben </span
|
2021-01-31 16:09:29 +00:00
|
|
|
><span v-for="(user, index) in birthday" :key="index"
|
2021-01-27 07:16:44 +00:00
|
|
|
>{{ user.display_name }}<span v-if="index < birthday.length - 1">, </span></span
|
|
|
|
>
|
|
|
|
Geburtstag.</span
|
|
|
|
>
|
2020-11-15 19:08:24 +00:00
|
|
|
<span v-else>Heute stehen keine Geburtstage an</span>
|
2020-11-10 00:33:55 +00:00
|
|
|
</div>
|
|
|
|
</q-card-section>
|
|
|
|
</q-card>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-01-30 03:16:17 +00:00
|
|
|
import { computed, defineComponent, onMounted, ref } from 'vue';
|
2021-01-30 07:38:44 +00:00
|
|
|
import { useStore } from 'vuex';
|
|
|
|
import { UserSessionState } from '../store';
|
2020-11-10 00:33:55 +00:00
|
|
|
|
|
|
|
export default defineComponent({
|
2020-11-15 19:08:24 +00:00
|
|
|
name: 'Greeting',
|
2021-01-30 07:38:44 +00:00
|
|
|
setup() {
|
|
|
|
const store = useStore<UserSessionState>();
|
|
|
|
onMounted(() => store.dispatch('users/getUsers', false));
|
2020-11-15 19:08:24 +00:00
|
|
|
|
2021-01-30 07:38:44 +00:00
|
|
|
const name = ref(store.state.users.currentUser?.display_name);
|
2020-11-10 00:33:55 +00:00
|
|
|
|
2021-01-30 07:38:44 +00:00
|
|
|
const avatarLink = ref(store.state.users.currentUser?.avatar_url);
|
2020-11-16 01:28:03 +00:00
|
|
|
|
2020-11-15 19:08:24 +00:00
|
|
|
function userHasBirthday(user: FG.User) {
|
|
|
|
const today = new Date();
|
|
|
|
return (
|
|
|
|
user.birthday &&
|
2020-11-17 17:09:05 +00:00
|
|
|
user.birthday.getMonth() === today.getMonth() &&
|
|
|
|
user.birthday.getDate() === today.getDate()
|
2020-11-15 19:08:24 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const hasBirthday = computed(() => {
|
2021-01-30 07:38:44 +00:00
|
|
|
return userHasBirthday(<FG.User>store.state.users.currentUser);
|
2020-11-15 19:08:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const birthday = computed(() =>
|
2021-01-30 07:38:44 +00:00
|
|
|
store.state.users.users
|
2020-11-15 19:08:24 +00:00
|
|
|
.filter(userHasBirthday)
|
2021-01-30 07:38:44 +00:00
|
|
|
.filter((user) => user.userid !== store.state.users.currentUser?.userid)
|
2020-11-15 19:08:24 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
return { avatarLink, name, hasBirthday, birthday };
|
2021-03-18 16:23:57 +00:00
|
|
|
},
|
2020-11-10 00:33:55 +00:00
|
|
|
});
|
|
|
|
</script>
|