up frontend

This commit is contained in:
2026-04-21 03:57:59 +03:00
parent b9d1afad42
commit 82a932dd2b
14 changed files with 492 additions and 172 deletions

View File

@@ -102,7 +102,7 @@
</div> </div>
<div class="flex-1 min-w-0"> <div class="flex-1 min-w-0">
<p class="text-sm font-medium text-gray-900 truncate">{{ userName }}</p> <p class="text-sm font-medium text-gray-900 truncate">{{ userName }}</p>
<p class="text-xs text-gray-500 truncate">{{ userStore.role === 'admin' ? 'Administrator' : 'User' }}</p> <p class="text-xs text-gray-500 truncate">{{ userStore.role === 'admin' ? t('app.administrator') : t('app.user') }}</p>
</div> </div>
</div> </div>
</div> </div>
@@ -124,7 +124,7 @@
<div class="relative"> <div class="relative">
<input <input
type="text" type="text"
placeholder="Search..." :placeholder="t('app.search')"
class="w-64 px-4 py-2 pl-10 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500" class="w-64 px-4 py-2 pl-10 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500"
/> />
<svg class="absolute left-3 top-2.5 w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <svg class="absolute left-3 top-2.5 w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -133,7 +133,7 @@
</div> </div>
<!-- Notifications --> <!-- Notifications -->
<button class="relative p-2 text-gray-400 hover:text-gray-600 rounded-lg hover:bg-gray-100 transition-colors"> <button class="relative p-2 text-gray-400 hover:text-gray-600 rounded-lg hover:bg-gray-100 transition-colors" :title="t('app.notifications')">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9" />
</svg> </svg>
@@ -186,15 +186,12 @@ const { t, locale } = useI18n()
const userName = computed(() => userStore.login || 'User') const userName = computed(() => userStore.login || 'User')
const userInitials = computed(() => (userName.value[0] || 'U').toUpperCase()) const userInitials = computed(() => (userName.value[0] || 'U').toUpperCase())
// Sidebar collapsed state with localStorage
const SIDEBAR_STORAGE_KEY = 'admin_sidebar_collapsed' const SIDEBAR_STORAGE_KEY = 'admin_sidebar_collapsed'
const sidebarCollapsed = ref(false) const sidebarCollapsed = ref(false)
onMounted(() => { onMounted(() => {
const saved = localStorage.getItem(SIDEBAR_STORAGE_KEY) const saved = localStorage.getItem(SIDEBAR_STORAGE_KEY)
if (saved !== null) { if (saved !== null) sidebarCollapsed.value = saved === 'true'
sidebarCollapsed.value = saved === 'true'
}
}) })
function toggleSidebar() { function toggleSidebar() {
@@ -210,11 +207,20 @@ async function logout() {
async function toggleLanguage() { async function toggleLanguage() {
const newLang = locale.value === 'en' ? 'ru' : 'en' const newLang = locale.value === 'en' ? 'ru' : 'en'
if (userStore.id) {
const ok = await userStore.updateProfile({ language: newLang }) const ok = await userStore.updateProfile({ language: newLang })
if (ok) { if (ok) {
locale.value = newLang locale.value = newLang
localStorage.setItem('locale', newLang)
} else { } else {
// В случае ошибки всё равно меняем локаль, но не сохраняем в БД
locale.value = newLang locale.value = newLang
localStorage.setItem('locale', newLang)
}
} else {
// Для неавторизованных просто сохраняем в localStorage
locale.value = newLang
localStorage.setItem('locale', newLang)
} }
} }
</script> </script>

View File

@@ -7,29 +7,163 @@
"settings": "Settings", "settings": "Settings",
"profile": "Profile", "profile": "Profile",
"logout": "Logout", "logout": "Logout",
"language": "Language" "language": "Language",
"search": "Search...",
"notifications": "Notifications",
"administrator": "Administrator",
"user": "User",
"yes": "Yes",
"no": "No",
"cancel": "Cancel",
"save": "Save",
"delete": "Delete",
"edit": "Edit",
"add": "Add",
"reset": "Reset",
"loading": "Loading..."
}, },
"user": { "common": {
"id": "ID",
"name": "Name",
"email": "Email",
"password": "Password",
"login": "Login",
"username": "Username",
"role": "Role",
"status": "Status",
"ip": "IP",
"created": "Created",
"actions": "Actions",
"active": "Active",
"inactive": "Inactive",
"yes": "Yes",
"no": "No",
"passwordRequired": "Password is required",
"saveChanges": "Save Changes",
"confirmDelete": "Confirm Delete",
"leavePasswordBlank": "Leave blank to keep current password",
"deleteConfirmation": "Are you sure you want to delete this item? This action cannot be undone.",
"operationSuccess": "Operation completed successfully",
"operationFailed": "Operation failed"
},
"dashboard": {
"totalUsers": "Total Users",
"activeSessions": "Active Sessions",
"systemHealth": "System Health",
"uptime": "Uptime",
"vsLastMonth": "vs last month",
"fromLastHour": "from last hour",
"operational": "Operational",
"down": "Down",
"userActivity": "User Activity (Last 7 days)",
"week": "Week",
"month": "Month",
"systemServices": "System Services",
"recentUsers": "Recent Users",
"recentRestaurants": "Recent Restaurants",
"viewAll": "View all",
"noUsers": "No users yet",
"noRestaurants": "No restaurants yet",
"new": "New",
"today": "Today",
"yesterday": "Yesterday",
"daysAgo": "{count} days ago"
},
"users": {
"pageName": "Users Management", "pageName": "Users Management",
"add": "Add User", "add": "Add User",
"edit": "Edit User" "edit": "Edit User",
"delete": "Delete User",
"you": "(You)",
"cannotChangeOwnRole": "You cannot change your own role",
"confirmDelete": "Delete User",
"deleteConfirmation": "Are you sure you want to delete this user? This action cannot be undone."
},
"restaurants": {
"pageName": "Restaurants",
"add": "Add Restaurant",
"edit": "Edit Restaurant",
"delete": "Delete Restaurant",
"host": "Host",
"https": "HTTPS",
"useHttps": "Use HTTPS",
"confirmDelete": "Delete Restaurant",
"noRestaurants": "No restaurants found. Click \"Add Restaurant\" to create one.",
"deleteConfirmation": "Are you sure you want to delete this restaurant? This action cannot be undone."
},
"settings": {
"title": "Application Settings",
"save": "Save Changes",
"reset": "Reset",
"saved": "Settings saved successfully",
"saveFailed": "Failed to save settings",
"loadFailed": "Failed to load settings metadata",
"enabled": "Enabled"
},
"profile": {
"title": "My Profile",
"subtitle": "Manage your account settings",
"username": "Username",
"email": "Email Address",
"newPassword": "New Password",
"confirmPassword": "Confirm New Password",
"language": "Language",
"save": "Save Changes",
"reset": "Reset",
"role": "Role",
"passwordMismatch": "Passwords do not match",
"updateSuccess": "Profile updated successfully",
"updateFailed": "Failed to update profile"
}, },
"login": { "login": {
"title": "Welcome Back", "title": "Welcome Back",
"subtitle": "Sign in to your account", "subtitle": "Sign in to your account",
"username": "Username or Email", "username": "Username or Email",
"password": "Password",
"remember": "Remember me", "remember": "Remember me",
"signin": "Sign In", "signin": "Sign In",
"createAccount": "Create account" "createAccount": "Create account",
"invalidCredentials": "Invalid username or password",
"networkError": "Network error. Please try again."
}, },
"profile": { "register": {
"title": "My Profile", "title": "Create Account",
"subtitle": "Register and wait for admin approval",
"username": "Username",
"email": "Email", "email": "Email",
"password": "Password", "password": "Password",
"newPassword": "New Password", "register": "Register",
"language": "Language", "success": "Account created! Wait for admin activation.",
"save": "Save Changes", "failed": "Registration failed",
"role": "Role" "alreadyHaveAccount": "Already have an account?",
"networkError": "Network error"
},
"setup": {
"title": "Setup Admin Account",
"subtitle": "Create your administrator account",
"step1": "Account Details",
"step2": "Complete",
"createAccount": "Create Account",
"passwordStrength": "Password strength",
"veryWeak": "Very Weak",
"weak": "Weak",
"fair": "Fair",
"good": "Good",
"strong": "Strong",
"validationUsernameMin": "Username must be at least 3 characters",
"validationEmailInvalid": "Please enter a valid email address",
"validationPasswordMin": "Password must be at least 6 characters",
"createFailed": "Failed to create account"
},
"notFound": {
"title": "Oops! Page not found",
"message": "The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.",
"goToDashboard": "Go to Dashboard",
"signIn": "Sign In"
},
"validation": {
"required": "This field is required",
"minLength": "Must be at least {min} characters",
"email": "Please enter a valid email address",
"passwordMismatch": "Passwords do not match"
} }
} }

