fix: resolve JS-005, JS-006, SVC-006 architecture violations
- JS-005: Add initialization guards to email-templates.js (admin/vendor) - JS-006: Add try/catch error handling to content-pages.js init - SVC-006: Move db.commit() from services to endpoints for proper transaction control in email_template_service and vendor_team_service 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,9 @@ function emailTemplatesPage() {
|
||||
|
||||
// Lifecycle
|
||||
async init() {
|
||||
if (window._adminEmailTemplatesInitialized) return;
|
||||
window._adminEmailTemplatesInitialized = true;
|
||||
|
||||
await this.loadData();
|
||||
},
|
||||
|
||||
|
||||
25
static/vendor/js/content-pages.js
vendored
25
static/vendor/js/content-pages.js
vendored
@@ -36,15 +36,21 @@ function vendorContentPagesManager() {
|
||||
}
|
||||
window._vendorContentPagesInitialized = true;
|
||||
|
||||
// IMPORTANT: Call parent init first to set vendorCode from URL
|
||||
const parentInit = data().init;
|
||||
if (parentInit) {
|
||||
await parentInit.call(this);
|
||||
try {
|
||||
// IMPORTANT: Call parent init first to set vendorCode from URL
|
||||
const parentInit = data().init;
|
||||
if (parentInit) {
|
||||
await parentInit.call(this);
|
||||
}
|
||||
|
||||
await this.loadPages();
|
||||
|
||||
contentPagesLog.info('=== VENDOR CONTENT PAGES MANAGER INITIALIZATION COMPLETE ===');
|
||||
} catch (error) {
|
||||
contentPagesLog.error('Failed to initialize content pages:', error);
|
||||
this.error = 'Failed to initialize. Please refresh the page.';
|
||||
this.loading = false;
|
||||
}
|
||||
|
||||
await this.loadPages();
|
||||
|
||||
contentPagesLog.info('=== VENDOR CONTENT PAGES MANAGER INITIALIZATION COMPLETE ===');
|
||||
},
|
||||
|
||||
// Load all pages
|
||||
@@ -188,7 +194,8 @@ function vendorContentPagesManager() {
|
||||
formatDate(dateStr) {
|
||||
if (!dateStr) return '—';
|
||||
const date = new Date(dateStr);
|
||||
return date.toLocaleDateString('en-GB', {
|
||||
const locale = window.VENDOR_CONFIG?.locale || 'en-GB';
|
||||
return date.toLocaleDateString(locale, {
|
||||
day: '2-digit',
|
||||
month: 'short',
|
||||
year: 'numeric'
|
||||
|
||||
3
static/vendor/js/email-templates.js
vendored
3
static/vendor/js/email-templates.js
vendored
@@ -54,6 +54,9 @@ function vendorEmailTemplates() {
|
||||
|
||||
// Lifecycle
|
||||
async init() {
|
||||
if (window._vendorEmailTemplatesInitialized) return;
|
||||
window._vendorEmailTemplatesInitialized = true;
|
||||
|
||||
vendorEmailTemplatesLog.info('Email templates init() called');
|
||||
|
||||
// Call parent init to set vendorCode and other base state
|
||||
|
||||
Reference in New Issue
Block a user