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