View File

@@ -7,29 +7,163 @@
"settings": "Настройки", "settings": "Настройки",
"profile": "Профиль", "profile": "Профиль",
"logout": "Выйти", "logout": "Выйти",
"language": "Язык" "language": "Язык",
"search": "Поиск...",
"notifications": "Уведомления",
"administrator": "Администратор",
"user": "Пользователь",
"yes": "Да",
"no": "Нет",
"cancel": "Отмена",
"save": "Сохранить",
"delete": "Удалить",
"edit": "Редактировать",
"add": "Добавить",
"reset": "Сбросить",
"loading": "Загрузка..."
}, },
"user": { "common": {
"id": "ID",
"name": "Название",
"email": "Email",
"password": "Пароль",
"login": "Логин",
"username": "Имя пользователя",
"role": "Роль",
"status": "Статус",
"ip": "IP",
"created": "Создан",
"actions": "Действия",
"active": "Активен",
"inactive": "Неактивен",
"yes": "Да",
"no": "Нет",
"passwordRequired": "Пароль обязателен",
"saveChanges": "Сохранить изменения",
"confirmDelete": "Подтверждение удаления",
"leavePasswordBlank": "Оставьте пустым, чтобы оставить текущий пароль",
"deleteConfirmation": "Вы уверены, что хотите удалить этот элемент? Это действие необратимо.",
"operationSuccess": "Операция выполнена успешно",
"operationFailed": "Операция не удалась"
},
"dashboard": {
"totalUsers": "Всего пользователей",
"activeSessions": "Активных сессий",
"systemHealth": "Здоровье системы",
"uptime": "Время работы",
"vsLastMonth": "по сравнению с прошлым месяцем",
"fromLastHour": "за последний час",
"operational": "Работает",
"down": "Недоступен",
"userActivity": "Активность пользователей (последние 7 дней)",
"week": "Неделя",
"month": "Месяц",
"systemServices": "Системные сервисы",
"recentUsers": "Недавние пользователи",
"recentRestaurants": "Недавние рестораны",
"viewAll": "Все",
"noUsers": "Пока нет пользователей",
"noRestaurants": "Пока нет ресторанов",
"new": "Новый",
"today": "Сегодня",
"yesterday": "Вчера",
"daysAgo": "дн. назад"
},
"users": {
"pageName": "Управление пользователями", "pageName": "Управление пользователями",
"add": "Добавить пользователя", "add": "Добавить пользователя",
"edit": "Редактировать пользователя" "edit": "Редактировать пользователя",
"delete": "Удалить пользователя",
"you": "(Вы)",
"cannotChangeOwnRole": "Вы не можете изменить свою собственную роль",
"confirmDelete": "Удалить пользователя",
"deleteConfirmation": "Вы уверены, что хотите удалить этого пользователя? Это действие необратимо."
},
"restaurants": {
"pageName": "Рестораны",
"add": "Добавить ресторан",
"edit": "Редактировать ресторан",
"delete": "Удалить ресторан",
"host": "Хост",
"https": "HTTPS",
"useHttps": "Использовать HTTPS",
"confirmDelete": "Удалить ресторан",
"noRestaurants": "Ресторанов не найдено. Нажмите \"Добавить ресторан\", чтобы создать его.",
"deleteConfirmation": "Вы уверены, что хотите удалить этот ресторан? Это действие необратимо."
},
"settings": {
"title": "Настройки приложения",
"save": "Сохранить изменения",
"reset": "Сбросить",
"saved": "Настройки успешно сохранены",
"saveFailed": "Не удалось сохранить настройки",
"loadFailed": "Не удалось загрузить метаданные настроек",
"enabled": "Включено"
},
"profile": {
"title": "Мой профиль",
"subtitle": "Управление настройками аккаунта",
"username": "Имя пользователя",
"email": "Email",
"newPassword": "Новый пароль",
"confirmPassword": "Подтверждение нового пароля",
"language": "Язык",
"save": "Сохранить изменения",
"reset": "Сбросить",
"role": "Роль",
"passwordMismatch": "Пароли не совпадают",
"updateSuccess": "Профиль успешно обновлен",
"updateFailed": "Не удалось обновить профиль"
}, },
"login": { "login": {
"title": "С возвращением", "title": "С возвращением",
"subtitle": "Войдите в свой аккаунт", "subtitle": "Войдите в свой аккаунт",
"username": "Имя пользователя или Email", "username": "Имя пользователя или Email",
"password": "Пароль",
"remember": "Запомнить меня", "remember": "Запомнить меня",
"signin": "Войти", "signin": "Войти",
"createAccount": "Создать аккаунт" "createAccount": "Создать аккаунт",
"invalidCredentials": "Неверное имя пользователя или пароль",
"networkError": "Ошибка сети. Попробуйте еще раз."
}, },
"profile": { "register": {
"title": "Мой профиль", "title": "Создать аккаунт",
"subtitle": "Зарегистрируйтесь и ожидайте одобрения администратора",
"username": "Имя пользователя",
"email": "Email", "email": "Email",
"password": "Пароль", "password": "Пароль",
"newPassword": "Новый пароль", "register": "Зарегистрироваться",
"language": "Язык", "success": "Аккаунт создан! Ожидайте активации администратором.",
"save": "Сохранить", "failed": "Ошибка регистрации",
"role": "Роль" "alreadyHaveAccount": "Уже есть аккаунт?",
"networkError": "Ошибка сети"
},
"setup": {
"title": "Настройка учетной записи администратора",
"subtitle": "Создайте учетную запись администратора",
"step1": "Данные аккаунта",
"step2": "Завершение",
"createAccount": "Создать аккаунт",
"passwordStrength": "Сложность пароля",
"veryWeak": "Очень слабый",
"weak": "Слабый",
"fair": "Средний",
"good": "Хороший",
"strong": "Сильный",
"validationUsernameMin": "Имя пользователя должно содержать не менее 3 символов",
"validationEmailInvalid": "Введите корректный email адрес",
"validationPasswordMin": "Пароль должен содержать не менее 6 символов",
"createFailed": "Не удалось создать аккаунт"
},
"notFound": {
"title": "Упс! Страница не найдена",
"message": "Возможно, страница была удалена, переименована или временно недоступна.",
"goToDashboard": "На главную",
"signIn": "Войти"
},
"validation": {
"required": "Это поле обязательно",
"minLength": "Должно быть не менее {min} символов",
"email": "Введите корректный email адрес",
"passwordMismatch": "Пароли не совпадают"
} }
} }

View File

