diff --git a/public/js/app.js b/public/js/app.js
index 394d872..3bb91e6 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -31,7 +31,8 @@ const App = {
this.showError('Сессия истекла: ' + e.message);
}
} else {
- this.showError('Откройте BuhApp через бота @buhoiapp_bot');
+ // WebApp открыт вне Telegram — предложим email login
+ this.showEmailLogin();
}
// bind input events for chat
@@ -117,6 +118,68 @@ const App = {
`;
},
+ showEmailLogin() {
+ document.getElementById('app').innerHTML = `
+
+
🍻 BuhApp
+
Приложение для поиска компании (Telegram Mini App)
+
+
+ ⚠️ WebApp лучше открывать через Telegram — там авторизация автоматическая.
+ Здесь можно зайти по email для тестирования.
+
+
+
+
+
+
+
+
+
+ 🍻 BuhApp — приложение для лиц 18+. Встречи и употребление алкоголя — на свой риск.
+ Принимая соглашение, вы подтверждаете совершеннолетие.
+
+
+ `;
+ document.getElementById('el-login').onclick = () => this.emailLogin();
+ document.getElementById('el-register').onclick = () => this.emailRegister();
+ },
+
+ async emailLogin() {
+ const email = document.getElementById('el-email').value.trim();
+ const pass = document.getElementById('el-pass').value;
+ try {
+ await API.Auth.loginEmail(email, pass);
+ await API.Auth.me();
+ await this.checkConsent();
+ this.showView('map');
+ } catch (e) {
+ TG_APP.showAlert('Ошибка: ' + e.message);
+ }
+ },
+
+ async emailRegister() {
+ const email = document.getElementById('el-email').value.trim();
+ const pass = document.getElementById('el-pass').value;
+ if (!email || pass.length < 8) {
+ TG_APP.showAlert('Email и пароль (≥8 символов) обязательны');
+ return;
+ }
+ try {
+ await API.Auth.registerEmail({
+ email,
+ password: pass,
+ name: email.split('@')[0],
+ consents: { adult: true, terms: true, privacy: true, disclaimer: true },
+ });
+ await API.Auth.me();
+ this.consentGiven = true;
+ this.showView('map');
+ } catch (e) {
+ TG_APP.showAlert('Ошибка: ' + e.message);
+ }
+ },
+
showView(name, params = {}) {
document.querySelectorAll('.tab').forEach(t => t.classList.toggle('active', t.dataset.view === name));