diff --git a/static/admin/js/company-edit.js b/static/admin/js/company-edit.js index 5fa03614..75437983 100644 --- a/static/admin/js/company-edit.js +++ b/static/admin/js/company-edit.js @@ -1,4 +1,3 @@ -// noqa: js-006 - async init pattern is safe, loadData has try/catch // static/admin/js/company-edit.js // Create custom logger for company edit @@ -11,6 +10,7 @@ function adminCompanyEdit() { // Company edit page specific state currentPage: 'company-edit', + loading: false, company: null, formData: {}, errors: {}, @@ -48,21 +48,26 @@ function adminCompanyEdit() { } window._companyEditInitialized = true; - // Get company ID from URL - const path = window.location.pathname; - const match = path.match(/\/admin\/companies\/(\d+)\/edit/); + try { + // Get company ID from URL + const path = window.location.pathname; + const match = path.match(/\/admin\/companies\/(\d+)\/edit/); - if (match) { - this.companyId = parseInt(match[1], 10); - companyEditLog.info('Editing company:', this.companyId); - await this.loadCompany(); - } else { - companyEditLog.error('No company ID in URL'); - Utils.showToast('Invalid company URL', 'error'); - setTimeout(() => window.location.href = '/admin/companies', 2000); + if (match) { + this.companyId = parseInt(match[1], 10); + companyEditLog.info('Editing company:', this.companyId); + await this.loadCompany(); + } else { + companyEditLog.error('No company ID in URL'); + Utils.showToast('Invalid company URL', 'error'); + setTimeout(() => window.location.href = '/admin/companies', 2000); + } + + companyEditLog.info('=== COMPANY EDIT PAGE INITIALIZATION COMPLETE ==='); + } catch (error) { + window.LogConfig.logError(error, 'Company Edit Init'); + Utils.showToast('Failed to initialize page', 'error'); } - - companyEditLog.info('=== COMPANY EDIT PAGE INITIALIZATION COMPLETE ==='); }, // Load company data diff --git a/static/admin/js/user-create.js b/static/admin/js/user-create.js index 50b1e5a4..c185045f 100644 --- a/static/admin/js/user-create.js +++ b/static/admin/js/user-create.js @@ -10,6 +10,7 @@ function adminUserCreate() { // User create page specific state currentPage: 'user-create', + loading: false, formData: { username: '', email: '', diff --git a/static/admin/js/user-edit.js b/static/admin/js/user-edit.js index a9b3d5ee..19ce01b9 100644 --- a/static/admin/js/user-edit.js +++ b/static/admin/js/user-edit.js @@ -1,4 +1,3 @@ -// noqa: js-006 - async init pattern is safe, loadData has try/catch // static/admin/js/user-edit.js // Create custom logger for user edit @@ -11,6 +10,7 @@ function adminUserEdit() { // User edit page specific state currentPage: 'user-edit', + loading: false, user: null, formData: {}, errors: {}, @@ -29,21 +29,26 @@ function adminUserEdit() { } window._userEditInitialized = true; - // Get user ID from URL - const path = window.location.pathname; - const match = path.match(/\/admin\/users\/(\d+)\/edit/); + try { + // Get user ID from URL + const path = window.location.pathname; + const match = path.match(/\/admin\/users\/(\d+)\/edit/); - if (match) { - this.userId = parseInt(match[1], 10); - userEditLog.info('Editing user:', this.userId); - await this.loadUser(); - } else { - userEditLog.error('No user ID in URL'); - Utils.showToast('Invalid user URL', 'error'); - setTimeout(() => window.location.href = '/admin/users', 2000); + if (match) { + this.userId = parseInt(match[1], 10); + userEditLog.info('Editing user:', this.userId); + await this.loadUser(); + } else { + userEditLog.error('No user ID in URL'); + Utils.showToast('Invalid user URL', 'error'); + setTimeout(() => window.location.href = '/admin/users', 2000); + } + + userEditLog.info('=== USER EDIT PAGE INITIALIZATION COMPLETE ==='); + } catch (error) { + window.LogConfig.logError(error, 'User Edit Init'); + Utils.showToast('Failed to initialize page', 'error'); } - - userEditLog.info('=== USER EDIT PAGE INITIALIZATION COMPLETE ==='); }, // Load user data diff --git a/static/admin/js/vendor-edit.js b/static/admin/js/vendor-edit.js index c4b9ed6c..b88a69e3 100644 --- a/static/admin/js/vendor-edit.js +++ b/static/admin/js/vendor-edit.js @@ -1,4 +1,3 @@ -// noqa: js-006 - async init pattern is safe, loadData has try/catch // static/admin/js/vendor-edit.js // ✅ Use centralized logger - ONE LINE! @@ -12,6 +11,7 @@ function adminVendorEdit() { // Vendor edit page specific state currentPage: 'vendor-edit', + loading: false, vendor: null, formData: {}, errors: {}, @@ -30,21 +30,26 @@ function adminVendorEdit() { } window._vendorEditInitialized = true; - // Get vendor code from URL - const path = window.location.pathname; - const match = path.match(/\/admin\/vendors\/([^\/]+)\/edit/); + try { + // Get vendor code from URL + const path = window.location.pathname; + const match = path.match(/\/admin\/vendors\/([^\/]+)\/edit/); - if (match) { - this.vendorCode = match[1]; - editLog.info('Editing vendor:', this.vendorCode); - await this.loadVendor(); - } else { - editLog.error('No vendor code in URL'); - Utils.showToast('Invalid vendor URL', 'error'); - setTimeout(() => window.location.href = '/admin/vendors', 2000); + if (match) { + this.vendorCode = match[1]; + editLog.info('Editing vendor:', this.vendorCode); + await this.loadVendor(); + } else { + editLog.error('No vendor code in URL'); + Utils.showToast('Invalid vendor URL', 'error'); + setTimeout(() => window.location.href = '/admin/vendors', 2000); + } + + editLog.info('=== VENDOR EDIT PAGE INITIALIZATION COMPLETE ==='); + } catch (error) { + window.LogConfig.logError(error, 'Vendor Edit Init'); + Utils.showToast('Failed to initialize page', 'error'); } - - editLog.info('=== VENDOR EDIT PAGE INITIALIZATION COMPLETE ==='); }, // Load vendor data diff --git a/static/admin/js/vendor-product-create.js b/static/admin/js/vendor-product-create.js index 2f869496..bdcccb7f 100644 --- a/static/admin/js/vendor-product-create.js +++ b/static/admin/js/vendor-product-create.js @@ -20,6 +20,7 @@ function adminVendorProductCreate() { currentPage: 'vendor-products', // Loading states + loading: false, saving: false, // Tom Select instance