@@ -1,3 +1,4 @@
// src/main.ts
import { createApp } from 'vue' import { createApp } from 'vue'
import { createPinia } from 'pinia' import { createPinia } from 'pinia'
import App from './App.vue' import App from './App.vue'
@@ -9,9 +10,19 @@ import { createI18n } from 'vue-i18n'
import en from './locales/en.json' import en from './locales/en.json'
import ru from './locales/ru.json' import ru from './locales/ru.json'
// Функция определения языка браузера
function getBrowserLocale(): string {
const browserLang = navigator.language.split('-')[0]
return browserLang === 'ru' ? 'ru' : 'en'
}
// Получаем сохраненный язык из localStorage (для неавторизованных)
const storedLocale = localStorage.getItem('locale')
const initialLocale = storedLocale || getBrowserLocale()
const i18n = createI18n({ const i18n = createI18n({
legacy: false, legacy: false,
locale: 'en', locale: initialLocale,
fallbackLocale: 'en', fallbackLocale: 'en',
messages: { en, ru } messages: { en, ru }
}) })
@@ -30,9 +41,14 @@ Promise.all([
settingsStore.loadSettings(), settingsStore.loadSettings(),
userStore.fetchProfile().catch(() => {}) userStore.fetchProfile().catch(() => {})
]).then(() => { ]).then(() => {
// Устанавливаем язык из профиля, если есть // Если пользователь авторизован используем язык из профиля
if (userStore.language) { if (userStore.id && userStore.language) {
i18n.global.locale.value = userStore.language i18n.global.locale.value = userStore.language
// Сохраняем в localStorage для синхронизации (опционально)
localStorage.setItem('locale', userStore.language)
} else {
// Для неавторизованных сохраняем текущий язык в localStorage
localStorage.setItem('locale', i18n.global.locale.value)
} }
app.mount('#app') app.mount('#app')
}) })

View File

@@ -1,7 +1,7 @@
<template> <template>
<AppLayout> <AppLayout>
<div class="card"> <div class="card">
<h1 class="text-2xl font-bold mb-6">Application Settings</h1> <h1 class="text-2xl font-bold mb-6">{{ t('settings.title') }}</h1>
<form @submit.prevent="saveSettings" class="space-y-6 max-w-2xl"> <form @submit.prevent="saveSettings" class="space-y-6 max-w-2xl">
<div v-for="field in meta" :key="field.key" class="border-b border-gray-200 pb-4"> <div v-for="field in meta" :key="field.key" class="border-b border-gray-200 pb-4">
<label class="block text-sm font-medium text-gray-700 mb-1"> <label class="block text-sm font-medium text-gray-700 mb-1">
@@ -54,8 +54,8 @@
</div> </div>
<div class="flex justify-end space-x-3 pt-4"> <div class="flex justify-end space-x-3 pt-4">
<button type="button" @click="loadData" class="btn-secondary">Reset</button> <button type="button" @click="loadData" class="btn-secondary">{{ t('settings.reset') }}</button>
<button type="submit" class="btn-primary">Save Changes</button> <button type="submit" class="btn-primary">{{ t('settings.save') }}</button>
</div> </div>
</form> </form>
@@ -69,7 +69,9 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted } from 'vue'; import { ref, onMounted } from 'vue';
import AppLayout from '../components/Layout/AppLayout.vue'; import AppLayout from '../components/Layout/AppLayout.vue';
import { useI18n } from 'vue-i18n'
const { t, locale } = useI18n()
interface FieldMeta { interface FieldMeta {
key: string; key: string;
label: string; label: string;

View File

@@ -5,7 +5,7 @@
<div class="card hover:shadow-md transition-shadow"> <div class="card hover:shadow-md transition-shadow">
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-sm font-medium text-gray-600">Total Users</p> <p class="text-sm font-medium text-gray-600">{{ t('dashboard.totalUsers') }}</p>
<p class="text-3xl font-bold text-gray-900 mt-2">{{ stats.totalUsers }}</p> <p class="text-3xl font-bold text-gray-900 mt-2">{{ stats.totalUsers }}</p>
</div> </div>
<div class="w-12 h-12 bg-primary-100 rounded-xl flex items-center justify-center"> <div class="w-12 h-12 bg-primary-100 rounded-xl flex items-center justify-center">
@@ -16,14 +16,14 @@
</div> </div>
<div class="mt-4 flex items-center text-sm"> <div class="mt-4 flex items-center text-sm">
<span class="text-green-600 font-medium"> {{ userGrowth }}%</span> <span class="text-green-600 font-medium"> {{ userGrowth }}%</span>
<span class="text-gray-500 ml-2">vs last month</span> <span class="text-gray-500 ml-2">{{ t('dashboard.vsLastMonth') }}</span>
</div> </div>
</div> </div>
<div class="card hover:shadow-md transition-shadow"> <div class="card hover:shadow-md transition-shadow">
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-sm font-medium text-gray-600">Active Sessions</p> <p class="text-sm font-medium text-gray-600">{{ t('dashboard.activeSessions') }}</p>
<p class="text-3xl font-bold text-gray-900 mt-2">{{ stats.activeSessions }}</p> <p class="text-3xl font-bold text-gray-900 mt-2">{{ stats.activeSessions }}</p>
</div> </div>
<div class="w-12 h-12 bg-green-100 rounded-xl flex items-center justify-center"> <div class="w-12 h-12 bg-green-100 rounded-xl flex items-center justify-center">
@@ -34,14 +34,14 @@
</div> </div>
<div class="mt-4 flex items-center text-sm"> <div class="mt-4 flex items-center text-sm">
<span class="text-green-600 font-medium"> {{ sessionGrowth }}%</span> <span class="text-green-600 font-medium"> {{ sessionGrowth }}%</span>
<span class="text-gray-500 ml-2">from last hour</span> <span class="text-gray-500 ml-2">{{ t('dashboard.fromLastHour') }}</span>
</div> </div>
</div> </div>
<div class="card hover:shadow-md transition-shadow"> <div class="card hover:shadow-md transition-shadow">
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-sm font-medium text-gray-600">System Health</p> <p class="text-sm font-medium text-gray-600">{{ t('dashboard.systemHealth') }}</p>
<p class="text-3xl font-bold text-gray-900 mt-2">{{ stats.systemHealth }}%</p> <p class="text-3xl font-bold text-gray-900 mt-2">{{ stats.systemHealth }}%</p>
</div> </div>
<div class="w-12 h-12 bg-blue-100 rounded-xl flex items-center justify-center"> <div class="w-12 h-12 bg-blue-100 rounded-xl flex items-center justify-center">
@@ -63,7 +63,7 @@
<div class="card hover:shadow-md transition-shadow"> <div class="card hover:shadow-md transition-shadow">
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-sm font-medium text-gray-600">Uptime</p> <p class="text-sm font-medium text-gray-600">{{ t('dashboard.uptime') }}</p>
<p class="text-3xl font-bold text-gray-900 mt-2">{{ stats.uptime }}</p> <p class="text-3xl font-bold text-gray-900 mt-2">{{ stats.uptime }}</p>
</div> </div>
<div class="w-12 h-12 bg-purple-100 rounded-xl flex items-center justify-center"> <div class="w-12 h-12 bg-purple-100 rounded-xl flex items-center justify-center">
@@ -75,7 +75,7 @@
<div class="mt-4 flex items-center text-sm"> <div class="mt-4 flex items-center text-sm">
<div class="flex items-center text-green-600"> <div class="flex items-center text-green-600">
<div class="w-2 h-2 bg-green-600 rounded-full mr-2"></div> <div class="w-2 h-2 bg-green-600 rounded-full mr-2"></div>
Operational {{ t('dashboard.operational') }}
</div> </div>
</div> </div>
</div> </div>
@@ -86,10 +86,10 @@
<!-- User Activity Chart --> <!-- User Activity Chart -->
<div class="card"> <div class="card">
<div class="flex justify-between items-center mb-4"> <div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-semibold text-gray-900">User Activity (Last 7 days)</h3> <h3 class="text-lg font-semibold text-gray-900">{{ t('dashboard.userActivity') }}</h3>
<div class="flex items-center space-x-2"> <div class="flex items-center space-x-2">
<button @click="activityPeriod = 'week'" class="text-xs px-2 py-1 rounded" :class="activityPeriod === 'week' ? 'bg-primary-100 text-primary-700' : 'text-gray-500'">Week</button> <button @click="activityPeriod = 'week'" class="text-xs px-2 py-1 rounded" :class="activityPeriod === 'week' ? 'bg-primary-100 text-primary-700' : 'text-gray-500'">{{ t('dashboard.week') }}</button>
<button @click="activityPeriod = 'month'" class="text-xs px-2 py-1 rounded" :class="activityPeriod === 'month' ? 'bg-primary-100 text-primary-700' : 'text-gray-500'">Month</button> <button @click="activityPeriod = 'month'" class="text-xs px-2 py-1 rounded" :class="activityPeriod === 'month' ? 'bg-primary-100 text-primary-700' : 'text-gray-500'">{{ t('dashboard.month') }}</button>
</div> </div>
</div> </div>
<div class="flex items-end space-x-2 h-48"> <div class="flex items-end space-x-2 h-48">
@@ -102,7 +102,7 @@
<!-- System Services Status --> <!-- System Services Status -->
<div class="card"> <div class="card">
<h3 class="text-lg font-semibold text-gray-900 mb-4">System Services</h3> <h3 class="text-lg font-semibold text-gray-900 mb-4">{{ t('dashboard.systemServices') }}</h3>
<div class="space-y-4"> <div class="space-y-4">
<div v-for="service in systemServices" :key="service.name" class="flex items-center justify-between p-3 bg-gray-50 rounded-lg"> <div v-for="service in systemServices" :key="service.name" class="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
<div class="flex items-center space-x-3"> <div class="flex items-center space-x-3">
@@ -112,7 +112,7 @@
<div class="flex items-center space-x-4"> <div class="flex items-center space-x-4">
<span class="text-sm text-gray-500">{{ service.latency }}ms</span> <span class="text-sm text-gray-500">{{ service.latency }}ms</span>
<span class="text-xs px-2 py-1 rounded-full" :class="service.status === 'up' ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-700'"> <span class="text-xs px-2 py-1 rounded-full" :class="service.status === 'up' ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-700'">
{{ service.status === 'up' ? 'Operational' : 'Down' }} {{ service.status === 'up' ? t('dashboard.operational') : t('dashboard.down') }}
</span> </span>
</div> </div>
</div> </div>
@@ -124,8 +124,8 @@
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6"> <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<div class="card"> <div class="card">
<div class="flex justify-between items-center mb-4"> <div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-semibold text-gray-900">Recent Users</h3> <h3 class="text-lg font-semibold text-gray-900">{{ t('dashboard.recentUsers') }}</h3>
<router-link to="/users" class="text-sm text-primary-600 hover:text-primary-700">View all </router-link> <router-link to="/users" class="text-sm text-primary-600 hover:text-primary-700">{{ t('dashboard.viewAll') }} </router-link>
</div> </div>
<div class="space-y-3"> <div class="space-y-3">
<div v-for="user in recentUsers" :key="user.id" class="flex items-center justify-between p-3 hover:bg-gray-50 rounded-lg transition-colors"> <div v-for="user in recentUsers" :key="user.id" class="flex items-center justify-between p-3 hover:bg-gray-50 rounded-lg transition-colors">
@@ -138,16 +138,16 @@
<p class="text-sm text-gray-500">{{ formatDate(user.created) }}</p> <p class="text-sm text-gray-500">{{ formatDate(user.created) }}</p>
</div> </div>
</div> </div>
<span class="px-2 py-1 text-xs font-medium bg-green-100 text-green-700 rounded-full">New</span> <span class="px-2 py-1 text-xs font-medium bg-green-100 text-green-700 rounded-full">{{ t('dashboard.new') }}</span>
</div> </div>
<div v-if="recentUsers.length === 0" class="text-center text-gray-500 py-8">No users yet</div> <div v-if="recentUsers.length === 0" class="text-center text-gray-500 py-8">{{ t('dashboard.noUsers') }}</div>
</div> </div>
</div> </div>
<div class="card"> <div class="card">
<div class="flex justify-between items-center mb-4"> <div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-semibold text-gray-900">Recent Restaurants</h3> <h3 class="text-lg font-semibold text-gray-900">{{ t('dashboard.recentRestaurants') }}</h3>
<router-link to="/restaurants" class="text-sm text-primary-600 hover:text-primary-700">View all </router-link> <router-link to="/restaurants" class="text-sm text-primary-600 hover:text-primary-700">{{ t('dashboard.viewAll') }} </router-link>
</div> </div>
<div class="space-y-3"> <div class="space-y-3">
<div v-for="rest in recentRestaurants" :key="rest.id" class="flex items-center justify-between p-3 hover:bg-gray-50 rounded-lg transition-colors"> <div v-for="rest in recentRestaurants" :key="rest.id" class="flex items-center justify-between p-3 hover:bg-gray-50 rounded-lg transition-colors">
@@ -166,7 +166,7 @@
<span class="text-xs text-gray-500">{{ formatDate(rest.created) }}</span> <span class="text-xs text-gray-500">{{ formatDate(rest.created) }}</span>
</div> </div>
</div> </div>
<div v-if="recentRestaurants.length === 0" class="text-center text-gray-500 py-8">No restaurants yet</div> <div v-if="recentRestaurants.length === 0" class="text-center text-gray-500 py-8">{{ t('dashboard.noRestaurants') }}</div>
</div> </div>
</div> </div>
</div> </div>
@@ -176,6 +176,8 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, onUnmounted } from 'vue'; import { ref, onMounted, onUnmounted } from 'vue';
import AppLayout from '../components/Layout/AppLayout.vue'; import AppLayout from '../components/Layout/AppLayout.vue';
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const stats = ref({ totalUsers: 0, activeSessions: 0, systemHealth: 100, uptime: '99.9%' }); const stats = ref({ totalUsers: 0, activeSessions: 0, systemHealth: 100, uptime: '99.9%' });
const userGrowth = ref(12); const userGrowth = ref(12);
@@ -229,9 +231,9 @@ function formatDate(dateStr: string) {
const date = new Date(dateStr); const date = new Date(dateStr);
const now = new Date(); const now = new Date();
const diffDays = Math.floor((now.getTime() - date.getTime()) / (1000 * 60 * 60 * 24)); const diffDays = Math.floor((now.getTime() - date.getTime()) / (1000 * 60 * 60 * 24));
if (diffDays === 0) return 'Today'; if (diffDays === 0) return t('dashboard.today');
if (diffDays === 1) return 'Yesterday'; if (diffDays === 1) return t('dashboard.yesterday');
if (diffDays < 7) return `${diffDays} days ago`; if (diffDays < 7) return `${diffDays} ${t('dashboard.daysAgo')}`;
return date.toLocaleDateString(); return date.toLocaleDateString();
} }

