fix(ui): inject window.FRONTEND_TYPE from server + rename SHOP→STOREFRONT

Server now injects window.FRONTEND_TYPE in all base templates via
get_context_for_frontend(). Both log-config.js and dev-toolbar.js read
this instead of guessing from URL paths, fixing:
- UNKNOWN prefix on merchant pages
- Incorrect detection on custom domains/subdomains in prod

Also adds frontend_type to login page contexts (admin, merchant, store).

Renames all [SHOP] logger prefixes to [STOREFRONT] across 7 files
(storefront-layout.js + 6 storefront templates).

Adds 'merchant' and 'storefront' to log-config.js frontend detection,
log levels, and logger selection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-28 21:08:59 +01:00
parent 9bceeaac9c
commit b4f01210d9
16 changed files with 99 additions and 79 deletions

View File

@@ -62,6 +62,7 @@ async def admin_login_page(
context = {
"request": request,
"current_language": language,
"frontend_type": "admin",
**get_jinja2_globals(language),
}
return templates.TemplateResponse("tenancy/admin/login.html", context)

View File

@@ -72,6 +72,7 @@ async def merchant_login_page(
context = {
"request": request,
"current_language": language,
"frontend_type": "merchant",
**get_jinja2_globals(language),
}
return templates.TemplateResponse("tenancy/merchant/login.html", context)

View File

@@ -5,11 +5,11 @@
* Works with store-specific themes
*/
const shopLog = {
info: (...args) => console.info('🛒 [SHOP]', ...args),
warn: (...args) => console.warn('⚠️ [SHOP]', ...args),
error: (...args) => console.error('❌ [SHOP]', ...args),
debug: (...args) => console.log('🔍 [SHOP]', ...args)
const shopLog = window.LogConfig?.createLogger('STOREFRONT') || {
info: (...args) => console.info('🛒 [STOREFRONT]', ...args),
warn: (...args) => console.warn('⚠️ [STOREFRONT]', ...args),
error: (...args) => console.error('❌ [STOREFRONT]', ...args),
debug: (...args) => console.log('🔍 [STOREFRONT]', ...args)
};
/**

View File

@@ -149,6 +149,9 @@ def get_context_for_frontend(
# Pass enabled module codes to templates for conditional rendering
context["enabled_modules"] = enabled_module_codes
# Pass frontend type to templates (used by JS for logging, dev toolbar, etc.)
context["frontend_type"] = frontend_type.value
# For storefront, build nav menu structure from module declarations
if frontend_type == FrontendType.STOREFRONT:
from app.modules.core.services.menu_discovery_service import (