Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -206,9 +206,10 @@ TEMPLATE = """
|
|
| 206 |
--padding-m: 16px;
|
| 207 |
--font-family: 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
| 208 |
--shadow-color: rgba(255, 193, 7, 0.15);
|
| 209 |
-
--shadow-glow: 0 0 35px var(--shadow-color);
|
| 210 |
}
|
| 211 |
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
|
|
|
|
|
| 212 |
html, body {
|
| 213 |
background-color: var(--tg-theme-bg-color);
|
| 214 |
font-family: var(--font-family);
|
|
@@ -220,82 +221,84 @@ TEMPLATE = """
|
|
| 220 |
visibility: hidden;
|
| 221 |
min-height: 100vh;
|
| 222 |
}
|
| 223 |
-
.container { max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; gap: calc(var(--padding-m) + 4px); }
|
| 224 |
.header { text-align: left; padding: 8px 0; }
|
| 225 |
.logo { font-size: 2.5em; font-weight: 800; letter-spacing: -1px; }
|
| 226 |
.logo span { color: var(--tg-theme-button-color); }
|
| 227 |
-
.welcome-text { font-size:
|
| 228 |
.nav-buttons {
|
| 229 |
-
display:
|
|
|
|
| 230 |
border-radius: 50px; padding: 6px; position: sticky; top: var(--padding-m); z-index: 100;
|
| 231 |
backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
|
|
|
|
| 232 |
}
|
| 233 |
.nav-btn {
|
| 234 |
-
|
| 235 |
background-color: transparent; color: var(--tg-theme-hint-color);
|
| 236 |
font-family: var(--font-family); font-weight: 700; font-size: 1em;
|
| 237 |
-
cursor: pointer; transition: all 0.3s
|
| 238 |
}
|
| 239 |
.nav-btn.active { background-color: var(--tg-theme-button-color); color: var(--tg-theme-button-text-color); box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
|
| 240 |
.content-section { display: none; flex-direction: column; gap: calc(var(--padding-m) + 4px); }
|
| 241 |
.content-section.active { display: flex; }
|
| 242 |
-
.
|
| 243 |
-
background: linear-gradient(
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
box-shadow: 0 10px 30px rgba(0,0,0,0.
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
.main-bonus-card .bonus-amount { font-size: 3.5em; font-weight: 800; letter-spacing: -2px; line-height: 1; }
|
| 250 |
-
.balances-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--padding-m); }
|
| 251 |
-
.balance-card {
|
| 252 |
-
background-color: var(--tg-theme-secondary-bg-color);
|
| 253 |
-
border-radius: var(--border-radius-m); padding: 20px; text-align: center;
|
| 254 |
}
|
| 255 |
-
.balance-
|
| 256 |
-
.balance-
|
| 257 |
-
.balance-
|
| 258 |
-
.
|
| 259 |
-
.
|
| 260 |
-
|
| 261 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
}
|
| 263 |
.promo-card .card-label { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 1em; font-weight: 500; color: var(--tg-theme-hint-color); margin-bottom: 12px; }
|
| 264 |
-
.promo-info-icon { cursor: pointer; position: relative; }
|
| 265 |
.promo-info-icon .tooltip {
|
| 266 |
-
visibility: hidden; opacity: 0; position: absolute; bottom:
|
| 267 |
transform: translateX(-50%); background-color: #333; color: #fff; text-align: left;
|
| 268 |
-
border-radius: 8px; padding: 12px; z-index:
|
| 269 |
font-size: 0.9em; font-weight: 400; line-height: 1.4;
|
| 270 |
box-shadow: 0 4px 10px rgba(0,0,0,0.3); transition: opacity 0.2s, visibility 0.2s;
|
| 271 |
}
|
| 272 |
.promo-info-icon:hover .tooltip { visibility: visible; opacity: 1; }
|
| 273 |
-
.promo-code-display {
|
| 274 |
-
|
| 275 |
-
|
|
|
|
|
|
|
| 276 |
}
|
| 277 |
-
.promo-code-value { font-size: 1.5em; font-weight: 700; color: var(--tg-theme-button-color); letter-spacing: 2px; }
|
| 278 |
.copy-btn {
|
| 279 |
-
padding:
|
| 280 |
-
background-color: var(--tg-theme-button-color); border: none; border-radius: 10px; cursor: pointer;
|
| 281 |
-
transition:
|
| 282 |
}
|
| 283 |
.copy-btn:active { transform: scale(0.95); }
|
|
|
|
| 284 |
.client-id-card { display: flex; justify-content: space-between; align-items: center; }
|
| 285 |
.client-id-label { font-weight: 500; color: var(--tg-theme-hint-color); }
|
| 286 |
-
.client-id-value {
|
| 287 |
-
font-size: 1.3em; font-weight: 700; color: var(--tg-theme-button-color); letter-spacing: 2px;
|
| 288 |
-
background-color: rgba(0,0,0,0.2); padding: 6px 12px; border-radius: 10px;
|
| 289 |
-
}
|
| 290 |
-
.section-card { background-color: var(--tg-theme-secondary-bg-color); border-radius: var(--border-radius-m); padding: 20px; }
|
| 291 |
.section-title { font-size: 1.4em; font-weight: 700; margin-bottom: 16px; }
|
| 292 |
.history-list, .invoices-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
|
| 293 |
.history-item, .invoice-item {
|
| 294 |
display: flex; align-items: center; padding: 14px;
|
| 295 |
-
border-bottom: 1px solid rgba(255, 255, 255, 0.
|
| 296 |
}
|
| 297 |
.history-item:last-child, .invoice-item:last-child { border-bottom: none; }
|
| 298 |
-
.history-
|
|
|
|
| 299 |
.history-icon svg { width: 22px; height: 22px; }
|
| 300 |
.icon-bonus-accrual { background-color: rgba(76, 175, 80, 0.15); color: var(--brand-green); }
|
| 301 |
.icon-bonus-deduction { background-color: rgba(244, 67, 54, 0.15); color: var(--brand-red); }
|
|
@@ -309,21 +312,20 @@ TEMPLATE = """
|
|
| 309 |
.history-amount.positive { color: var(--brand-green); }
|
| 310 |
.history-amount.negative { color: var(--brand-red); }
|
| 311 |
.history-amount.referral { color: var(--brand-blue); }
|
| 312 |
-
.invoice-item { cursor: pointer;
|
| 313 |
-
.invoice-item:hover { background-color: rgba(255,255,255,0.05); }
|
| 314 |
.invoice-details { flex-grow: 1; }
|
| 315 |
.invoice-description, .invoice-date { margin-left: 16px; }
|
| 316 |
.invoice-amount { font-size: 1.1em; font-weight: 700; color: var(--tg-theme-button-color); }
|
| 317 |
-
.no-data { text-align: center; color: var(--tg-theme-hint-color); padding: 3rem 0; }
|
| 318 |
-
.business-card-item { margin-bottom:
|
| 319 |
-
.business-card-label { font-weight: 500; color: var(--tg-theme-hint-color); margin-bottom:
|
| 320 |
.business-card-value { font-size: 1.1em; font-weight: 600; }
|
| 321 |
.business-card-value a { color: var(--tg-theme-button-color); text-decoration: none; word-break: break-all; transition: opacity 0.2s; }
|
| 322 |
.business-card-value a:hover { opacity: 0.8; }
|
| 323 |
-
.business-card-phone-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap:
|
| 324 |
.business-card-phone-item a {
|
| 325 |
-
display: inline-flex; align-items: center; gap:
|
| 326 |
-
text-decoration: none; background-color: rgba(255,255,255,0.08); padding:
|
| 327 |
border-radius: 12px; transition: background-color 0.2s;
|
| 328 |
}
|
| 329 |
.business-card-phone-item a:hover { background-color: rgba(255,255,255,0.12); }
|
|
@@ -338,7 +340,6 @@ TEMPLATE = """
|
|
| 338 |
box-shadow: 0 -5px 25px rgba(0,0,0,0.3); padding: var(--padding-m); padding-top: 40px; position: relative;
|
| 339 |
max-height: 90vh; overflow-y: auto; animation: slideUp 0.3s ease-out;
|
| 340 |
}
|
| 341 |
-
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
|
| 342 |
.modal-close {
|
| 343 |
position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
|
| 344 |
width: 40px; height: 5px; background-color: var(--tg-theme-hint-color);
|
|
@@ -361,7 +362,7 @@ TEMPLATE = """
|
|
| 361 |
.total-row .deduction { color: var(--brand-red); }
|
| 362 |
#promoCodeModal .modal-content { align-items: center; text-align: center; padding: 40px 24px 24px; }
|
| 363 |
#promoCodeModal h2 { margin-bottom: 12px; }
|
| 364 |
-
#promoCodeModal p { color: var(--tg-theme-hint-color); margin-bottom: 20px; }
|
| 365 |
#promoCodeModal input {
|
| 366 |
width: 100%; padding: 16px; margin-bottom: 16px; font-size: 1.2em;
|
| 367 |
background-color: var(--tg-theme-bg-color); border: 1px solid rgba(255,255,255,0.1);
|
|
@@ -390,21 +391,23 @@ TEMPLATE = """
|
|
| 390 |
<button class="nav-btn" data-target="business-card-section">Визитка</button>
|
| 391 |
</nav>
|
| 392 |
<div id="dashboard-section" class="content-section active">
|
| 393 |
-
<section class="
|
| 394 |
-
<
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
<section class="balances-grid">
|
| 398 |
-
<div class="balance-card">
|
| 399 |
-
<p class="card-label">Ваш долг</p>
|
| 400 |
-
<p class="amount debt">{{ "%.2f"|format(user.debts|float) }}</p>
|
| 401 |
</div>
|
| 402 |
-
<div class="
|
| 403 |
-
<
|
| 404 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 405 |
</div>
|
| 406 |
</section>
|
| 407 |
-
<section class="promo-card">
|
| 408 |
<p class="card-label">
|
| 409 |
Ваш промокод для друзей
|
| 410 |
<span class="promo-info-icon">
|
|
@@ -414,22 +417,26 @@ TEMPLATE = """
|
|
| 414 |
</p>
|
| 415 |
<div class="promo-code-display">
|
| 416 |
<span class="promo-code-value" id="userPromoCode">{{ user.referral_code }}</span>
|
| 417 |
-
<button class="copy-btn" onclick="copyPromoCode()"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 418 |
</div>
|
| 419 |
</section>
|
| 420 |
-
<section class="client-id-card">
|
| 421 |
<p class="client-id-label">Ваш ID клиента</p>
|
| 422 |
<p class="client-id-value">{{ user.id }}</p>
|
| 423 |
</section>
|
| 424 |
-
<section class="section-card">
|
| 425 |
<h2 class="section-title">История операций</h2>
|
| 426 |
{% if user.combined_history %}
|
| 427 |
<ul class="history-list">
|
| 428 |
-
{% for item in user.combined_history %}
|
| 429 |
<li class="history-item">
|
| 430 |
{% if item.transaction_type == 'bonus' %}
|
| 431 |
<div class="history-icon {{ 'icon-bonus-accrual' if item.type == 'accrual' else 'icon-bonus-deduction' }}">
|
| 432 |
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12
|
| 433 |
</div>
|
| 434 |
<div class="history-details">
|
| 435 |
<span class="history-description">{{ item.description }}</span>
|
|
@@ -476,7 +483,7 @@ TEMPLATE = """
|
|
| 476 |
<ul class="invoices-list">
|
| 477 |
{% for invoice in user.invoices|sort(attribute='date', reverse=true) %}
|
| 478 |
<li class="invoice-item" onclick='openInvoiceDetailModal({{ invoice|tojson }})'>
|
| 479 |
-
<div class="history-icon
|
| 480 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"/></svg>
|
| 481 |
</div>
|
| 482 |
<div class="invoice-details">
|
|
@@ -570,6 +577,7 @@ TEMPLATE = """
|
|
| 570 |
<script>
|
| 571 |
const tg = window.Telegram.WebApp;
|
| 572 |
const currentUserId = '{{ user.id }}';
|
|
|
|
| 573 |
|
| 574 |
function applyTheme(themeParams) {
|
| 575 |
if (!themeParams) return;
|
|
@@ -592,9 +600,13 @@ TEMPLATE = """
|
|
| 592 |
|
| 593 |
tg.ready();
|
| 594 |
tg.expand();
|
|
|
|
| 595 |
|
| 596 |
applyTheme(tg.themeParams);
|
| 597 |
-
tg.onEvent('themeChanged', () =>
|
|
|
|
|
|
|
|
|
|
| 598 |
|
| 599 |
const urlParams = new URLSearchParams(window.location.search);
|
| 600 |
const userIdForTest = urlParams.get('user_id_for_test');
|
|
@@ -676,16 +688,30 @@ TEMPLATE = """
|
|
| 676 |
openModal('invoiceDetailModal');
|
| 677 |
}
|
| 678 |
|
| 679 |
-
function copyPromoCode() {
|
| 680 |
const promoCode = document.getElementById('userPromoCode').textContent;
|
| 681 |
-
const copyBtn = document.querySelector('.copy-btn');
|
| 682 |
navigator.clipboard.writeText(promoCode).then(() => {
|
| 683 |
-
|
| 684 |
-
|
|
|
|
|
|
|
| 685 |
}).catch(err => {
|
| 686 |
console.error('Failed to copy text: ', err);
|
| 687 |
});
|
| 688 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 689 |
|
| 690 |
async function submitPromoCode(withCode) {
|
| 691 |
const promoCode = withCode ? document.getElementById('promoCodeInput').value.trim() : null;
|
|
@@ -718,6 +744,11 @@ TEMPLATE = """
|
|
| 718 |
button.addEventListener('click', () => showSection(button.dataset.target));
|
| 719 |
});
|
| 720 |
showSection('dashboard-section');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 721 |
});
|
| 722 |
|
| 723 |
if (window.Telegram && window.Telegram.WebApp) {
|
|
@@ -1847,7 +1878,8 @@ def add_invoice():
|
|
| 1847 |
|
| 1848 |
bonus_settings = visitor_data_cache.get('bonus_program_settings', {})
|
| 1849 |
invoice_bonus_percentage = float(bonus_settings.get('invoice_bonus_percentage', 0))
|
| 1850 |
-
|
|
|
|
| 1851 |
bonus_from_invoice = round((total_amount * invoice_bonus_percentage) / 100, 2)
|
| 1852 |
if bonus_from_invoice > 0:
|
| 1853 |
user['bonuses'] = user.get('bonuses', 0) + bonus_from_invoice
|
|
@@ -1998,4 +2030,4 @@ if __name__ == '__main__':
|
|
| 1998 |
print("WARNING: HF_TOKEN_WRITE not set. Periodic backups to Hugging Face are disabled.")
|
| 1999 |
|
| 2000 |
print("--- Server Ready ---")
|
| 2001 |
-
app.run(host=HOST, port=PORT, debug=False)
|
|
|
|
| 206 |
--padding-m: 16px;
|
| 207 |
--font-family: 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
| 208 |
--shadow-color: rgba(255, 193, 7, 0.15);
|
|
|
|
| 209 |
}
|
| 210 |
* { box-sizing: border-box; margin: 0; padding: 0; }
|
| 211 |
+
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
|
| 212 |
+
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
|
| 213 |
html, body {
|
| 214 |
background-color: var(--tg-theme-bg-color);
|
| 215 |
font-family: var(--font-family);
|
|
|
|
| 221 |
visibility: hidden;
|
| 222 |
min-height: 100vh;
|
| 223 |
}
|
| 224 |
+
.container { max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; gap: calc(var(--padding-m) + 4px); animation: fadeIn 0.5s ease-out forwards; }
|
| 225 |
.header { text-align: left; padding: 8px 0; }
|
| 226 |
.logo { font-size: 2.5em; font-weight: 800; letter-spacing: -1px; }
|
| 227 |
.logo span { color: var(--tg-theme-button-color); }
|
| 228 |
+
.welcome-text { font-size: 1.05em; color: var(--tg-theme-hint-color); margin-top: 4px; }
|
| 229 |
.nav-buttons {
|
| 230 |
+
display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
|
| 231 |
+
background-color: var(--tg-theme-secondary-bg-color);
|
| 232 |
border-radius: 50px; padding: 6px; position: sticky; top: var(--padding-m); z-index: 100;
|
| 233 |
backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
|
| 234 |
+
box-shadow: 0 5px 20px rgba(0,0,0,0.2);
|
| 235 |
}
|
| 236 |
.nav-btn {
|
| 237 |
+
padding: 12px 15px; border: none; border-radius: 50px;
|
| 238 |
background-color: transparent; color: var(--tg-theme-hint-color);
|
| 239 |
font-family: var(--font-family); font-weight: 700; font-size: 1em;
|
| 240 |
+
cursor: pointer; transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
|
| 241 |
}
|
| 242 |
.nav-btn.active { background-color: var(--tg-theme-button-color); color: var(--tg-theme-button-text-color); box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
|
| 243 |
.content-section { display: none; flex-direction: column; gap: calc(var(--padding-m) + 4px); }
|
| 244 |
.content-section.active { display: flex; }
|
| 245 |
+
.financial-summary-card {
|
| 246 |
+
background: linear-gradient(135deg, var(--tg-secondary-bg-color) 0%, #3a3a3c 100%);
|
| 247 |
+
border-radius: var(--border-radius-l);
|
| 248 |
+
padding: 24px;
|
| 249 |
+
box-shadow: 0 10px 30px rgba(0,0,0,0.25);
|
| 250 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 251 |
+
animation: slideUp 0.6s ease-out forwards;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
}
|
| 253 |
+
.main-balance-section { text-align: center; border-bottom: 1px solid rgba(255, 255, 255, 0.1); padding-bottom: 20px; margin-bottom: 20px; }
|
| 254 |
+
.main-balance-section .card-label { font-size: 1.2em; font-weight: 600; color: var(--tg-theme-hint-color); margin-bottom: 8px; }
|
| 255 |
+
.main-balance-section .bonus-amount { font-size: 4em; font-weight: 800; letter-spacing: -2px; line-height: 1; color: var(--tg-theme-button-color); }
|
| 256 |
+
.sub-balances-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--padding-m); }
|
| 257 |
+
.sub-balance-item { text-align: center; }
|
| 258 |
+
.sub-balance-item .card-label { font-size: 1em; font-weight: 500; color: var(--tg-theme-hint-color); margin-bottom: 8px; }
|
| 259 |
+
.sub-balance-item .amount { font-size: 1.8em; font-weight: 700; }
|
| 260 |
+
.sub-balance-item .amount.debt { color: var(--brand-red); }
|
| 261 |
+
.sub-balance-item .amount.referral { color: var(--brand-blue); }
|
| 262 |
+
.animated-card { animation: slideUp 0.6s ease-out 0.2s forwards; opacity: 0; }
|
| 263 |
+
.section-card {
|
| 264 |
+
background-color: var(--tg-theme-secondary-bg-color); border-radius: var(--border-radius-m);
|
| 265 |
+
padding: 20px; border: 1px solid rgba(255, 255, 255, 0.05);
|
| 266 |
}
|
| 267 |
.promo-card .card-label { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 1em; font-weight: 500; color: var(--tg-theme-hint-color); margin-bottom: 12px; }
|
| 268 |
+
.promo-info-icon { cursor: pointer; position: relative; display: flex; align-items: center; }
|
| 269 |
.promo-info-icon .tooltip {
|
| 270 |
+
visibility: hidden; opacity: 0; position: absolute; bottom: 140%; left: 50%;
|
| 271 |
transform: translateX(-50%); background-color: #333; color: #fff; text-align: left;
|
| 272 |
+
border-radius: 8px; padding: 12px; z-index: 10; width: 280px;
|
| 273 |
font-size: 0.9em; font-weight: 400; line-height: 1.4;
|
| 274 |
box-shadow: 0 4px 10px rgba(0,0,0,0.3); transition: opacity 0.2s, visibility 0.2s;
|
| 275 |
}
|
| 276 |
.promo-info-icon:hover .tooltip { visibility: visible; opacity: 1; }
|
| 277 |
+
.promo-code-display { display: flex; align-items: stretch; justify-content: center; gap: 2px; }
|
| 278 |
+
.promo-code-value {
|
| 279 |
+
font-size: 1.5em; font-weight: 700; color: var(--tg-theme-button-color); letter-spacing: 2px;
|
| 280 |
+
background-color: rgba(0,0,0,0.2); padding: 12px 18px;
|
| 281 |
+
border-radius: 10px 0 0 10px; flex-grow: 1; text-align: center;
|
| 282 |
}
|
|
|
|
| 283 |
.copy-btn {
|
| 284 |
+
padding: 0 18px; color: var(--tg-theme-button-text-color);
|
| 285 |
+
background-color: var(--tg-theme-button-color); border: none; border-radius: 0 10px 10px 0; cursor: pointer;
|
| 286 |
+
transition: all 0.2s ease; display: flex; align-items: center; justify-content: center;
|
| 287 |
}
|
| 288 |
.copy-btn:active { transform: scale(0.95); }
|
| 289 |
+
.copy-btn .icon { width: 22px; height: 22px; }
|
| 290 |
.client-id-card { display: flex; justify-content: space-between; align-items: center; }
|
| 291 |
.client-id-label { font-weight: 500; color: var(--tg-theme-hint-color); }
|
| 292 |
+
.client-id-value { font-size: 1.3em; font-weight: 700; }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
.section-title { font-size: 1.4em; font-weight: 700; margin-bottom: 16px; }
|
| 294 |
.history-list, .invoices-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
|
| 295 |
.history-item, .invoice-item {
|
| 296 |
display: flex; align-items: center; padding: 14px;
|
| 297 |
+
border-bottom: 1px solid rgba(255, 255, 255, 0.08); transition: background-color 0.2s ease; border-radius: 12px;
|
| 298 |
}
|
| 299 |
.history-item:last-child, .invoice-item:last-child { border-bottom: none; }
|
| 300 |
+
.history-item:hover, .invoice-item:hover { background-color: rgba(255,255,255,0.05); }
|
| 301 |
+
.history-icon { margin-right: 16px; width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
|
| 302 |
.history-icon svg { width: 22px; height: 22px; }
|
| 303 |
.icon-bonus-accrual { background-color: rgba(76, 175, 80, 0.15); color: var(--brand-green); }
|
| 304 |
.icon-bonus-deduction { background-color: rgba(244, 67, 54, 0.15); color: var(--brand-red); }
|
|
|
|
| 312 |
.history-amount.positive { color: var(--brand-green); }
|
| 313 |
.history-amount.negative { color: var(--brand-red); }
|
| 314 |
.history-amount.referral { color: var(--brand-blue); }
|
| 315 |
+
.invoice-item { cursor: pointer; }
|
|
|
|
| 316 |
.invoice-details { flex-grow: 1; }
|
| 317 |
.invoice-description, .invoice-date { margin-left: 16px; }
|
| 318 |
.invoice-amount { font-size: 1.1em; font-weight: 700; color: var(--tg-theme-button-color); }
|
| 319 |
+
.no-data { text-align: center; color: var(--tg-theme-hint-color); padding: 3rem 0; font-size: 1.1em; }
|
| 320 |
+
.business-card-item { margin-bottom: 20px; }
|
| 321 |
+
.business-card-label { font-weight: 500; color: var(--tg-theme-hint-color); margin-bottom: 8px; font-size: 0.9em; }
|
| 322 |
.business-card-value { font-size: 1.1em; font-weight: 600; }
|
| 323 |
.business-card-value a { color: var(--tg-theme-button-color); text-decoration: none; word-break: break-all; transition: opacity 0.2s; }
|
| 324 |
.business-card-value a:hover { opacity: 0.8; }
|
| 325 |
+
.business-card-phone-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
|
| 326 |
.business-card-phone-item a {
|
| 327 |
+
display: inline-flex; align-items: center; gap: 12px; color: var(--tg-theme-text-color);
|
| 328 |
+
text-decoration: none; background-color: rgba(255,255,255,0.08); padding: 12px 16px;
|
| 329 |
border-radius: 12px; transition: background-color 0.2s;
|
| 330 |
}
|
| 331 |
.business-card-phone-item a:hover { background-color: rgba(255,255,255,0.12); }
|
|
|
|
| 340 |
box-shadow: 0 -5px 25px rgba(0,0,0,0.3); padding: var(--padding-m); padding-top: 40px; position: relative;
|
| 341 |
max-height: 90vh; overflow-y: auto; animation: slideUp 0.3s ease-out;
|
| 342 |
}
|
|
|
|
| 343 |
.modal-close {
|
| 344 |
position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
|
| 345 |
width: 40px; height: 5px; background-color: var(--tg-theme-hint-color);
|
|
|
|
| 362 |
.total-row .deduction { color: var(--brand-red); }
|
| 363 |
#promoCodeModal .modal-content { align-items: center; text-align: center; padding: 40px 24px 24px; }
|
| 364 |
#promoCodeModal h2 { margin-bottom: 12px; }
|
| 365 |
+
#promoCodeModal p { color: var(--tg-theme-hint-color); margin-bottom: 20px; max-width: 300px; }
|
| 366 |
#promoCodeModal input {
|
| 367 |
width: 100%; padding: 16px; margin-bottom: 16px; font-size: 1.2em;
|
| 368 |
background-color: var(--tg-theme-bg-color); border: 1px solid rgba(255,255,255,0.1);
|
|
|
|
| 391 |
<button class="nav-btn" data-target="business-card-section">Визитка</button>
|
| 392 |
</nav>
|
| 393 |
<div id="dashboard-section" class="content-section active">
|
| 394 |
+
<section class="financial-summary-card">
|
| 395 |
+
<div class="main-balance-section">
|
| 396 |
+
<p class="card-label">Ваши бонусы</p>
|
| 397 |
+
<p class="bonus-amount" id="bonus-amount-display">0.00</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 398 |
</div>
|
| 399 |
+
<div class="sub-balances-grid">
|
| 400 |
+
<div class="sub-balance-item">
|
| 401 |
+
<p class="card-label">Ваш долг</p>
|
| 402 |
+
<p class="amount debt">{{ "%.2f"|format(user.debts|float) }}</p>
|
| 403 |
+
</div>
|
| 404 |
+
<div class="sub-balance-item">
|
| 405 |
+
<p class="card-label">Бонусы с друзей</p>
|
| 406 |
+
<p class="amount referral">{{ "%.2f"|format(user.referral_bonuses|float) }}</p>
|
| 407 |
+
</div>
|
| 408 |
</div>
|
| 409 |
</section>
|
| 410 |
+
<section class="section-card promo-card animated-card">
|
| 411 |
<p class="card-label">
|
| 412 |
Ваш промокод для друзей
|
| 413 |
<span class="promo-info-icon">
|
|
|
|
| 417 |
</p>
|
| 418 |
<div class="promo-code-display">
|
| 419 |
<span class="promo-code-value" id="userPromoCode">{{ user.referral_code }}</span>
|
| 420 |
+
<button class="copy-btn" onclick="copyPromoCode(this)">
|
| 421 |
+
<span id="copy-icon-wrapper">
|
| 422 |
+
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>
|
| 423 |
+
</span>
|
| 424 |
+
</button>
|
| 425 |
</div>
|
| 426 |
</section>
|
| 427 |
+
<section class="section-card client-id-card animated-card">
|
| 428 |
<p class="client-id-label">Ваш ID клиента</p>
|
| 429 |
<p class="client-id-value">{{ user.id }}</p>
|
| 430 |
</section>
|
| 431 |
+
<section class="section-card animated-card">
|
| 432 |
<h2 class="section-title">История операций</h2>
|
| 433 |
{% if user.combined_history %}
|
| 434 |
<ul class="history-list">
|
| 435 |
+
{% for item in user.combined_history[:10] %}
|
| 436 |
<li class="history-item">
|
| 437 |
{% if item.transaction_type == 'bonus' %}
|
| 438 |
<div class="history-icon {{ 'icon-bonus-accrual' if item.type == 'accrual' else 'icon-bonus-deduction' }}">
|
| 439 |
+
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" viewBox="0 0 24 24" fill="currentColor"><g><rect fill="none" height="24" width="24"/></g><g><path d="M12,2C6.48,2,2,6.48,2,12s4.48,10,10,10s10-4.48,10-10S17.52,2,12,2z M17,13h-4v4h-2v-4H7v-2h4V7h2v4h4V13z"/></g></svg>
|
| 440 |
</div>
|
| 441 |
<div class="history-details">
|
| 442 |
<span class="history-description">{{ item.description }}</span>
|
|
|
|
| 483 |
<ul class="invoices-list">
|
| 484 |
{% for invoice in user.invoices|sort(attribute='date', reverse=true) %}
|
| 485 |
<li class="invoice-item" onclick='openInvoiceDetailModal({{ invoice|tojson }})'>
|
| 486 |
+
<div class="history-icon" style="background-color: rgba(255, 193, 7, 0.15); color: var(--tg-theme-button-color);">
|
| 487 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"/></svg>
|
| 488 |
</div>
|
| 489 |
<div class="invoice-details">
|
|
|
|
| 577 |
<script>
|
| 578 |
const tg = window.Telegram.WebApp;
|
| 579 |
const currentUserId = '{{ user.id }}';
|
| 580 |
+
const initialBonusAmount = parseFloat('{{ user.bonuses|float }}');
|
| 581 |
|
| 582 |
function applyTheme(themeParams) {
|
| 583 |
if (!themeParams) return;
|
|
|
|
| 600 |
|
| 601 |
tg.ready();
|
| 602 |
tg.expand();
|
| 603 |
+
tg.setHeaderColor(tg.themeParams.secondary_bg_color || '#2c2c2e');
|
| 604 |
|
| 605 |
applyTheme(tg.themeParams);
|
| 606 |
+
tg.onEvent('themeChanged', () => {
|
| 607 |
+
applyTheme(tg.themeParams);
|
| 608 |
+
tg.setHeaderColor(tg.themeParams.secondary_bg_color || '#2c2c2e');
|
| 609 |
+
});
|
| 610 |
|
| 611 |
const urlParams = new URLSearchParams(window.location.search);
|
| 612 |
const userIdForTest = urlParams.get('user_id_for_test');
|
|
|
|
| 688 |
openModal('invoiceDetailModal');
|
| 689 |
}
|
| 690 |
|
| 691 |
+
function copyPromoCode(button) {
|
| 692 |
const promoCode = document.getElementById('userPromoCode').textContent;
|
|
|
|
| 693 |
navigator.clipboard.writeText(promoCode).then(() => {
|
| 694 |
+
const iconWrapper = document.getElementById('copy-icon-wrapper');
|
| 695 |
+
const originalIcon = iconWrapper.innerHTML;
|
| 696 |
+
iconWrapper.innerHTML = `<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="var(--brand-green)"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"/></svg>`;
|
| 697 |
+
setTimeout(() => { iconWrapper.innerHTML = originalIcon; }, 2000);
|
| 698 |
}).catch(err => {
|
| 699 |
console.error('Failed to copy text: ', err);
|
| 700 |
});
|
| 701 |
}
|
| 702 |
+
|
| 703 |
+
function animateValue(obj, start, end, duration) {
|
| 704 |
+
let startTimestamp = null;
|
| 705 |
+
const step = (timestamp) => {
|
| 706 |
+
if (!startTimestamp) startTimestamp = timestamp;
|
| 707 |
+
const progress = Math.min((timestamp - startTimestamp) / duration, 1);
|
| 708 |
+
obj.innerHTML = parseFloat(progress * (end - start) + start).toFixed(2);
|
| 709 |
+
if (progress < 1) {
|
| 710 |
+
window.requestAnimationFrame(step);
|
| 711 |
+
}
|
| 712 |
+
};
|
| 713 |
+
window.requestAnimationFrame(step);
|
| 714 |
+
}
|
| 715 |
|
| 716 |
async function submitPromoCode(withCode) {
|
| 717 |
const promoCode = withCode ? document.getElementById('promoCodeInput').value.trim() : null;
|
|
|
|
| 744 |
button.addEventListener('click', () => showSection(button.dataset.target));
|
| 745 |
});
|
| 746 |
showSection('dashboard-section');
|
| 747 |
+
|
| 748 |
+
const bonusAmountEl = document.getElementById('bonus-amount-display');
|
| 749 |
+
if (bonusAmountEl) {
|
| 750 |
+
animateValue(bonusAmountEl, 0, initialBonusAmount, 1000);
|
| 751 |
+
}
|
| 752 |
});
|
| 753 |
|
| 754 |
if (window.Telegram && window.Telegram.WebApp) {
|
|
|
|
| 1878 |
|
| 1879 |
bonus_settings = visitor_data_cache.get('bonus_program_settings', {})
|
| 1880 |
invoice_bonus_percentage = float(bonus_settings.get('invoice_bonus_percentage', 0))
|
| 1881 |
+
|
| 1882 |
+
if deduct_bonuses <= 0 and invoice_bonus_percentage > 0 and total_amount > 0:
|
| 1883 |
bonus_from_invoice = round((total_amount * invoice_bonus_percentage) / 100, 2)
|
| 1884 |
if bonus_from_invoice > 0:
|
| 1885 |
user['bonuses'] = user.get('bonuses', 0) + bonus_from_invoice
|
|
|
|
| 2030 |
print("WARNING: HF_TOKEN_WRITE not set. Periodic backups to Hugging Face are disabled.")
|
| 2031 |
|
| 2032 |
print("--- Server Ready ---")
|
| 2033 |
+
app.run(host=HOST, port=PORT, debug=False)
|