View File

@@ -9,20 +9,20 @@
</div> </div>
</div> </div>
<h1 class="text-6xl font-bold text-gray-900 mb-4">404</h1> <h1 class="text-6xl font-bold text-gray-900 mb-4">404</h1>
<p class="text-xl text-gray-600 mb-8">Oops! Page not found</p> <p class="text-xl text-gray-600 mb-8">{{ t('notFound.title') }}</p>
<p class="text-gray-500 mb-8">The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.</p> <p class="text-gray-500 mb-8">{{ t('notFound.message') }}</p>
<div class="flex flex-col sm:flex-row gap-4 justify-center"> <div class="flex flex-col sm:flex-row gap-4 justify-center">
<router-link <router-link
to="/dashboard" to="/dashboard"
class="px-6 py-3 bg-primary-600 text-white rounded-lg hover:bg-primary-700 transition-colors" class="px-6 py-3 bg-primary-600 text-white rounded-lg hover:bg-primary-700 transition-colors"
> >
Go to Dashboard {{ t('notFound.goToDashboard') }}
</router-link> </router-link>
<router-link <router-link
to="/login" to="/login"
class="px-6 py-3 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 transition-colors" class="px-6 py-3 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 transition-colors"
> >
Sign In {{ t('notFound.signIn') }}
</router-link> </router-link>
</div> </div>
</div> </div>
@@ -30,5 +30,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
// No additional logic needed import { useI18n } from 'vue-i18n'
const { t } = useI18n()
</script> </script>

View File

