Добрый день, {{ user.name.split(' ')[0] }}! 👋
+Добрый день, {{ formatUserName(user.name) }}! 👋
{{ user.institute }} · {{ user.direction }} · {{ user.year }} курс
diff --git a/frontend/src/components/layout/AppTopbar.vue b/frontend/src/components/layout/AppTopbar.vue index 22a4fa2..53af3d5 100644 --- a/frontend/src/components/layout/AppTopbar.vue +++ b/frontend/src/components/layout/AppTopbar.vue @@ -5,6 +5,7 @@ import { useAuthStore } from '@/stores/auth' import { useUserStore } from '@/stores/user' import CoinChip from '@/components/ui/CoinChip.vue' import SearchInput from '@/components/ui/SearchInput.vue' +import { formatUserName } from '@/utils/formatUserName' const auth = useAuthStore() const userStore = useUserStore() @@ -65,7 +66,7 @@ function openProfile() { @keydown.space.prevent="openProfile" > - {{ auth.user.name.split(' ')[0] }} + {{ formatUserName(auth.user.name) }} diff --git a/frontend/src/utils/formatUserName.ts b/frontend/src/utils/formatUserName.ts new file mode 100644 index 0000000..5a23636 --- /dev/null +++ b/frontend/src/utils/formatUserName.ts @@ -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]}` +} diff --git a/frontend/src/views/student/DashboardView.vue b/frontend/src/views/student/DashboardView.vue index d890b4a..09535ec 100644 --- a/frontend/src/views/student/DashboardView.vue +++ b/frontend/src/views/student/DashboardView.vue @@ -10,6 +10,7 @@ import LectureCard from '@/components/ui/LectureCard.vue' import ProgressBar from '@/components/ui/ProgressBar.vue' import AchievementBadge from '@/components/ui/AchievementBadge.vue' import EmptyState from '@/components/ui/EmptyState.vue' +import { formatUserName } from '@/utils/formatUserName' const auth = useAuthStore() const lectures = useLecturesStore() @@ -39,7 +40,7 @@ onMounted(async () => {
{{ user.institute }} · {{ user.direction }} · {{ user.year }} курс