пользователь

This commit is contained in:
2026-02-07 00:56:09 +05:00
parent 5f34e17bee
commit 8ff87ec2a8

View File

@@ -119,6 +119,8 @@ async function logout() {
} }
function showAdminSection(sectionName) { function showAdminSection(sectionName) {
console.log('showAdminSection called with:', sectionName);
// Убираем активный класс у всех вкладок // Убираем активный класс у всех вкладок
document.querySelectorAll('.admin-tab').forEach(tab => { document.querySelectorAll('.admin-tab').forEach(tab => {
tab.classList.remove('active'); tab.classList.remove('active');
@@ -130,48 +132,74 @@ function showAdminSection(sectionName) {
}); });
// Находим и активируем соответствующую вкладку // Находим и активируем соответствующую вкладку
const tab = document.querySelector(`.admin-tab[onclick*="showAdminSection('${sectionName}')"]`); const tabs = document.querySelectorAll('.admin-tab');
if (tab) { let tabFound = false;
tab.classList.add('active');
} else { tabs.forEach(tab => {
// Альтернативный поиск если выше не сработал const onclick = tab.getAttribute('onclick');
const tabs = document.querySelectorAll('.admin-tab'); if (onclick && onclick.includes(`showAdminSection('${sectionName}')`)) {
tabs.forEach(t => { tab.classList.add('active');
if (t.textContent.toLowerCase().includes(sectionName)) { tabFound = true;
t.classList.add('active'); }
});
// Если не нашли по onclick, ищем по тексту
if (!tabFound) {
tabs.forEach(tab => {
const tabText = tab.textContent.toLowerCase();
if (tabText.includes(sectionName.toLowerCase())) {
tab.classList.add('active');
} }
}); });
} }
// Активируем соответствующую секцию // Активируем соответствующую секцию
const section = document.getElementById(`admin-${sectionName}`); const sectionId = `admin-${sectionName}-section`;
let section = document.getElementById(sectionId);
// Если не нашли по такому ID, пробуем другие варианты
if (!section) {
if (sectionName === 'users') {
section = document.getElementById('admin-users-section');
} else if (sectionName === 'dashboard') {
section = document.getElementById('admin-dashboard');
} else if (sectionName === 'stats') {
section = document.getElementById('admin-stats-section');
} else {
// Пробуем найти по частичному совпадению
const sections = document.querySelectorAll('.admin-section');
sections.forEach(s => {
if (s.id.includes(sectionName)) {
section = s;
}
});
}
}
if (section) { if (section) {
section.classList.add('active'); section.classList.add('active');
console.log('Activated section:', section.id);
} else { } else {
// Если секция не найдена по ID, ищем по другому шаблону console.error('Section not found for:', sectionName);
const sections = document.querySelectorAll('.admin-section');
sections.forEach(s => {
if (s.id.includes(sectionName)) {
s.classList.add('active');
}
});
} }
// Загружаем данные для активной секции // Загружаем данные для активной секции
if (sectionName === 'users') { setTimeout(() => {
loadUsers(); if (sectionName === 'users') {
} else if (sectionName === 'dashboard') { console.log('Loading users...');
if (typeof renderDashboard === 'function') { loadUsers();
renderDashboard(); } else if (sectionName === 'dashboard') {
console.log('Loading dashboard...');
if (typeof renderDashboard === 'function') {
renderDashboard();
}
} else if (sectionName === 'stats') {
console.log('Loading stats...');
if (typeof renderStatsSection === 'function') {
renderStatsSection();
}
} }
} else if (sectionName === 'stats') { }, 50);
if (typeof renderStatsSection === 'function') {
renderStatsSection();
} else if (typeof checkAndRenderStats === 'function') {
// Альтернативный вызов если функция переименована
checkAndRenderStats();
}
}
} }
async function loadUsers() { async function loadUsers() {