@@ -7,29 +7,29 @@
<div class="w-20 h-20 bg-gradient-to-br from-primary-500 to-primary-700 rounded-full flex items-center justify-center text-white text-2xl font-bold"> <div class="w-20 h-20 bg-gradient-to-br from-primary-500 to-primary-700 rounded-full flex items-center justify-center text-white text-2xl font-bold">
{{ userInitials }} {{ userInitials }}
</div> </div>
<button class="absolute bottom-0 right-0 p-1 bg-white rounded-full shadow-md hover:shadow-lg transition-shadow"> <!-- <button class="absolute bottom-0 right-0 p-1 bg-white rounded-full shadow-md hover:shadow-lg transition-shadow">
<svg class="w-4 h-4 text-gray-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <svg class="w-4 h-4 text-gray-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 13a3 3 0 11-6 0 3 3 0 016 0z" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 13a3 3 0 11-6 0 3 3 0 016 0z" />
</svg> </svg>
</button> </button> -->
</div> </div>
<div> <div>
<h1 class="text-2xl font-bold text-gray-900">My Profile</h1> <h1 class="text-2xl font-bold text-gray-900">{{ t('profile.title') }}</h1>
<p class="text-gray-500">Manage your account settings</p> <p class="text-gray-500">{{ t('profile.subtitle') }}</p>
</div> </div>
</div> </div>
<form @submit.prevent="saveProfile" class="space-y-6"> <form @submit.prevent="saveProfile" class="space-y-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-1">Username</label> <label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.username') }}</label>
<input v-model="userStore.login" type="text" disabled class="input-field bg-gray-100" /> <input v-model="userStore.login" type="text" disabled class="input-field bg-gray-100" />
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-1">Role</label> <label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.role') }}</label>
<div class="relative"> <div class="relative">
<input :value="userStore.role === 'admin' ? 'Administrator' : 'User'" type="text" disabled class="input-field bg-gray-100" /> <input :value="userStore.role === 'admin' ? t('app.administrator') : t('app.user')" type="text" disabled class="input-field bg-gray-100" />
<div class="absolute right-3 top-2.5"> <div class="absolute right-3 top-2.5">
<span class="px-2 py-0.5 text-xs rounded-full" :class="userStore.role === 'admin' ? 'bg-purple-100 text-purple-700' : 'bg-gray-100 text-gray-600'"> <span class="px-2 py-0.5 text-xs rounded-full" :class="userStore.role === 'admin' ? 'bg-purple-100 text-purple-700' : 'bg-gray-100 text-gray-600'">
{{ userStore.role === 'admin' ? 'Admin' : 'User' }} {{ userStore.role === 'admin' ? 'Admin' : 'User' }}
@@ -40,24 +40,24 @@
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-1">Email Address</label> <label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.email') }}</label>
<input v-model="form.email" type="email" required class="input-field" /> <input v-model="form.email" type="email" required class="input-field" />
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-1">New Password</label> <label class="block text-sm font-medium text-gray-700 mb-1">{{ t('profile.newPassword') }}</label>
<input v-model="form.password" type="password" class="input-field" autocomplete="new-password" /> <input v-model="form.password" type="password" class="input-field" autocomplete="new-password" />
<p class="text-xs text-gray-500 mt-1">Leave blank to keep current password</p> <p class="text-xs text-gray-500 mt-1">{{ t('common.leavePasswordBlank') }}</p>
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-1">Confirm New Password</label> <label class="block text-sm font-medium text-gray-700 mb-1">{{ t('profile.confirmPassword') }}</label>
<input v-model="form.confirmPassword" type="password" class="input-field" :class="{ 'border-red-300': passwordMismatch }" /> <input v-model="form.confirmPassword" type="password" class="input-field" :class="{ 'border-red-300': passwordMismatch }" />
<p v-if="passwordMismatch" class="text-xs text-red-600 mt-1">Passwords do not match</p> <p v-if="passwordMismatch" class="text-xs text-red-600 mt-1">Passwords do not match</p>
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-1">Language</label> <label class="block text-sm font-medium text-gray-700 mb-1">{{ t('app.language') }}</label>
<select v-model="form.language" class="input-field"> <select v-model="form.language" class="input-field">
<option value="en">English</option> <option value="en">English</option>
<option value="ru">Русский</option> <option value="ru">Русский</option>
@@ -66,13 +66,13 @@
<div class="pt-4 border-t"> <div class="pt-4 border-t">
<div class="flex justify-end space-x-3"> <div class="flex justify-end space-x-3">
<button type="button" @click="resetForm" class="btn-secondary">Reset</button> <button type="button" @click="resetForm" class="btn-secondary">{{ t('settings.reset') }}</button>
<button type="submit" :disabled="loading" class="btn-primary flex items-center gap-2"> <button type="submit" :disabled="loading" class="btn-primary flex items-center gap-2">
<svg v-if="loading" class="animate-spin h-4 w-4 text-white" fill="none" viewBox="0 0 24 24"> <svg v-if="loading" class="animate-spin h-4 w-4 text-white" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle> <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path> <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg> </svg>
Save Changes {{ t('settings.save') }}
</button> </button>
</div> </div>
</div> </div>
@@ -102,7 +102,7 @@ import { useI18n } from 'vue-i18n';
import AppLayout from '../components/Layout/AppLayout.vue'; import AppLayout from '../components/Layout/AppLayout.vue';
const userStore = useUserStore(); const userStore = useUserStore();
const { locale } = useI18n(); const { t, locale } = useI18n();
const form = reactive({ const form = reactive({
email: '', email: '',

View File

@@ -1,12 +1,12 @@
<template> <template>
<AppLayout> <AppLayout>
<div class="flex justify-between items-center mb-6"> <div class="flex justify-between items-center mb-6">
<h1 class="text-2xl font-bold text-gray-900">Restaurants</h1> <h1 class="text-2xl font-bold text-gray-900">{{ t('restaurants.pageName') }}</h1>
<button @click="openModal('create')" class="btn-primary flex items-center gap-2"> <button @click="openModal('create')" class="btn-primary flex items-center gap-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
</svg> </svg>
Add Restaurant {{ t('restaurants.add') }}
</button> </button>
</div> </div>
@@ -15,13 +15,13 @@
<table class="min-w-full divide-y divide-gray-200"> <table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50"> <thead class="bg-gray-50">
<tr> <tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.id') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.name') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Host</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('restaurants.host') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">HTTPS</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('restaurants.https') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Login</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.login') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Created</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.created') }}</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th> <th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.actions') }}</th>
</tr> </tr>
</thead> </thead>
<tbody class="divide-y divide-gray-200 bg-white"> <tbody class="divide-y divide-gray-200 bg-white">
@@ -57,7 +57,7 @@
</td> </td>
</tr> </tr>
<tr v-if="restaurants.length === 0"> <tr v-if="restaurants.length === 0">
<td colspan="7" class="px-6 py-12 text-center text-gray-500">No restaurants found. Click "Add Restaurant" to create one.</td> <td colspan="7" class="px-6 py-12 text-center text-gray-500">{{ t('restaurants.noRestaurants') }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -80,23 +80,23 @@
</div> </div>
<form @submit.prevent="submitRestaurant" class="p-6 space-y-5"> <form @submit.prevent="submitRestaurant" class="p-6 space-y-5">
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-1">Name *</label> <label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.name') }} *</label>
<input v-model="form.name" type="text" required class="input-field" /> <input v-model="form.name" type="text" required class="input-field" />
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-1">Host *</label> <label class="block text-sm font-medium text-gray-700 mb-1">{{ t('restaurants.host') }} *</label>
<input v-model="form.host" type="text" required class="input-field" placeholder="e.g., api.example.com" /> <input v-model="form.host" type="text" required class="input-field" placeholder="e.g., api.example.com" />
</div> </div>
<div class="flex items-center"> <div class="flex items-center">
<input type="checkbox" v-model="form.https" class="rounded border-gray-300 text-primary-600 focus:ring-primary-500 w-4 h-4 mr-2" /> <input type="checkbox" v-model="form.https" class="rounded border-gray-300 text-primary-600 focus:ring-primary-500 w-4 h-4 mr-2" />
<label class="text-sm font-medium text-gray-700">Use HTTPS</label> <label class="text-sm font-medium text-gray-700">{{ t('restaurants.useHttps') }}</label>
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-1">Login *</label> <label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.login') }} *</label>
<input v-model="form.login" type="text" required class="input-field" /> <input v-model="form.login" type="text" required class="input-field" />
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-1">Password</label> <label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.password') }}</label>
<input <input
v-model="form.password" v-model="form.password"
:required="modalMode === 'create'" :required="modalMode === 'create'"
@@ -104,11 +104,11 @@
class="input-field" class="input-field"
autocomplete="new-password" autocomplete="new-password"
/> />
<p v-if="modalMode === 'edit'" class="text-xs text-gray-500 mt-1">Leave blank to keep current password</p> <p v-if="modalMode === 'edit'" class="text-xs text-gray-500 mt-1">{{ t('common.leavePasswordBlank') }}</p>
</div> </div>
<div class="flex justify-end space-x-3 pt-2"> <div class="flex justify-end space-x-3 pt-2">
<button type="button" @click="closeModal" class="btn-secondary">Cancel</button> <button type="button" @click="closeModal" class="btn-secondary">{{ t('app.cancel') }}</button>
<button type="submit" class="btn-primary">Save</button> <button type="submit" class="btn-primary">{{ t('app.save') }}</button>
</div> </div>
</form> </form>
</div> </div>
@@ -128,11 +128,11 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
</svg> </svg>
</div> </div>
<h3 class="text-lg font-medium text-gray-900 mb-2">Delete Restaurant</h3> <h3 class="text-lg font-medium text-gray-900 mb-2">{{ t('restaurants.delete') }}</h3>
<p class="text-sm text-gray-500 mb-6">Are you sure you want to delete this restaurant? This action cannot be undone.</p> <p class="text-sm text-gray-500 mb-6">{{ t('restaurants.deleteConfirmation') }}</p>
<div class="flex justify-center space-x-3"> <div class="flex justify-center space-x-3">
<button @click="deleteConfirm.show = false" class="btn-secondary">Cancel</button> <button @click="deleteConfirm.show = false" class="btn-secondary">{{ t('app.cancel') }}</button>
<button @click="deleteRestaurant(deleteConfirm.id)" class="bg-red-600 text-white px-4 py-2 rounded-lg hover:bg-red-700 transition-colors">Delete</button> <button @click="deleteUser(deleteConfirm.id)" class="bg-red-600 text-white px-4 py-2 rounded-lg hover:bg-red-700 transition-colors">{{ t('app.delete') }}</button>
</div> </div>
</div> </div>
</div> </div>
@@ -145,7 +145,9 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted } from 'vue'; import { ref, onMounted } from 'vue';
import AppLayout from '../components/Layout/AppLayout.vue'; import AppLayout from '../components/Layout/AppLayout.vue';
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const restaurants = ref([]); const restaurants = ref([]);
const modalOpen = ref(false); const modalOpen = ref(false);
const modalMode = ref<'create' | 'edit'>('create'); const modalMode = ref<'create' | 'edit'>('create');
@@ -167,7 +169,7 @@ function openModal(mode: 'create' | 'edit', rest: any = null) {
modalMode.value = mode; modalMode.value = mode;
if (mode === 'create') { if (mode === 'create') {
form.value = { id: null, name: '', login: '', password: '', host: '', https: false }; form.value = { id: null, name: '', login: '', password: '', host: '', https: false };
modalTitle.value = 'Create Restaurant'; modalTitle.value = t('restaurants.add');
} else { } else {
form.value = { form.value = {
id: rest.id, id: rest.id,
@@ -177,7 +179,7 @@ function openModal(mode: 'create' | 'edit', rest: any = null) {
host: rest.host, host: rest.host,
https: rest.https || false https: rest.https || false
}; };
modalTitle.value = 'Edit Restaurant'; modalTitle.value = t('restaurants.edit');
} }
modalOpen.value = true; modalOpen.value = true;
} }

View File

@@ -1,12 +1,12 @@
<template> <template>
<AppLayout> <AppLayout>
<div class="flex justify-between items-center mb-6"> <div class="flex justify-between items-center mb-6">
<h1 class="text-2xl font-bold text-gray-900">{{ t('user.pageName') }}</h1> <h1 class="text-2xl font-bold text-gray-900">{{ t('users.pageName') }}</h1>
<button @click="openModal('create')" class="btn-primary flex items-center gap-2"> <button @click="openModal('create')" class="btn-primary flex items-center gap-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
</svg> </svg>
{{ t('user.add') }} {{ t('users.add') }}
</button> </button>
</div> </div>
@@ -15,14 +15,14 @@
<table class="min-w-full divide-y divide-gray-200"> <table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50"> <thead class="bg-gray-50">
<tr> <tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.id') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Login</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.login') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.email') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Role</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.role') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.status') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">IP</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.ip') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Created</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.created') }}</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th> <th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.actions') }}</th>
</tr> </tr>
</thead> </thead>
<tbody class="divide-y divide-gray-200 bg-white"> <tbody class="divide-y divide-gray-200 bg-white">
@@ -32,11 +32,11 @@
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ user.email }}</td> <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ user.email }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm"> <td class="px-6 py-4 whitespace-nowrap text-sm">
<span class="px-2 py-1 text-xs rounded-full" :class="user.role === 'admin' ? 'bg-purple-100 text-purple-700' : 'bg-gray-100 text-gray-600'"> <span class="px-2 py-1 text-xs rounded-full" :class="user.role === 'admin' ? 'bg-purple-100 text-purple-700' : 'bg-gray-100 text-gray-600'">
{{ user.role === 'admin' ? 'Administrator' : 'User' }} {{ user.role === 'admin' ? t('app.administrator') : t('app.user') }}
</span> </span>
</td> </td>
<td class="px-6 py-4 whitespace-nowrap text-sm"> <td class="px-6 py-4 whitespace-nowrap text-sm">
<div v-if="user.id === currentUserId" class="text-xs text-gray-500">(You)</div> <div v-if="user.id === currentUserId" class="text-xs text-gray-500">{{ t('users.you') }}</div>
<label v-else class="relative inline-flex items-center cursor-pointer"> <label v-else class="relative inline-flex items-center cursor-pointer">
<input <input
type="checkbox" type="checkbox"
@@ -93,23 +93,23 @@
</div> </div>
<form @submit.prevent="submitUser" class="p-6 space-y-5"> <form @submit.prevent="submitUser" class="p-6 space-y-5">
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-1">Email *</label> <label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.email') }} *</label>
<input v-model="form.email" type="email" required class="input-field" /> <input v-model="form.email" type="email" required class="input-field" />
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-1">Login *</label> <label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.login') }} *</label>
<input v-model="form.login" type="text" required class="input-field" /> <input v-model="form.login" type="text" required class="input-field" />
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-1">Role</label> <label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.role') }}</label>
<select v-model="form.role" class="input-field" :disabled="isEditingSelf"> <select v-model="form.role" class="input-field" :disabled="isEditingSelf">
<option value="user">User</option> <option value="user">{{ t('app.user') }}</option>
<option value="admin">Administrator</option> <option value="admin">{{ t('app.administrator') }}</option>
</select> </select>
<p v-if="isEditingSelf" class="text-xs text-amber-600 mt-1">You cannot change your own role</p> <p v-if="isEditingSelf" class="text-xs text-amber-600 mt-1">{{ t('users.cannotChangeOwnRole') }}</p>
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-1">Password</label> <label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.password') }}</label>
<input <input
v-model="form.password" v-model="form.password"
:required="modalMode === 'create'" :required="modalMode === 'create'"
@@ -117,11 +117,11 @@
class="input-field" class="input-field"
autocomplete="new-password" autocomplete="new-password"
/> />
<p v-if="modalMode === 'edit'" class="text-xs text-gray-500 mt-1">Leave blank to keep current password</p> <p v-if="modalMode === 'edit'" class="text-xs text-gray-500 mt-1">{{ t('common.leavePasswordBlank') }}</p>
</div> </div>
<div class="flex justify-end space-x-3 pt-2"> <div class="flex justify-end space-x-3 pt-2">
<button type="button" @click="closeModal" class="btn-secondary">Cancel</button> <button type="button" @click="closeModal" class="btn-secondary">{{ t('app.cancel') }}</button>
<button type="submit" class="btn-primary">Save</button> <button type="submit" class="btn-primary">{{ t('app.save') }}</button>
</div> </div>
</form> </form>
</div> </div>
@@ -141,11 +141,11 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
</svg> </svg>
</div> </div>
<h3 class="text-lg font-medium text-gray-900 mb-2">Delete User</h3> <h3 class="text-lg font-medium text-gray-900 mb-2">{{ t('users.delete') }}</h3>
<p class="text-sm text-gray-500 mb-6">Are you sure you want to delete this user? This action cannot be undone.</p> <p class="text-sm text-gray-500 mb-6">{{ t('users.deleteConfirmation') }}</p>
<div class="flex justify-center space-x-3"> <div class="flex justify-center space-x-3">
<button @click="deleteConfirm.show = false" class="btn-secondary">Cancel</button> <button @click="deleteConfirm.show = false" class="btn-secondary">{{ t('app.cancel') }}</button>
<button @click="deleteUser(deleteConfirm.id)" class="bg-red-600 text-white px-4 py-2 rounded-lg hover:bg-red-700 transition-colors">Delete</button> <button @click="deleteUser(deleteConfirm.id)" class="bg-red-600 text-white px-4 py-2 rounded-lg hover:bg-red-700 transition-colors">{{ t('app.delete') }}</button>
</div> </div>
</div> </div>
</div> </div>
@@ -208,10 +208,10 @@ function openModal(mode: 'create' | 'edit', user: any = null) {
modalMode.value = mode; modalMode.value = mode;
if (mode === 'create') { if (mode === 'create') {
form.value = { id: null, login: '', email: '', password: '', role: 'user' }; form.value = { id: null, login: '', email: '', password: '', role: 'user' };
modalTitle.value = t('user.add'); modalTitle.value = t('users.add');
} else { } else {
form.value = { id: user.id, login: user.login, email: user.email, password: '', role: user.role || 'user' }; form.value = { id: user.id, login: user.login, email: user.email, password: '', role: user.role || 'user' };
modalTitle.value = t('user.edit'); modalTitle.value = t('users.edit');
} }
modalOpen.value = true; modalOpen.value = true;
} }

