|
| 1 | +<!-- A popover that shows current user information and actions --> |
| 2 | +<template> |
| 3 | + <div class="current-user-popover w-72"> |
| 4 | + <!-- User Info Section --> |
| 5 | + <div class="p-3"> |
| 6 | + <div class="flex flex-col items-center"> |
| 7 | + <Avatar |
| 8 | + class="mb-3" |
| 9 | + :image="user?.photoURL ?? undefined" |
| 10 | + :icon="user?.photoURL ? undefined : 'pi pi-user'" |
| 11 | + shape="circle" |
| 12 | + size="large" |
| 13 | + aria-label="User Avatar" |
| 14 | + /> |
| 15 | + |
| 16 | + <!-- User Details --> |
| 17 | + <h3 class="text-lg font-semibold truncate my-0 mb-1"> |
| 18 | + {{ user?.displayName || $t('g.user') }} |
| 19 | + </h3> |
| 20 | + <p v-if="user?.email" class="text-sm text-muted truncate my-0"> |
| 21 | + {{ user.email }} |
| 22 | + </p> |
| 23 | + </div> |
| 24 | + </div> |
| 25 | + |
| 26 | + <Divider class="my-2" /> |
| 27 | + |
| 28 | + <Button |
| 29 | + class="justify-start" |
| 30 | + :label="$t('userSettings.title')" |
| 31 | + icon="pi pi-cog" |
| 32 | + text |
| 33 | + fluid |
| 34 | + severity="secondary" |
| 35 | + @click="handleOpenUserSettings" |
| 36 | + /> |
| 37 | + |
| 38 | + <Divider class="my-2" /> |
| 39 | + |
| 40 | + <div class="w-full flex flex-col gap-2 p-2"> |
| 41 | + <div class="text-muted text-sm"> |
| 42 | + {{ $t('credits.yourCreditBalance') }} |
| 43 | + </div> |
| 44 | + <div class="flex justify-between items-center"> |
| 45 | + <UserCredit text-class="text-2xl" /> |
| 46 | + <Button :label="$t('credits.topUp.topUp')" @click="handleTopUp" /> |
| 47 | + </div> |
| 48 | + </div> |
| 49 | + </div> |
| 50 | +</template> |
| 51 | + |
| 52 | +<script setup lang="ts"> |
| 53 | +import Avatar from 'primevue/avatar' |
| 54 | +import Button from 'primevue/button' |
| 55 | +import Divider from 'primevue/divider' |
| 56 | +import { computed, onMounted } from 'vue' |
| 57 | +
|
| 58 | +import UserCredit from '@/components/common/UserCredit.vue' |
| 59 | +import { useDialogService } from '@/services/dialogService' |
| 60 | +import { useFirebaseAuthService } from '@/services/firebaseAuthService' |
| 61 | +import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore' |
| 62 | +
|
| 63 | +const authStore = useFirebaseAuthStore() |
| 64 | +const authService = useFirebaseAuthService() |
| 65 | +const dialogService = useDialogService() |
| 66 | +
|
| 67 | +const user = computed(() => authStore.currentUser) |
| 68 | +
|
| 69 | +const handleOpenUserSettings = () => { |
| 70 | + dialogService.showSettingsDialog('user') |
| 71 | +} |
| 72 | +
|
| 73 | +const handleTopUp = () => { |
| 74 | + dialogService.showTopUpCreditsDialog() |
| 75 | +} |
| 76 | +
|
| 77 | +onMounted(() => { |
| 78 | + void authService.fetchBalance() |
| 79 | +}) |
| 80 | +</script> |
0 commit comments