fix: use centralized logger in email-templates.js (JS-001)

Replace direct console.error calls with centralized logger pattern
in both admin and vendor email templates JavaScript files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-03 19:50:53 +01:00
parent 8e539634aa
commit 87056ea65c
2 changed files with 9 additions and 6 deletions

View File

@@ -7,6 +7,9 @@
* - Preview and test email sending * - Preview and test email sending
*/ */
const emailTemplatesLog = window.LogConfig?.createLogger?.('emailTemplates') ||
{ info: () => {}, debug: () => {}, warn: () => {}, error: () => {} };
function emailTemplatesPage() { function emailTemplatesPage() {
return { return {
// Data // Data
@@ -63,7 +66,7 @@ function emailTemplatesPage() {
this.templates = templatesData.templates || []; this.templates = templatesData.templates || [];
this.categories = categoriesData.categories || []; this.categories = categoriesData.categories || [];
} catch (error) { } catch (error) {
console.error('Failed to load email templates:', error); emailTemplatesLog.error('Failed to load email templates:', error);
Utils.showToast('Failed to load templates', 'error'); Utils.showToast('Failed to load templates', 'error');
} finally { } finally {
this.loading = false; this.loading = false;
@@ -118,7 +121,7 @@ function emailTemplatesPage() {
}; };
Utils.showToast(`No template for ${this.editLanguage.toUpperCase()} - create one by saving`, 'info'); Utils.showToast(`No template for ${this.editLanguage.toUpperCase()} - create one by saving`, 'info');
} else { } else {
console.error('Failed to load template:', error); emailTemplatesLog.error('Failed to load template:', error);
Utils.showToast('Failed to load template', 'error'); Utils.showToast('Failed to load template', 'error');
} }
} finally { } finally {
@@ -156,7 +159,7 @@ function emailTemplatesPage() {
// Refresh templates list // Refresh templates list
await this.loadData(); await this.loadData();
} catch (error) { } catch (error) {
console.error('Failed to save template:', error); emailTemplatesLog.error('Failed to save template:', error);
Utils.showToast(error.detail || 'Failed to save template', 'error'); Utils.showToast(error.detail || 'Failed to save template', 'error');
} finally { } finally {
this.saving = false; this.saving = false;
@@ -181,7 +184,7 @@ function emailTemplatesPage() {
this.previewData = data; this.previewData = data;
this.showPreviewModal = true; this.showPreviewModal = true;
} catch (error) { } catch (error) {
console.error('Failed to preview template:', error); emailTemplatesLog.error('Failed to preview template:', error);
Utils.showToast('Failed to load preview', 'error'); Utils.showToast('Failed to load preview', 'error');
} }
}, },
@@ -251,7 +254,7 @@ function emailTemplatesPage() {
Utils.showToast(result.message || 'Failed to send test email', 'error'); Utils.showToast(result.message || 'Failed to send test email', 'error');
} }
} catch (error) { } catch (error) {
console.error('Failed to send test email:', error); emailTemplatesLog.error('Failed to send test email:', error);
Utils.showToast('Failed to send test email', 'error'); Utils.showToast('Failed to send test email', 'error');
} finally { } finally {
this.sendingTest = false; this.sendingTest = false;

View File

@@ -7,7 +7,7 @@
const vendorEmailTemplatesLog = window.LogConfig?.loggers?.vendorEmailTemplates || const vendorEmailTemplatesLog = window.LogConfig?.loggers?.vendorEmailTemplates ||
window.LogConfig?.createLogger?.('vendorEmailTemplates', false) || window.LogConfig?.createLogger?.('vendorEmailTemplates', false) ||
{ info: () => {}, debug: () => {}, warn: () => {}, error: console.error }; { info: () => {}, debug: () => {}, warn: () => {}, error: () => {} };
vendorEmailTemplatesLog.info('Loading...'); vendorEmailTemplatesLog.info('Loading...');