View File

@@ -8,15 +8,15 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
</svg> </svg>
</div> </div>
<h1 class="text-3xl font-bold text-gray-900">Welcome Back</h1> <h1 class="text-3xl font-bold text-gray-900">{{ t('login.title') }}</h1>
<p class="text-gray-600 mt-2">Sign in to your account</p> <p class="text-gray-600 mt-2">{{ t('login.subtitle') }}</p>
</div> </div>
<!-- Login Form --> <!-- Login Form -->
<div class="bg-white rounded-2xl shadow-xl p-8"> <div class="bg-white rounded-2xl shadow-xl p-8">
<form @submit.prevent="handleLogin" class="space-y-6"> <form @submit.prevent="handleLogin" class="space-y-6">
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-2">Username or Email</label> <label class="block text-sm font-medium text-gray-700 mb-2">{{ t('login.username') }}</label>
<div class="relative"> <div class="relative">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none"> <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -34,7 +34,7 @@
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-2">Password</label> <label class="block text-sm font-medium text-gray-700 mb-2">{{ t('common.password') }}</label>
<div class="relative"> <div class="relative">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none"> <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -65,14 +65,14 @@
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<label class="flex items-center"> <label class="flex items-center">
<input type="checkbox" class="rounded border-gray-300 text-primary-600 focus:ring-primary-500" /> <input type="checkbox" class="rounded border-gray-300 text-primary-600 focus:ring-primary-500" />
<span class="ml-2 text-sm text-gray-600">Remember me</span> <span class="ml-2 text-sm text-gray-600">{{ t('login.remember') }}</span>
</label> </label>
<router-link <router-link
v-if="settings.enableRegistration" v-if="settings.enableRegistration"
to="/register" to="/register"
class="text-sm text-primary-600 hover:text-primary-700" class="text-sm text-primary-600 hover:text-primary-700"
> >
Create account {{ t('login.createAccount') }}
</router-link> </router-link>
</div> </div>
@@ -81,7 +81,7 @@
:disabled="loading" :disabled="loading"
class="w-full btn-primary py-3 relative" class="w-full btn-primary py-3 relative"
> >
<span v-if="!loading">Sign In</span> <span v-if="!loading">{{ t('login.signin') }}</span>
<svg v-else class="animate-spin h-5 w-5 mx-auto text-white" fill="none" viewBox="0 0 24 24"> <svg v-else class="animate-spin h-5 w-5 mx-auto text-white" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle> <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path> <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
@@ -105,10 +105,12 @@ import { ref } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { useSettingsStore } from '../../stores/settings' import { useSettingsStore } from '../../stores/settings'
import { useUserStore } from '../../stores/user' import { useUserStore } from '../../stores/user'
import { useI18n } from 'vue-i18n'
const settings = useSettingsStore() const settings = useSettingsStore()
const userStore = useUserStore() const userStore = useUserStore()
const router = useRouter() const router = useRouter()
const { t, locale } = useI18n()
const form = ref({ login: '', password: '' }) const form = ref({ login: '', password: '' })
const loading = ref(false) const loading = ref(false)
const error = ref('') const error = ref('')
@@ -124,15 +126,19 @@ async function handleLogin() {
body: JSON.stringify(form.value) body: JSON.stringify(form.value)
}) })
if (res.ok) { if (res.ok) {
// Загружаем профиль (роль, язык, email)
await userStore.fetchProfile() await userStore.fetchProfile()
// Устанавливаем язык интерфейса из профиля
if (userStore.language) {
locale.value = userStore.language
localStorage.setItem('locale', userStore.language)
}
router.push('/dashboard') router.push('/dashboard')
} else { } else {
const text = await res.text() const text = await res.text()
error.value = text || 'Invalid username or password' error.value = text || t('login.invalidCredentials')
} }
} catch (e) { } catch (e) {
error.value = 'Network error. Please try again.' error.value = t('login.networkError')
} finally { } finally {
loading.value = false loading.value = false
} }

