refactor: complete module-driven architecture migration

This commit completes the migration to a fully module-driven architecture:

## Models Migration
- Moved all domain models from models/database/ to their respective modules:
  - tenancy: User, Admin, Vendor, Company, Platform, VendorDomain, etc.
  - cms: MediaFile, VendorTheme
  - messaging: Email, VendorEmailSettings, VendorEmailTemplate
  - core: AdminMenuConfig
- models/database/ now only contains Base and TimestampMixin (infrastructure)

## Schemas Migration
- Moved all domain schemas from models/schema/ to their respective modules:
  - tenancy: company, vendor, admin, team, vendor_domain
  - cms: media, image, vendor_theme
  - messaging: email
- models/schema/ now only contains base.py and auth.py (infrastructure)

## Routes Migration
- Moved admin routes from app/api/v1/admin/ to modules:
  - menu_config.py -> core module
  - modules.py -> tenancy module
  - module_config.py -> tenancy module
- app/api/v1/admin/ now only aggregates auto-discovered module routes

## Menu System
- Implemented module-driven menu system with MenuDiscoveryService
- Extended FrontendType enum: PLATFORM, ADMIN, VENDOR, STOREFRONT
- Added MenuItemDefinition and MenuSectionDefinition dataclasses
- Each module now defines its own menu items in definition.py
- MenuService integrates with MenuDiscoveryService for template rendering

## Documentation
- Updated docs/architecture/models-structure.md
- Updated docs/architecture/menu-management.md
- Updated architecture validation rules for new exceptions

## Architecture Validation
- Updated MOD-019 rule to allow base.py in models/schema/
- Created core module exceptions.py and schemas/ directory
- All validation errors resolved (only warnings remain)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-01 21:02:56 +01:00
parent 09d7d282c6
commit d7a0ff8818
307 changed files with 5536 additions and 3826 deletions

View File

