diff --git a/frontend/js/app.js b/frontend/js/app.js index 67951c5..92b08e0 100644 --- a/frontend/js/app.js +++ b/frontend/js/app.js @@ -64,7 +64,7 @@ function initSocket() { document.addEventListener("DOMContentLoaded", async () => { initAuth(); initReports(); - initSocket(); + try { initSocket(); } catch(e) { console.warn('Socket.IO не подключен:', e.message); } // Check if logged in const token = localStorage.getItem('token'); @@ -863,7 +863,7 @@ async function initCases() { try { const token = localStorage.getItem('token'); - const res = await fetch('http://localhost:5000/api/ai/generate-complaint', { + const res = await fetch('/api/ai/generate-complaint', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -905,7 +905,7 @@ async function initCases() { try { const token = localStorage.getItem('token'); - const res = await fetch('http://localhost:5000/api/ai/generate-reply', { + const res = await fetch('/api/ai/generate-reply', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -949,61 +949,7 @@ async function initReports() { }); } -async function loadDashboard() { - // Update counters - document.getElementById('stat-cases').innerText = data.total_cases; - document.getElementById('stat-integrations').innerText = data.total_integrations; - document.getElementById('stat-sales').innerText = `${data.total_sales.toLocaleString()} ₽`; - - // Update stores table (multi-account) - const storesTbody = document.querySelector('#stores-table tbody'); - storesTbody.innerHTML = ''; - data.stores.forEach(s => { - const tr = document.createElement('tr'); - tr.innerHTML = ` - ${s.name} - ${s.platform} - ● Online - ${s.daily_sales.toLocaleString()} ₽ - `; - storesTbody.appendChild(tr); - }); - - // Update Activity Table - const tbody = document.querySelector('#recent-activity-table tbody'); - tbody.innerHTML = 'Загрузка...'; - - try { - const cases = await api.fetchCases({ article, status, platform }); - tbody.innerHTML = ''; - if (cases.length === 0) { - tbody.innerHTML = 'Нет жалоб'; - return; - } - - cases.forEach(c => { - const tr = document.createElement('tr'); - const pName = PLATFORMS.find(p => p.id === c.platform)?.name || c.platform; - const statusClass = c.status === 'new' ? 'status-new' : (c.status === 'closed' ? 'status-closed' : ''); - - tr.innerHTML = ` - #${c.id} - ${pName} - ${c.violator_article} - ${c.status} - ${new Date(c.created_at).toLocaleDateString()} - - - - - `; - tbody.appendChild(tr); - }); - if (window.lucide) lucide.createIcons(); - } catch (err) { - tbody.innerHTML = 'Ошибка сети'; - } -} +// Дублирующий loadDashboard удалён — используется функция из строки ~149 window.viewCase = async function(id) { currentViewCaseId = id; @@ -1026,7 +972,7 @@ window.viewCase = async function(id) { if (files && files.length > 0) { html += `

Файлы доказательств:

`; files.forEach(f => { - const url = `http://localhost:5000/api/uploads/${f.path.split('/').pop()}`; + const url = `/api/uploads/${f.path.split('/').pop()}`; html += `Док`; }); html += `
`;