View File

@@ -7,32 +7,32 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18 9v3m0 0v3m0-3h3m-3 0h-3m-2-5a4 4 0 11-8 0 4 4 0 018 0zM3 20a6 6 0 0112 0v1H3v-1z" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18 9v3m0 0v3m0-3h3m-3 0h-3m-2-5a4 4 0 11-8 0 4 4 0 018 0zM3 20a6 6 0 0112 0v1H3v-1z" />
</svg> </svg>
</div> </div>
<h1 class="text-3xl font-bold text-gray-900">Create Account</h1> <h1 class="text-3xl font-bold text-gray-900">{{ t('register.title') }}</h1>
<p class="text-gray-600 mt-2">Register and wait for admin approval</p> <p class="text-gray-600 mt-2">{{ t('register.subtitle') }}</p>
</div> </div>
<div class="bg-white rounded-2xl shadow-xl p-8"> <div class="bg-white rounded-2xl shadow-xl p-8">
<form @submit.prevent="handleRegister" class="space-y-6"> <form @submit.prevent="handleRegister" class="space-y-6">
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-2">Username</label> <label class="block text-sm font-medium text-gray-700 mb-2">{{ t('register.username') }}</label>
<input v-model="form.login" type="text" required minlength="3" class="input-field" /> <input v-model="form.login" type="text" required minlength="3" class="input-field" />
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-2">Email</label> <label class="block text-sm font-medium text-gray-700 mb-2">{{ t('common.email') }}</label>
<input v-model="form.email" type="email" required class="input-field" /> <input v-model="form.email" type="email" required class="input-field" />
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-2">Password</label> <label class="block text-sm font-medium text-gray-700 mb-2">{{ t('common.password') }}</label>
<input v-model="form.password" type="password" required minlength="6" class="input-field" /> <input v-model="form.password" type="password" required minlength="6" class="input-field" />
</div> </div>
<button type="submit" :disabled="loading" class="w-full btn-primary py-3"> <button type="submit" :disabled="loading" class="w-full btn-primary py-3">
<span v-if="!loading">Register</span> <span v-if="!loading">{{ t('register.register') }}</span>
<span v-else>Loading...</span> <span v-else>Loading...</span>
</button> </button>
</form> </form>
<p v-if="success" class="mt-4 text-green-600 text-center">Account created! Wait for admin activation.</p> <p v-if="success" class="mt-4 text-green-600 text-center">{{ t('register.success') }}</p>
<p v-if="error" class="mt-4 text-red-600 text-center">{{ error }}</p> <p v-if="error" class="mt-4 text-red-600 text-center">{{ error }}</p>
<p class="mt-4 text-center text-sm text-gray-600"> <p class="mt-4 text-center text-sm text-gray-600">
Already have an account? <router-link to="/login" class="text-primary-600">Login</router-link> {{ t('register.alreadyHaveAccount') }} <router-link to="/login" class="text-primary-600">{{ t('login.signin') }}</router-link>
</p> </p>
</div> </div>
</div> </div>
@@ -41,6 +41,8 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const form = ref({ login: '', email: '', password: '' }) const form = ref({ login: '', email: '', password: '' })
const loading = ref(false) const loading = ref(false)
const error = ref('') const error = ref('')

