// Settings view + consent gate + user profile (public) const SettingsView = { async render(root) { const u = API.Store.user; root.innerHTML = `

⚙️ Настройки

${escapeHtml(u?.name || '')}
${u?.telegram_id ? `
Telegram ID: ${u.telegram_id}
` : ''} ${u?.email ? `
${escapeHtml(u.email)}
` : ''}
Юридические документы
Версия 1.0 · 20.08.2026
📄 Пользовательское соглашение 🔒 Политика конфиденциальности ⚠️ Отказ от ответственности
`; document.getElementById('logout').onclick = async () => { const ok = await TG_APP.showConfirm('Выйти из BuhApp?'); if (!ok) return; // очистим cookie на бэкенде (best-effort, без await) try { await fetch('https://api.buhapp.mygoodservice.ru/api/v1/auth/logout', { method: 'POST', credentials: 'include' }); } catch {} App.onLogout(); location.reload(); }; }, }; // Public user profile (включая рейтинг и кнопку "написать") const UserProfileView = { async render(root, params) { const userId = params.userId; const name = params.name || ''; root.innerHTML = '
Загрузка...
'; try { const [profile, stats] = await Promise.all([ API.Auth.getUser(userId), API.ReviewApi.stats(userId), ]); root.innerHTML = `
${profile.photo ? `
` : `
${escapeHtml((profile.name||'?')[0])}
`}
${escapeHtml(profile.name || '')}
${profile.city ? `
📍 ${escapeHtml(profile.city)}
` : ''} ${profile.age ? `
${profile.age} лет
` : ''}
${stats.rating_avg ? stats.rating_avg.toFixed(1) : '—'}
${[1,2,3,4,5].map(n=>``).join('')}
${stats.rating_count || 0} отзывов
${profile.bio ? `
О себе
${escapeHtml(profile.bio)}
` : ''} ${profile.prefs ? this.renderPrefs(profile.prefs) : ''}
`; document.getElementById('up-back').onclick = () => history.back(); document.getElementById('up-chat').onclick = async () => { try { const chat = await API.ChatApi.ensureChat(userId); App.openChat(chat.id, userId, profile.name); } catch (e) { TG_APP.showAlert('Ошибка: ' + e.message); } }; document.getElementById('up-reviews').onclick = () => App.showView('user-reviews', { userId, userName: profile.name }); document.getElementById('up-block').onclick = async () => { const ok = await TG_APP.showConfirm('Заблокировать ' + profile.name + '?'); if (!ok) return; try { await API.ChatApi.block(userId); TG_APP.showAlert('Заблокировано'); history.back(); } catch (e) { TG_APP.showAlert('Ошибка: ' + e.message); } }; document.getElementById('up-report').onclick = async () => { const reason = prompt('Причина жалобы:'); if (!reason) return; try { await API.ChatApi.report('user', userId, reason); TG_APP.showAlert('Жалоба отправлена'); } catch (e) { TG_APP.showAlert('Ошибка: ' + e.message); } }; } catch (e) { root.innerHTML = '
Ошибка: ' + e.message + '
'; } }, renderPrefs(p) { const blocks = []; if (p.drinks?.length) { blocks.push(`
Предпочтения
${p.drinks.map(d => `${escapeHtml(d)}`).join('')}
`); } return blocks.join(''); }, }; window.SettingsView = SettingsView; window.UserProfileView = UserProfileView;