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

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