fix and refactor code

This commit is contained in:
2026-04-27 15:45:06 +03:00
parent 316d06b1d2
commit 05076eb367
17 changed files with 89 additions and 91 deletions

View File

@@ -58,22 +58,18 @@
<button type="submit" class="btn-primary">{{ t('settings.save') }}</button>
</div>
</form>
<div v-if="message" class="mt-4 p-3 rounded-lg" :class="messageClass">
{{ message }}
</div>
</div>
</AppLayout>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import AppLayout from '../components/Layout/AppLayout.vue';
import AppLayout from '@/components/Layout/AppLayout.vue';
import { useI18n } from 'vue-i18n'
import { useNotification } from '../composables/useNotification'
import { useNotification } from '@/composables/useNotification'
const { showNotification } = useNotification()
const { t, locale } = useI18n()
const { t } = useI18n()
interface FieldMeta {
key: string;
label: string;
@@ -86,11 +82,9 @@ interface FieldMeta {
const meta = ref<FieldMeta[]>([]);
const values = ref<Record<string, string>>({});
const message = ref('');
const messageClass = ref('');
async function loadMeta() {
const res = await fetch('/api/settings/meta');
const res = await fetch('/api/admin/settings/meta');
if (res.ok) {
meta.value = await res.json();
} else {
@@ -99,7 +93,7 @@ async function loadMeta() {
}
async function loadValues() {
const res = await fetch('/api/settings/all');
const res = await fetch('/api/admin/settings');
if (res.ok) {
values.value = await res.json();
} else {
@@ -128,13 +122,5 @@ async function saveSettings() {
}
}
function showMessage(text: string, cssClass: string) {
message.value = text;
messageClass.value = cssClass;
setTimeout(() => {
message.value = '';
}, 3000);
}
onMounted(loadData);
</script>

View File

@@ -23,8 +23,8 @@
<div class="card hover:shadow-md transition-shadow">
<div class="flex items-center justify-between">
<div>
<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-sm font-medium text-gray-600">{{ t('dashboard.totalRestaurants') }}</p>
<p class="text-3xl font-bold text-gray-900 mt-2">{{ stats.totalRestaurants }}</p>
</div>
<div class="w-12 h-12 bg-green-100 rounded-xl flex items-center justify-center">
<svg class="w-6 h-6 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -175,13 +175,13 @@
<script setup lang="ts">
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()
import { useNotification } from '../composables/useNotification'
import { useNotification } from '@/composables/useNotification'
const { showNotification } = useNotification()
const stats = ref({ totalUsers: 0, activeSessions: 0, systemHealth: 100, uptime: '99.9%' });
const stats = ref({ totalUsers: 0, totalRestaurants: 0, systemHealth: 100, uptime: '99.9%' });
const userGrowth = ref(12);
const sessionGrowth = ref(5);
const recentUsers = ref([]);
@@ -195,20 +195,18 @@ let interval: number;
async function loadDashboardData() {
try {
const [usersRes, sessionsRes, healthRes, restaurantsRes] = await Promise.all([
const [usersRes, healthRes, restaurantsRes] = await Promise.all([
fetch('/api/admin/users'),
fetch('/api/admin/active-sessions'),
fetch('/api/health'),
fetch('/api/admin/restaurants')
]);
const users = await usersRes.json();
const sessions = await sessionsRes.json();
const health = await healthRes.json();
const restaurants = await restaurantsRes.json();
stats.value.totalUsers = users.length;
stats.value.activeSessions = sessions.count || 0;
stats.value.totalRestaurants = restaurants.length;
recentUsers.value = users.slice(-5).reverse();
recentRestaurants.value = restaurants.slice(-5).reverse();

View File

@@ -84,10 +84,12 @@
<script setup lang="ts">
import { ref, reactive, computed, onMounted } from 'vue';
import { useUserStore } from '../stores/user';
import { useUserStore } from '@/stores/user';
import { useI18n } from 'vue-i18n';
import AppLayout from '../components/Layout/AppLayout.vue';
import AppLayout from '@/components/Layout/AppLayout.vue';
import {useNotification} from "@/composables/useNotification";
const { showNotification } = useNotification();
const userStore = useUserStore();
const { t, locale } = useI18n();
@@ -129,7 +131,7 @@ async function saveProfile() {
if (ok) {
locale.value = form.language;
showNotification('profile.updateSuccess', 'success');
resetForm(); // очищаем поля пароля
resetForm();
} else {
showNotification('profile.updateError', 'error');
}

View File

@@ -153,9 +153,9 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import AppLayout from '../components/Layout/AppLayout.vue';
import AppLayout from '@/components/Layout/AppLayout.vue';
import { useI18n } from 'vue-i18n';
import { useNotification } from '../composables/useNotification';
import { useNotification } from '@/composables/useNotification';
const { t } = useI18n();
const { showNotification } = useNotification();

View File

@@ -155,10 +155,10 @@
<script setup lang="ts">
import { ref, onMounted, computed } from 'vue';
import AppLayout from '../components/Layout/AppLayout.vue';
import { useUserStore } from '../stores/user';
import AppLayout from '@/components/Layout/AppLayout.vue';
import { useUserStore } from '@/stores/user';
import { useI18n } from 'vue-i18n';
import { useNotification } from '../composables/useNotification';
import { useNotification } from '@/composables/useNotification';
const { t } = useI18n();
const { showNotification } = useNotification();

View File

@@ -103,8 +103,8 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { useSettingsStore } from '../../stores/settings'
import { useUserStore } from '../../stores/user'
import { useSettingsStore } from '@/stores/settings'
import { useUserStore } from '@/stores/user'
import { useI18n } from 'vue-i18n'
const settings = useSettingsStore()