@@ -20,6 +20,9 @@ function adminUserDetailPage() {
// Initialize
async init() {
// Load i18n translations
await I18n.loadModule('tenancy');
adminUserDetailLog.info('=== ADMIN USER DETAIL PAGE INITIALIZING ===');
// Prevent multiple initializations
@@ -43,7 +46,7 @@ function adminUserDetailPage() {
} else {
adminUserDetailLog.error('No user ID in URL');
this.error = 'Invalid admin user URL';
Utils.showToast('Invalid admin user URL', 'error');
Utils.showToast(I18n.t('tenancy.messages.invalid_admin_user_url'), 'error');
}
adminUserDetailLog.info('=== ADMIN USER DETAIL PAGE INITIALIZATION COMPLETE ===');
@@ -88,7 +91,7 @@ function adminUserDetailPage() {
} catch (error) {
window.LogConfig.logError(error, 'Load Admin User Details');
this.error = error.message || 'Failed to load admin user details';
Utils.showToast('Failed to load admin user details', 'error');
Utils.showToast(I18n.t('tenancy.messages.failed_to_load_admin_user_details'), 'error');
} finally {
this.loading = false;
}
@@ -109,7 +112,7 @@ function adminUserDetailPage() {
// Prevent self-deactivation
if (this.adminUser.id === this.currentUserId) {
Utils.showToast('You cannot deactivate your own account', 'error');
Utils.showToast(I18n.t('tenancy.messages.you_cannot_deactivate_your_own_account'), 'error');
return;
}
@@ -145,7 +148,7 @@ function adminUserDetailPage() {
// Prevent self-deletion
if (this.adminUser.id === this.currentUserId) {
Utils.showToast('You cannot delete your own account', 'error');
Utils.showToast(I18n.t('tenancy.messages.you_cannot_delete_your_own_account'), 'error');
return;
}
@@ -169,7 +172,7 @@ function adminUserDetailPage() {
window.LogConfig.logApiCall('DELETE', url, null, 'response');
Utils.showToast('Admin user deleted successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.admin_user_deleted_successfully'), 'success');
adminUserDetailLog.info('Admin user deleted successfully');
// Redirect to admin users list
@@ -187,7 +190,7 @@ function adminUserDetailPage() {
async refresh() {
adminUserDetailLog.info('=== ADMIN USER REFRESH TRIGGERED ===');
await this.loadAdminUser();
Utils.showToast('Admin user details refreshed', 'success');
Utils.showToast(I18n.t('tenancy.messages.admin_user_details_refreshed'), 'success');
adminUserDetailLog.info('=== ADMIN USER REFRESH COMPLETE ===');
}
};

View File

@@ -29,6 +29,9 @@ function adminUserEditPage() {
// Initialize
async init() {
// Load i18n translations
await I18n.loadModule('tenancy');
adminUserEditLog.info('=== ADMIN USER EDIT PAGE INITIALIZING ===');
// Prevent multiple initializations
@@ -52,7 +55,7 @@ function adminUserEditPage() {
await this.loadAllPlatforms();
} else {
adminUserEditLog.error('No user ID in URL');
Utils.showToast('Invalid admin user URL', 'error');
Utils.showToast(I18n.t('tenancy.messages.invalid_admin_user_url'), 'error');
setTimeout(() => window.location.href = '/admin/admin-users', 2000);
}
@@ -94,7 +97,7 @@ function adminUserEditPage() {
} catch (error) {
window.LogConfig.logError(error, 'Load Admin User');
Utils.showToast('Failed to load admin user', 'error');
Utils.showToast(I18n.t('tenancy.messages.failed_to_load_admin_user'), 'error');
setTimeout(() => window.location.href = '/admin/admin-users', 2000);
} finally {
this.loading = false;
@@ -137,7 +140,7 @@ function adminUserEditPage() {
// Prevent self-demotion
if (this.adminUser.id === this.currentUserId && !newStatus) {
Utils.showToast('You cannot demote yourself from super admin', 'error');
Utils.showToast(I18n.t('tenancy.messages.you_cannot_demote_yourself_from_super_ad'), 'error');
return;
}
@@ -180,7 +183,7 @@ function adminUserEditPage() {
// Prevent self-deactivation
if (this.adminUser.id === this.currentUserId) {
Utils.showToast('You cannot deactivate your own account', 'error');
Utils.showToast(I18n.t('tenancy.messages.you_cannot_deactivate_your_own_account'), 'error');
return;
}
@@ -228,7 +231,7 @@ function adminUserEditPage() {
// Reload admin user to get updated platforms
await this.loadAdminUser();
Utils.showToast('Platform assigned successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.platform_assigned_successfully'), 'success');
adminUserEditLog.info('Platform assigned successfully');
this.showPlatformModal = false;
this.selectedPlatformId = null;
@@ -245,7 +248,7 @@ function adminUserEditPage() {
removePlatform(platformId) {
// Validate: platform admin must have at least one platform
if (this.adminUser.platforms.length <= 1) {
Utils.showToast('Platform admin must be assigned to at least one platform', 'error');
Utils.showToast(I18n.t('tenancy.messages.platform_admin_must_be_assigned_to_at_le'), 'error');
return;
}
@@ -272,7 +275,7 @@ function adminUserEditPage() {
// Reload admin user to get updated platforms
await this.loadAdminUser();
Utils.showToast('Platform removed successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.platform_removed_successfully'), 'success');
adminUserEditLog.info('Platform removed successfully');
} catch (error) {
@@ -296,7 +299,7 @@ function adminUserEditPage() {
// Prevent self-deletion
if (this.adminUser.id === this.currentUserId) {
Utils.showToast('You cannot delete your own account', 'error');
Utils.showToast(I18n.t('tenancy.messages.you_cannot_delete_your_own_account'), 'error');
return;
}
@@ -320,7 +323,7 @@ function adminUserEditPage() {
window.LogConfig.logApiCall('DELETE', url, null, 'response');
Utils.showToast('Admin user deleted successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.admin_user_deleted_successfully'), 'success');
adminUserEditLog.info('Admin user deleted successfully');
// Redirect to admin users list

View File

@@ -37,6 +37,9 @@ function adminUsersPage() {
// Initialization
async init() {
// Load i18n translations
await I18n.loadModule('tenancy');
adminUsersLog.info('=== ADMIN USERS PAGE INITIALIZING ===');
// Prevent multiple initializations
@@ -197,7 +200,7 @@ function adminUsersPage() {
} catch (error) {
window.LogConfig.logError(error, 'Load Admin Users');
this.error = error.message || 'Failed to load admin users';
Utils.showToast('Failed to load admin users', 'error');
Utils.showToast(I18n.t('tenancy.messages.failed_to_load_admin_users'), 'error');
} finally {
this.loading = false;
}
@@ -288,7 +291,7 @@ function adminUsersPage() {
// Prevent self-deletion
if (admin.id === this.currentUserId) {
Utils.showToast('You cannot delete your own account', 'error');
Utils.showToast(I18n.t('tenancy.messages.you_cannot_delete_your_own_account'), 'error');
return;
}
@@ -309,7 +312,7 @@ function adminUsersPage() {
await apiClient.delete(url);
Utils.showToast('Admin user deleted successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.admin_user_deleted_successfully'), 'success');
adminUsersLog.info('Admin user deleted successfully');
await this.loadAdminUsers();

View File

@@ -18,6 +18,9 @@ function adminCompanyDetail() {
// Initialize
async init() {
// Load i18n translations
await I18n.loadModule('tenancy');
companyDetailLog.info('=== COMPANY DETAIL PAGE INITIALIZING ===');
// Prevent multiple initializations
@@ -38,7 +41,7 @@ function adminCompanyDetail() {
} else {
companyDetailLog.error('No company ID in URL');
this.error = 'Invalid company URL';
Utils.showToast('Invalid company URL', 'error');
Utils.showToast(I18n.t('tenancy.messages.invalid_company_url'), 'error');
}
companyDetailLog.info('=== COMPANY DETAIL PAGE INITIALIZATION COMPLETE ===');
@@ -75,7 +78,7 @@ function adminCompanyDetail() {
} catch (error) {
window.LogConfig.logError(error, 'Load Company Details');
this.error = error.message || 'Failed to load company details';
Utils.showToast('Failed to load company details', 'error');
Utils.showToast(I18n.t('tenancy.messages.failed_to_load_company_details'), 'error');
} finally {
this.loading = false;
}
@@ -121,7 +124,7 @@ function adminCompanyDetail() {
window.LogConfig.logApiCall('DELETE', url, null, 'response');
Utils.showToast('Company deleted successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.company_deleted_successfully'), 'success');
companyDetailLog.info('Company deleted successfully');
// Redirect to companies list
@@ -137,7 +140,7 @@ function adminCompanyDetail() {
async refresh() {
companyDetailLog.info('=== COMPANY REFRESH TRIGGERED ===');
await this.loadCompany();
Utils.showToast('Company details refreshed', 'success');
Utils.showToast(I18n.t('tenancy.messages.company_details_refreshed'), 'success');
companyDetailLog.info('=== COMPANY REFRESH COMPLETE ===');
}
};

View File

@@ -39,6 +39,9 @@ function adminCompanyEdit() {
// Initialize
async init() {
// Load i18n translations
await I18n.loadModule('tenancy');
companyEditLog.info('=== COMPANY EDIT PAGE INITIALIZING ===');
// Prevent multiple initializations
@@ -59,14 +62,14 @@ function adminCompanyEdit() {
await this.loadCompany();
} else {
companyEditLog.error('No company ID in URL');
Utils.showToast('Invalid company URL', 'error');
Utils.showToast(I18n.t('tenancy.messages.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');
Utils.showToast(I18n.t('tenancy.messages.failed_to_initialize_page'), 'error');
}
},
@@ -107,7 +110,7 @@ function adminCompanyEdit() {
} catch (error) {
window.LogConfig.logError(error, 'Load Company');
Utils.showToast('Failed to load company', 'error');
Utils.showToast(I18n.t('tenancy.messages.failed_to_load_company'), 'error');
setTimeout(() => window.location.href = '/admin/companies', 2000);
} finally {
this.loadingCompany = false;
@@ -134,7 +137,7 @@ function adminCompanyEdit() {
window.LogConfig.logPerformance('Update Company', duration);
this.company = response;
Utils.showToast('Company updated successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.company_updated_successfully'), 'success');
companyEditLog.info(`Company updated successfully in ${duration}ms`, response);
} catch (error) {
@@ -258,7 +261,7 @@ function adminCompanyEdit() {
window.LogConfig.logApiCall('POST', url, response, 'response');
Utils.showToast('Ownership transferred successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.ownership_transferred_successfully'), 'success');
companyEditLog.info('Ownership transferred successfully', response);
// Close modal and reload company data
@@ -370,7 +373,7 @@ function adminCompanyEdit() {
window.LogConfig.logApiCall('DELETE', url, response, 'response');
Utils.showToast('Company deleted successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.company_deleted_successfully'), 'success');
companyEditLog.info('Company deleted successfully');
// Redirect to companies list

View File

@@ -26,6 +26,9 @@ function adminUserCreate() {
// Initialize
async init() {
// Load i18n translations
await I18n.loadModule('tenancy');
userCreateLog.info('=== ADMIN USER CREATE PAGE INITIALIZING ===');
// Prevent multiple initializations
@@ -85,7 +88,7 @@ function adminUserCreate() {
if (!this.validateForm()) {
userCreateLog.warn('Validation failed:', this.errors);
Utils.showToast('Please fix the errors before submitting', 'error');
Utils.showToast(I18n.t('tenancy.messages.please_fix_the_errors_before_submitting'), 'error');
return;
}

View File

@@ -19,6 +19,9 @@ function adminUserDetail() {
// Initialize
async init() {
// Load i18n translations
await I18n.loadModule('tenancy');
userDetailLog.info('=== USER DETAIL PAGE INITIALIZING ===');
// Prevent multiple initializations
@@ -39,7 +42,7 @@ function adminUserDetail() {
} else {
userDetailLog.error('No user ID in URL');
this.error = 'Invalid user URL';
Utils.showToast('Invalid user URL', 'error');
Utils.showToast(I18n.t('tenancy.messages.invalid_user_url'), 'error');
}
userDetailLog.info('=== USER DETAIL PAGE INITIALIZATION COMPLETE ===');
@@ -75,7 +78,7 @@ function adminUserDetail() {
} catch (error) {
window.LogConfig.logError(error, 'Load User Details');
this.error = error.message || 'Failed to load user details';
Utils.showToast('Failed to load user details', 'error');
Utils.showToast(I18n.t('tenancy.messages.failed_to_load_user_details'), 'error');
} finally {
this.loading = false;
}
@@ -149,7 +152,7 @@ function adminUserDetail() {
window.LogConfig.logApiCall('DELETE', url, null, 'response');
Utils.showToast('User deleted successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.user_deleted_successfully'), 'success');
userDetailLog.info('User deleted successfully');
// Redirect to users list
@@ -167,7 +170,7 @@ function adminUserDetail() {
async refresh() {
userDetailLog.info('=== USER REFRESH TRIGGERED ===');
await this.loadUser();
Utils.showToast('User details refreshed', 'success');
Utils.showToast(I18n.t('tenancy.messages.user_details_refreshed'), 'success');
userDetailLog.info('=== USER REFRESH COMPLETE ===');
}
};

View File

@@ -20,6 +20,9 @@ function adminUserEdit() {
// Initialize
async init() {
// Load i18n translations
await I18n.loadModule('tenancy');
userEditLog.info('=== USER EDIT PAGE INITIALIZING ===');
// Prevent multiple initializations
@@ -40,14 +43,14 @@ function adminUserEdit() {
await this.loadUser();
} else {
userEditLog.error('No user ID in URL');
Utils.showToast('Invalid user URL', 'error');
Utils.showToast(I18n.t('tenancy.messages.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');
Utils.showToast(I18n.t('tenancy.messages.failed_to_initialize_page'), 'error');
}
},
@@ -87,7 +90,7 @@ function adminUserEdit() {
} catch (error) {
window.LogConfig.logError(error, 'Load User');
Utils.showToast('Failed to load user', 'error');
Utils.showToast(I18n.t('tenancy.messages.failed_to_load_user'), 'error');
setTimeout(() => window.location.href = '/admin/users', 2000);
} finally {
this.loadingUser = false;
@@ -122,7 +125,7 @@ function adminUserEdit() {
window.LogConfig.logPerformance('Update User', duration);
this.user = response;
Utils.showToast('User updated successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.user_updated_successfully'), 'success');
userEditLog.info(`User updated successfully in ${duration}ms`, response);
} catch (error) {
@@ -207,7 +210,7 @@ function adminUserEdit() {
window.LogConfig.logApiCall('DELETE', url, null, 'response');
Utils.showToast('User deleted successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.user_deleted_successfully'), 'success');
userEditLog.info('User deleted successfully');
// Redirect to users list

View File

@@ -36,6 +36,9 @@ function adminUsers() {
// Initialization
async init() {
// Load i18n translations
await I18n.loadModule('tenancy');
usersLog.info('=== USERS PAGE INITIALIZING ===');
// Prevent multiple initializations
@@ -159,7 +162,7 @@ function adminUsers() {
} catch (error) {
window.LogConfig.logError(error, 'Load Users');
this.error = error.message || 'Failed to load users';
Utils.showToast('Failed to load users', 'error');
Utils.showToast(I18n.t('tenancy.messages.failed_to_load_users'), 'error');
} finally {
this.loading = false;
}
@@ -278,14 +281,14 @@ function adminUsers() {
await apiClient.delete(url); // ✅ Fixed: lowercase apiClient
Utils.showToast('User deleted successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.user_deleted_successfully'), 'success');
usersLog.info('User deleted successfully');
await this.loadUsers();
await this.loadStats();
} catch (error) {
window.LogConfig.logError(error, 'Delete User');
Utils.showToast('Failed to delete user', 'error');
Utils.showToast(I18n.t('tenancy.messages.failed_to_delete_user'), 'error');
}
},

View File

@@ -21,6 +21,9 @@ function adminVendorDetail() {
// Initialize
async init() {
// Load i18n translations
await I18n.loadModule('tenancy');
detailLog.info('=== VENDOR DETAIL PAGE INITIALIZING ===');
// Prevent multiple initializations
@@ -45,7 +48,7 @@ function adminVendorDetail() {
} else {
detailLog.error('No vendor code in URL');
this.error = 'Invalid vendor URL';
Utils.showToast('Invalid vendor URL', 'error');
Utils.showToast(I18n.t('tenancy.messages.invalid_vendor_url'), 'error');
}
detailLog.info('=== VENDOR DETAIL PAGE INITIALIZATION COMPLETE ===');
@@ -81,7 +84,7 @@ function adminVendorDetail() {
} catch (error) {
window.LogConfig.logError(error, 'Load Vendor Details');
this.error = error.message || 'Failed to load vendor details';
Utils.showToast('Failed to load vendor details', 'error');
Utils.showToast(I18n.t('tenancy.messages.failed_to_load_vendor_details'), 'error');
} finally {
this.loading = false;
}
@@ -144,7 +147,7 @@ function adminVendorDetail() {
// Create a new subscription for this vendor
async createSubscription() {
if (!this.vendor?.id) {
Utils.showToast('No vendor loaded', 'error');
Utils.showToast(I18n.t('tenancy.messages.no_vendor_loaded'), 'error');
return;
}
@@ -165,7 +168,7 @@ function adminVendorDetail() {
window.LogConfig.logApiCall('POST', url, response, 'response');
this.subscription = response;
Utils.showToast('Subscription created successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.subscription_created_successfully'), 'success');
detailLog.info('Subscription created:', this.subscription);
} catch (error) {
@@ -198,7 +201,7 @@ function adminVendorDetail() {
window.LogConfig.logApiCall('DELETE', url, null, 'response');
Utils.showToast('Vendor deleted successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.vendor_deleted_successfully'), 'success');
detailLog.info('Vendor deleted successfully');
// Redirect to vendors list
@@ -214,7 +217,7 @@ function adminVendorDetail() {
async refresh() {
detailLog.info('=== VENDOR REFRESH TRIGGERED ===');
await this.loadVendor();
Utils.showToast('Vendor details refreshed', 'success');
Utils.showToast(I18n.t('tenancy.messages.vendor_details_refreshed'), 'success');
detailLog.info('=== VENDOR REFRESH COMPLETE ===');
}
};

View File

@@ -21,6 +21,9 @@ function adminVendorEdit() {
// Initialize
async init() {
// Load i18n translations
await I18n.loadModule('tenancy');
editLog.info('=== VENDOR EDIT PAGE INITIALIZING ===');
// Prevent multiple initializations
@@ -41,14 +44,14 @@ function adminVendorEdit() {
await this.loadVendor();
} else {
editLog.error('No vendor code in URL');
Utils.showToast('Invalid vendor URL', 'error');
Utils.showToast(I18n.t('tenancy.messages.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');
Utils.showToast(I18n.t('tenancy.messages.failed_to_initialize_page'), 'error');
}
},
@@ -96,7 +99,7 @@ function adminVendorEdit() {
} catch (error) {
window.LogConfig.logError(error, 'Load Vendor');
Utils.showToast('Failed to load vendor', 'error');
Utils.showToast(I18n.t('tenancy.messages.failed_to_load_vendor'), 'error');
setTimeout(() => window.location.href = '/admin/vendors', 2000);
} finally {
this.loadingVendor = false;
@@ -131,7 +134,7 @@ function adminVendorEdit() {
window.LogConfig.logPerformance('Update Vendor', duration);
this.vendor = response;
Utils.showToast('Vendor updated successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.vendor_updated_successfully'), 'success');
editLog.info(`Vendor updated successfully in ${duration}ms`, response);
// Optionally redirect back to list
@@ -249,7 +252,7 @@ function adminVendorEdit() {
window.LogConfig.logApiCall('DELETE', url, response, 'response');
Utils.showToast('Vendor deleted successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.vendor_deleted_successfully'), 'success');
editLog.info('Vendor deleted successfully');
// Redirect to vendors list
@@ -294,7 +297,7 @@ function adminVendorEdit() {
this.formData[field] = '';
});
Utils.showToast('All contact fields reset to company defaults', 'info');
Utils.showToast(I18n.t('tenancy.messages.all_contact_fields_reset_to_company_defa'), 'info');
},
/**

View File

@@ -43,6 +43,9 @@ function adminVendors() {
// Initialize
async init() {
// Load i18n translations
await I18n.loadModule('tenancy');
vendorsLog.info('=== VENDORS PAGE INITIALIZING ===');
// Prevent multiple initializations
@@ -195,7 +198,7 @@ function adminVendors() {
} catch (error) {
window.LogConfig.logError(error, 'Load Vendors');
this.error = error.message || 'Failed to load vendors';
Utils.showToast('Failed to load vendors', 'error');
Utils.showToast(I18n.t('tenancy.messages.failed_to_load_vendors'), 'error');
} finally {
this.loading = false;
}
@@ -298,7 +301,7 @@ function adminVendors() {
window.LogConfig.logApiCall('DELETE', url, null, 'response');
Utils.showToast('Vendor deleted successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.vendor_deleted_successfully'), 'success');
vendorsLog.info('Vendor deleted successfully');
// Reload data
@@ -320,7 +323,7 @@ function adminVendors() {
await this.loadStats();
vendorsLog.groupEnd();
Utils.showToast('Vendors list refreshed', 'success');
Utils.showToast(I18n.t('tenancy.messages.vendors_list_refreshed'), 'success');
vendorsLog.info('=== VENDORS REFRESH COMPLETE ===');
}
};

View File

@@ -45,6 +45,9 @@ function vendorProfile() {
hasChanges: false,
async init() {
// Load i18n translations
await I18n.loadModule('tenancy');
vendorProfileLog.info('Profile init() called');
// Guard against multiple initialization
@@ -153,7 +156,7 @@ function vendorProfile() {
*/
async saveProfile() {
if (!this.validateForm()) {
Utils.showToast('Please fix the errors before saving', 'error');
Utils.showToast(I18n.t('tenancy.messages.please_fix_the_errors_before_saving'), 'error');
return;
}
@@ -161,7 +164,7 @@ function vendorProfile() {
try {
await apiClient.put(`/vendor/profile`, this.form);
Utils.showToast('Profile updated successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.profile_updated_successfully'), 'success');
vendorProfileLog.info('Profile updated');
this.hasChanges = false;

View File

@@ -135,6 +135,9 @@ function vendorSettings() {
hasMarketplaceChanges: false,
async init() {
// Load i18n translations
await I18n.loadModule('tenancy');
vendorSettingsLog.info('Settings init() called');
// Guard against multiple initialization
@@ -315,7 +318,7 @@ function vendorSettings() {
await apiClient.put(`/vendor/settings/business-info`, payload);
Utils.showToast('Business info saved', 'success');
Utils.showToast(I18n.t('tenancy.messages.business_info_saved'), 'success');
vendorSettingsLog.info('Business info updated');
// Reload to get updated inheritance flags
@@ -337,7 +340,7 @@ function vendorSettings() {
try {
await apiClient.put(`/vendor/settings/letzshop`, this.marketplaceForm);
Utils.showToast('Marketplace settings saved', 'success');
Utils.showToast(I18n.t('tenancy.messages.marketplace_settings_saved'), 'success');
vendorSettingsLog.info('Marketplace settings updated');
this.hasMarketplaceChanges = false;
@@ -355,7 +358,7 @@ function vendorSettings() {
async testLetzshopUrl(lang) {
const url = this.marketplaceForm[`letzshop_csv_url_${lang}`];
if (!url) {
Utils.showToast('Please enter a URL first', 'error');
Utils.showToast(I18n.t('tenancy.messages.please_enter_a_url_first'), 'error');
return;
}
@@ -365,7 +368,7 @@ function vendorSettings() {
const response = await fetch(url, { method: 'HEAD', mode: 'no-cors' });
Utils.showToast(`URL appears to be valid`, 'success');
} catch (error) {
Utils.showToast('Could not validate URL - it may still work', 'warning');
Utils.showToast(I18n.t('tenancy.messages.could_not_validate_url_it_may_still_work'), 'warning');
} finally {
this.saving = false;
}
@@ -406,7 +409,7 @@ function vendorSettings() {
try {
await apiClient.put(`/vendor/settings/localization`, this.localizationForm);
Utils.showToast('Localization settings saved', 'success');
Utils.showToast(I18n.t('tenancy.messages.localization_settings_saved'), 'success');
vendorSettingsLog.info('Localization settings updated');
this.hasLocalizationChanges = false;
@@ -450,7 +453,7 @@ function vendorSettings() {
vendorSettingsLog.info('Loaded email settings');
} catch (error) {
vendorSettingsLog.error('Failed to load email settings:', error);
Utils.showToast('Failed to load email settings', 'error');
Utils.showToast(I18n.t('tenancy.messages.failed_to_load_email_settings'), 'error');
} finally {
this.emailSettingsLoading = false;
}
@@ -500,7 +503,7 @@ function vendorSettings() {
async saveEmailSettings() {
// Validate required fields
if (!this.emailForm.from_email || !this.emailForm.from_name) {
Utils.showToast('From Email and From Name are required', 'error');
Utils.showToast(I18n.t('tenancy.messages.from_email_and_from_name_are_required'), 'error');
return;
}
@@ -509,7 +512,7 @@ function vendorSettings() {
const response = await apiClient.put('/vendor/email-settings', this.emailForm);
if (response.success) {
Utils.showToast('Email settings saved', 'success');
Utils.showToast(I18n.t('tenancy.messages.email_settings_saved'), 'success');
vendorSettingsLog.info('Email settings updated');
// Update local state
@@ -531,12 +534,12 @@ function vendorSettings() {
*/
async sendTestEmail() {
if (!this.testEmailAddress) {
Utils.showToast('Please enter a test email address', 'error');
Utils.showToast(I18n.t('tenancy.messages.please_enter_a_test_email_address'), 'error');
return;
}
if (!this.emailSettings?.is_configured) {
Utils.showToast('Please save your email settings first', 'error');
Utils.showToast(I18n.t('tenancy.messages.please_save_your_email_settings_first'), 'error');
return;
}
@@ -547,7 +550,7 @@ function vendorSettings() {
});
if (response.success) {
Utils.showToast('Test email sent! Check your inbox.', 'success');
Utils.showToast(I18n.t('tenancy.messages.test_email_sent_check_your_inbox'), 'success');
// Update verification status
this.emailSettings.is_verified = true;
} else {

View File

@@ -64,6 +64,9 @@ function vendorTeam() {
],
async init() {
// Load i18n translations
await I18n.loadModule('tenancy');
vendorTeamLog.info('Team init() called');
// Guard against multiple initialization
@@ -149,7 +152,7 @@ function vendorTeam() {
*/
async sendInvitation() {
if (!this.inviteForm.email) {
Utils.showToast('Email is required', 'error');
Utils.showToast(I18n.t('tenancy.messages.email_is_required'), 'error');
return;
}
@@ -157,7 +160,7 @@ function vendorTeam() {
try {
await apiClient.post(`/vendor/team/invite`, this.inviteForm);
Utils.showToast('Invitation sent successfully', 'success');
Utils.showToast(I18n.t('tenancy.messages.invitation_sent_successfully'), 'success');
vendorTeamLog.info('Invitation sent to:', this.inviteForm.email);
this.showInviteModal = false;
@@ -195,7 +198,7 @@ function vendorTeam() {
this.editForm
);
Utils.showToast('Team member updated', 'success');
Utils.showToast(I18n.t('tenancy.messages.team_member_updated'), 'success');
vendorTeamLog.info('Updated team member:', this.selectedMember.user_id);
this.showEditModal = false;
@@ -227,7 +230,7 @@ function vendorTeam() {
try {
await apiClient.delete(`/vendor/team/members/${this.selectedMember.user_id}`);
Utils.showToast('Team member removed', 'success');
Utils.showToast(I18n.t('tenancy.messages.team_member_removed'), 'success');
vendorTeamLog.info('Removed team member:', this.selectedMember.user_id);
this.showRemoveModal = false;