38 lines
1.2 KiB
Vue
38 lines
1.2 KiB
Vue
<script setup lang="ts">
|
|
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
|
import { useInitials } from '@/composables/useInitials';
|
|
import type { User } from '@/types';
|
|
import { computed } from 'vue';
|
|
import { Kbd, KbdGroup } from '@/components/ui/kbd'
|
|
|
|
interface Props {
|
|
user: User;
|
|
showEmail?: boolean;
|
|
}
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
showEmail: false,
|
|
});
|
|
|
|
const { getInitials } = useInitials();
|
|
|
|
// Compute whether we should show the avatar image
|
|
const showAvatar = computed(() => props.user.avatar && props.user.avatar !== '');
|
|
</script>
|
|
|
|
<template>
|
|
<div class="flex items-center gap-2">
|
|
<Avatar class="size-8">
|
|
<AvatarImage v-if="showAvatar" :src="'storage/uploads/users/' + user.avatar" :alt="user.name" />
|
|
<AvatarFallback class="rounded-full bg-primary text-black dark:text-white">
|
|
{{ getInitials(user.name) }}
|
|
</AvatarFallback>
|
|
</Avatar>
|
|
|
|
<div class="grid flex-1 text-left text-sm leading-tight">
|
|
<span class="truncate font-medium">{{ user.name }}</span>
|
|
<span v-if="showEmail" class="truncate text-xs text-muted-foreground">{{ user.email }}</span>
|
|
</div>
|
|
</div>
|
|
</template>
|