Dev #11
@@ -5,6 +5,7 @@ import { useAuthStore } from '@/stores/auth'
|
|||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
import CoinChip from '@/components/ui/CoinChip.vue'
|
import CoinChip from '@/components/ui/CoinChip.vue'
|
||||||
import SearchInput from '@/components/ui/SearchInput.vue'
|
import SearchInput from '@/components/ui/SearchInput.vue'
|
||||||
|
import { formatUserName } from '@/utils/formatUserName'
|
||||||
|
|
||||||
const auth = useAuthStore()
|
const auth = useAuthStore()
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
@@ -65,7 +66,7 @@ function openProfile() {
|
|||||||
@keydown.space.prevent="openProfile"
|
@keydown.space.prevent="openProfile"
|
||||||
>
|
>
|
||||||
<span class="avatar-icon">👤</span>
|
<span class="avatar-icon">👤</span>
|
||||||
<span class="avatar-name" v-if="auth.user">{{ auth.user.name.split(' ')[0] }}</span>
|
<span class="avatar-name" v-if="auth.user">{{ formatUserName(auth.user.name) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
export function formatUserName(name?: string | null) {
|
||||||
|
if (!name) return ''
|
||||||
|
|
||||||
|
const parts = name.trim().split(' ').filter(Boolean)
|
||||||
|
|
||||||
|
// Если имя состоит из одного слова, оставляем его как есть.
|
||||||
|
if (parts.length === 1) return parts[0]
|
||||||
|
|
||||||
|
// Бэкенд хранит displayName одной строкой, а в интерфейсе нам нужен формат
|
||||||
|
// "имя + фамилия" для верхней панели и приветствия.
|
||||||
|
return `${parts[1]} ${parts[0]}`
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ import LectureCard from '@/components/ui/LectureCard.vue'
|
|||||||
import ProgressBar from '@/components/ui/ProgressBar.vue'
|
import ProgressBar from '@/components/ui/ProgressBar.vue'
|
||||||
import AchievementBadge from '@/components/ui/AchievementBadge.vue'
|
import AchievementBadge from '@/components/ui/AchievementBadge.vue'
|
||||||
import EmptyState from '@/components/ui/EmptyState.vue'
|
import EmptyState from '@/components/ui/EmptyState.vue'
|
||||||
|
import { formatUserName } from '@/utils/formatUserName'
|
||||||
|
|
||||||
const auth = useAuthStore()
|
const auth = useAuthStore()
|
||||||
const lectures = useLecturesStore()
|
const lectures = useLecturesStore()
|
||||||
@@ -39,7 +40,7 @@ onMounted(async () => {
|
|||||||
<div class="dashboard page-content">
|
<div class="dashboard page-content">
|
||||||
<div class="dashboard-welcome">
|
<div class="dashboard-welcome">
|
||||||
<div>
|
<div>
|
||||||
<h1 class="page-title">Добрый день, {{ user.name.split(' ')[0] }}! 👋</h1>
|
<h1 class="page-title">Добрый день, {{ formatUserName(user.name) }}! 👋</h1>
|
||||||
<p class="text-secondary">{{ user.institute }} · {{ user.direction }} · {{ user.year }} курс</p>
|
<p class="text-secondary">{{ user.institute }} · {{ user.direction }} · {{ user.year }} курс</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="quick-actions">
|
<div class="quick-actions">
|
||||||
|
|||||||
Reference in New Issue
Block a user