View File

@@ -8,8 +8,8 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
</svg> </svg>
</div> </div>
<h1 class="text-3xl font-bold text-gray-900">Setup Admin Account</h1> <h1 class="text-3xl font-bold text-gray-900">{{ t('setup.title') }}</h1>
<p class="text-gray-600 mt-2">Create your administrator account</p> <p class="text-gray-600 mt-2">{{ t('setup.subtitle') }}</p>
</div> </div>
<!-- Setup Form --> <!-- Setup Form -->
@@ -19,19 +19,19 @@
<div class="flex items-center justify-center"> <div class="flex items-center justify-center">
<div class="flex items-center"> <div class="flex items-center">
<div class="w-8 h-8 bg-primary-600 rounded-full flex items-center justify-center text-white font-semibold">1</div> <div class="w-8 h-8 bg-primary-600 rounded-full flex items-center justify-center text-white font-semibold">1</div>
<div class="ml-2 text-sm font-medium text-gray-900">Account Details</div> <div class="ml-2 text-sm font-medium text-gray-900">{{ t('setup.step1') }}</div>
</div> </div>
<div class="mx-4 w-12 h-0.5 bg-gray-300"></div> <div class="mx-4 w-12 h-0.5 bg-gray-300"></div>
<div class="flex items-center"> <div class="flex items-center">
<div class="w-8 h-8 bg-gray-300 rounded-full flex items-center justify-center text-gray-600 font-semibold">2</div> <div class="w-8 h-8 bg-gray-300 rounded-full flex items-center justify-center text-gray-600 font-semibold">2</div>
<div class="ml-2 text-sm font-medium text-gray-500">Complete</div> <div class="ml-2 text-sm font-medium text-gray-500">{{ t('setup.step2') }}</div>
</div> </div>
</div> </div>
</div> </div>
<form @submit.prevent="handleSetup" class="space-y-6"> <form @submit.prevent="handleSetup" class="space-y-6">
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-2">Username</label> <label class="block text-sm font-medium text-gray-700 mb-2">{{ t('common.username') }}</label>
<div class="relative"> <div class="relative">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none"> <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -52,7 +52,7 @@
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-2">Email</label> <label class="block text-sm font-medium text-gray-700 mb-2">{{ t('common.email') }}</label>
<div class="relative"> <div class="relative">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none"> <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -72,7 +72,7 @@
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-2">Password</label> <label class="block text-sm font-medium text-gray-700 mb-2">{{ t('common.password') }}</label>
<div class="relative"> <div class="relative">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none"> <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -105,7 +105,7 @@
<!-- Password Strength --> <!-- Password Strength -->
<div v-if="form.password" class="mt-2"> <div v-if="form.password" class="mt-2">
<div class="flex items-center justify-between mb-1"> <div class="flex items-center justify-between mb-1">
<span class="text-xs text-gray-600">Password strength</span> <span class="text-xs text-gray-600">{{ t('setup.passwordStrength') }}</span>
<span class="text-xs font-medium" :class="strengthColor">{{ strengthText }}</span> <span class="text-xs font-medium" :class="strengthColor">{{ strengthText }}</span>
</div> </div>
<div class="h-1.5 bg-gray-200 rounded-full overflow-hidden"> <div class="h-1.5 bg-gray-200 rounded-full overflow-hidden">
@@ -123,7 +123,7 @@
:disabled="loading" :disabled="loading"
class="w-full btn-primary py-3 relative overflow-hidden group" class="w-full btn-primary py-3 relative overflow-hidden group"
> >
<span v-if="!loading" class="relative z-10">Create Account</span> <span v-if="!loading" class="relative z-10">{{ t('setup.createAccount') }}</span>
<svg v-else class="animate-spin h-5 w-5 mx-auto text-white" fill="none" viewBox="0 0 24 24"> <svg v-else class="animate-spin h-5 w-5 mx-auto text-white" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle> <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path> <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
@@ -151,7 +151,8 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, computed, watch } from 'vue' import { ref, computed, watch } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const router = useRouter() const router = useRouter()
const form = ref({ login: '', email: '', password: '' }); const form = ref({ login: '', email: '', password: '' });
const loading = ref(false) const loading = ref(false)
@@ -186,8 +187,9 @@ const passwordStrength = computed(() => {
const strengthPercent = computed(() => (passwordStrength.value / 5) * 100) const strengthPercent = computed(() => (passwordStrength.value / 5) * 100)
const strengthText = computed(() => { const strengthText = computed(() => {
const texts = ['Very Weak', 'Weak', 'Fair', 'Good', 'Strong'] const keys = ['setup.veryWeak', 'setup.weak', 'setup.fair', 'setup.good', 'setup.strong']
return texts[passwordStrength.value - 1] || '' const key = keys[passwordStrength.value - 1]
return key ? t(key) : ''
}) })
const strengthColor = computed(() => { const strengthColor = computed(() => {

View File

@@ -9,9 +9,7 @@ import io.vertx.sqlclient.Tuple;
import io.vertx.sqlclient.templates.SqlTemplate; import io.vertx.sqlclient.templates.SqlTemplate;
import org.mindrot.jbcrypt.BCrypt; import org.mindrot.jbcrypt.BCrypt;
import java.util.Collections; import java.util.*;
import java.util.HashMap;
import java.util.Map;
public class UserService { public class UserService {
private final Pool pool; private final Pool pool;
@@ -159,16 +157,30 @@ public class UserService {
public Future<Void> updateProfile(int userId, String email, String password, String language) { public Future<Void> updateProfile(int userId, String email, String password, String language) {
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("id", userId); params.put("id", userId);
List<String> setClauses = new ArrayList<>();
if (email != null) {
setClauses.add("email = #{email}");
params.put("email", email); params.put("email", email);
if (language != null) params.put("language", language); }
String sql;
if (password != null && !password.isEmpty()) { if (password != null && !password.isEmpty()) {
String hash = BCrypt.hashpw(password, BCrypt.gensalt()); String hash = BCrypt.hashpw(password, BCrypt.gensalt());
setClauses.add("password = #{password}");
params.put("password", hash); params.put("password", hash);
sql = "UPDATE users SET email = #{email}, password = #{password}, language = COALESCE(#{language}, language) WHERE id = #{id}";
} else {
sql = "UPDATE users SET email = #{email}, language = COALESCE(#{language}, language) WHERE id = #{id}";
} }
if (language != null) {
setClauses.add("language = #{language}");
params.put("language", language);
}
if (setClauses.isEmpty()) {
// Ни одно поле не обновляется — возвращаем успешный Future
return Future.succeededFuture();
}
String sql = "UPDATE users SET " + String.join(", ", setClauses) + " WHERE id = #{id}";
return SqlTemplate.forUpdate(pool, sql).execute(params).mapEmpty(); return SqlTemplate.forUpdate(pool, sql).execute(params).mapEmpty();
} }