feat: implement core frontend dashboard, auth flow, and AI-driven case management system

This commit is contained in:
2026-05-13 00:16:58 +03:00
parent 0732acbda5
commit 38f3199c33
5 changed files with 171 additions and 3 deletions

View File

@@ -272,10 +272,86 @@ function initTabs() {
if(target === 'seo-section') loadSEO();
if(target === 'content-section') loadReferences();
if(target === 'finance-section') { /* No initial load */ }
if(target === 'generator-section') { /* No initial load */ }
});
});
}
document.getElementById('ai-gen-card-btn').addEventListener('click', async () => {
const title = document.getElementById('gen-title-input').value;
if (!title) {
alert('Введите название товара');
return;
}
const btn = document.getElementById('ai-gen-card-btn');
const originalText = btn.innerHTML;
btn.disabled = true;
btn.innerHTML = '<i data-lucide="loader-2" class="icon-sm spin"></i> Магия ИИ в процессе...';
if (window.lucide) lucide.createIcons();
try {
const token = localStorage.getItem('token');
const res = await fetch('http://localhost:5000/api/ai/generate-card', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({ title })
});
const data = await res.json();
if (data.error) throw new Error(data.error);
document.getElementById('gen-result-container').classList.remove('hidden');
document.getElementById('gen-description').innerText = data.description;
// Tags
const tagsDiv = document.getElementById('gen-tags');
tagsDiv.innerHTML = '';
data.seo_tags.forEach(tag => {
const span = document.createElement('span');
span.className = 'status-pill';
span.style.background = 'rgba(255,255,255,0.1)';
span.innerText = `#${tag}`;
tagsDiv.appendChild(span);
});
// Features
const featuresTbody = document.querySelector('#gen-features-table tbody');
featuresTbody.innerHTML = '';
for (const [key, val] of Object.entries(data.features)) {
const tr = document.createElement('tr');
tr.innerHTML = `<td><strong>${key}</strong></td><td>${val}</td>`;
featuresTbody.appendChild(tr);
}
// Image Prompts
const promptsDiv = document.getElementById('gen-image-prompts');
promptsDiv.innerHTML = '';
data.image_prompts.forEach((p, i) => {
const pBox = document.createElement('div');
pBox.style.background = 'rgba(0,0,0,0.2)';
pBox.style.padding = '10px';
pBox.style.borderRadius = '8px';
pBox.style.marginBottom = '10px';
pBox.style.fontSize = '0.8rem';
pBox.innerHTML = `<strong>Вариант ${i+1}:</strong><br>${p}`;
promptsDiv.appendChild(pBox);
});
showToast('Карточка успешно сгенерирована!', 'success');
} catch (err) {
alert(err.message);
} finally {
btn.disabled = false;
btn.innerHTML = originalText;
if (window.lucide) lucide.createIcons();
}
});
document.getElementById('pnl-form').addEventListener('submit', async (e) => {
e.preventDefault();
const fd = new FormData(e.target);