@@ -166,6 +173,19 @@ body{font-family:'Inter',sans-serif;background:var(--bg);color:var(--text);displ
+
+
+
👤
Профиль компании
Расскажите о вашей деятельности
Базовая информация — Елена начнёт разговор уже зная контекст
+
+
+
💬
Этап 1 из 5 · В процессе
Знакомство
Расскажите Елене о вашем бизнесе — текстом или голосом
@@ -217,13 +237,29 @@ function go(n){
cur=n;
document.querySelectorAll('.sv').forEach(s=>s.classList.remove('active'));
document.getElementById('sv'+n).classList.add('active');
- document.querySelectorAll('.si').forEach((s,i)=>{s.classList.toggle('active',i+1===n)});
- document.getElementById('pbPct').textContent=PCTS[n]+'%';
- document.getElementById('pbFill').style.width=PCTS[n]+'%';
+ document.querySelectorAll('.si').forEach(s=>s.classList.remove('active'));
+ document.getElementById('si'+n).classList.add('active');
+ if(PCTS[n]!=null){document.getElementById('pbPct').textContent=PCTS[n]+'%';document.getElementById('pbFill').style.width=PCTS[n]+'%';}
if(n===4)renderAnalysis();
if(n===5)renderSpecPane();
}
+async function saveProfile(){
+ const name=document.getElementById("pfName").value.trim();
+ const niche=document.getElementById("pfNiche").value.trim();
+ const desc=document.getElementById("pfDesc").value.trim();
+ if(!name&&!desc){alert("Заполните хотя бы имя и описание");return}
+ const btn=document.getElementById("pfSave");btn.disabled=true;btn.innerHTML='
⏳ Елена знакомится...';
+ try{
+ const r=await fetch(`${API}/api/project/profile`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token,client_name:name,niche,description:desc})});
+ const d=await r.json();
+ if(d.error){alert("Ошибка: "+d.error);btn.disabled=false;btn.textContent="Сохранить и начать →";return}
+ // Обновляем состояние и чат
+ const r2=await fetch(`${API}/api/project/${token}`);state=await r2.json();
+ renderAll();go(1);
+ }catch(e){alert("Ошибка: "+e.message);btn.disabled=false}
+}
+
/* ── Voice ── */
let recog=null,recording=false;
const SR=window.SpeechRecognition||window.webkitSpeechRecognition;
@@ -243,10 +279,20 @@ function showTyping(){const t=document.createElement("div");t.className="msg";t.
function hideTyping(){const t=document.getElementById("typing");if(t)t.remove()}
async function init(){
- if(token){const r=await fetch(`${API}/api/project/${token}`);if(r.ok){state=await r.json();renderAll();return}}
+ if(token){const r=await fetch(`${API}/api/project/${token}`);if(r.ok){state=await r.json();renderAll();
+ fillProfile();
+ // Если профиль не заполнен — открыть вкладку Профиль
+ if(!state.description && !state.client_name) go(0); else go(1);
+ return;}}
const r=await fetch(`${API}/api/project/new`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});
const d=await r.json();token=d.token;localStorage.setItem("cab_token",token);
- state={messages:[],client_name:"",niche:""};addMsg("elena",d.greeting);
+ state={messages:[],client_name:"",niche:"",description:""};
+ go(0); // новый клиент → сразу профиль
+}
+function fillProfile(){
+ if(state.client_name)document.getElementById("pfName").value=state.client_name;
+ if(state.niche)document.getElementById("pfNiche").value=state.niche;
+ if(state.description)document.getElementById("pfDesc").value=state.description;
}
function renderAll(){
if(state.client_name)document.getElementById("hdrClient").textContent="· "+state.client_name;