fix: remove duplicate showToast declaration causing JavaScript error

Root cause: admin_pricing.html declared 'const showToast' while base.html
already defined 'function showToast', causing SyntaxError that prevented
all JavaScript from executing on the admin pricing page.

Changes:
- Removed duplicate showToast declaration from admin_pricing.html (lines 206-210)
- Removed debug logging added in previous commit
- Kept immediate function calls in base.html to ensure early initialization

This fixes the issue where username and "Администратор цен" link
disappeared when navigating to /admin/pricing.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Mikhail Chusavitin
2026-02-02 14:54:13 +03:00
parent eda0e7cb47
commit e0404186ad
2 changed files with 2 additions and 19 deletions

View File

@@ -203,12 +203,6 @@
</div>
<script>
// Fallback showToast function for cases where base.html isn't loaded properly
const showToast = window.showToast || function(msg, type) {
// Simple fallback: just alert the message
alert(`${type ? type + ': ' : ''}${msg}`);
};
let currentTab = 'alerts';
let currentPage = 1;
let totalPages = 1;

View File

@@ -159,21 +159,17 @@
}
async function checkDbStatus() {
console.log('[DEBUG] checkDbStatus called');
try {
const resp = await fetch('/api/db-status');
const data = await resp.json();
console.log('[DEBUG] checkDbStatus response:', data);
const statusEl = document.getElementById('db-status');
const countsEl = document.getElementById('db-counts');
const userEl = document.getElementById('db-user');
console.log('[DEBUG] userEl:', userEl);
if (data.connected) {
statusEl.innerHTML = '<span class="text-green-400">БД: подключено</span>';
if (data.db_user) {
userEl.innerHTML = '<span class="text-gray-500">@</span>' + data.db_user;
console.log('[DEBUG] username set to:', data.db_user);
}
} else {
statusEl.innerHTML = '<span class="text-red-400">БД: ошибка - ' + data.error + '</span>';
@@ -181,27 +177,20 @@
countsEl.textContent = 'lot: ' + data.lot_count + ' | lot_log: ' + data.lot_log_count + ' | metadata: ' + data.metadata_count;
} catch(e) {
console.error('[DEBUG] checkDbStatus error:', e);
document.getElementById('db-status').innerHTML = '<span class="text-red-400">БД: нет связи</span>';
}
}
async function checkWritePermission() {
console.log('[DEBUG] checkWritePermission called');
try {
const resp = await fetch('/api/pricelists/can-write');
const data = await resp.json();
console.log('[DEBUG] checkWritePermission response:', data);
if (data.can_write) {
const link = document.getElementById('admin-pricing-link');
console.log('[DEBUG] admin-pricing-link element:', link);
if (link) {
link.classList.remove('hidden');
console.log('[DEBUG] admin-pricing-link shown');
}
if (link) link.classList.remove('hidden');
}
} catch(e) {
console.error('[DEBUG] checkWritePermission error:', e);
console.error('Failed to check write permission:', e);
}
}