feat: multi-module improvements across merchant, store, i18n, and customer systems
All checks were successful
All checks were successful
- Fix platform-grouped merchant sidebar menu with core items at root level - Add merchant store management (detail page, create store, team page) - Fix store settings 500 error by removing dead stripe/API tab - Move onboarding translations to module-owned locale files - Fix onboarding banner i18n with server-side rendering + context inheritance - Refactor login language selectors to use languageSelector() function (LANG-002) - Move HTTPException handling to global exception handler in merchant routes (API-003) - Add language selector to all login pages and portal headers - Fix customer module: drop order stats from customer model, add to orders module - Fix admin menu config visibility for super admin platform context - Fix storefront auth and layout issues - Add missing i18n translations for onboarding steps (en/fr/de/lb) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// static/admin/js/select-platform.js
|
||||
// Platform selection page for platform admins
|
||||
// Platform selection page for admins (platform admins and super admins)
|
||||
|
||||
const platformLog = window.LogConfig ? window.LogConfig.createLogger('PLATFORM_SELECT') : console;
|
||||
|
||||
@@ -11,6 +11,7 @@ function selectPlatform() {
|
||||
error: null,
|
||||
platforms: [],
|
||||
isSuperAdmin: false,
|
||||
currentPlatformId: null,
|
||||
|
||||
async init() {
|
||||
platformLog.info('=== PLATFORM SELECTION PAGE INITIALIZING ===');
|
||||
@@ -46,21 +47,14 @@ function selectPlatform() {
|
||||
const response = await apiClient.get('/admin/auth/accessible-platforms');
|
||||
platformLog.debug('Platforms response:', response);
|
||||
|
||||
this.isSuperAdmin = response.role === 'super_admin';
|
||||
this.isSuperAdmin = response.is_super_admin === true;
|
||||
this.platforms = response.platforms || [];
|
||||
this.currentPlatformId = response.current_platform_id || null;
|
||||
|
||||
if (this.isSuperAdmin) {
|
||||
platformLog.info('User is super admin, redirecting to dashboard...');
|
||||
setTimeout(() => {
|
||||
window.location.href = '/admin/dashboard';
|
||||
}, 1500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!response.requires_platform_selection && this.platforms.length === 1) {
|
||||
if (!this.isSuperAdmin && !response.requires_platform_selection && this.platforms.length === 1) {
|
||||
// Only one platform assigned, auto-select it
|
||||
platformLog.info('Single platform assigned, auto-selecting...');
|
||||
await this.selectPlatform(this.platforms[0]);
|
||||
await this.choosePlatform(this.platforms[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -81,7 +75,11 @@ function selectPlatform() {
|
||||
}
|
||||
},
|
||||
|
||||
async selectPlatform(platform) {
|
||||
isCurrentPlatform(platform) {
|
||||
return this.currentPlatformId && this.currentPlatformId === platform.id;
|
||||
},
|
||||
|
||||
async choosePlatform(platform) {
|
||||
if (this.selecting) return;
|
||||
|
||||
this.selecting = true;
|
||||
@@ -132,6 +130,37 @@ function selectPlatform() {
|
||||
}
|
||||
},
|
||||
|
||||
async deselectPlatform() {
|
||||
if (this.selecting) return;
|
||||
|
||||
this.selecting = true;
|
||||
this.error = null;
|
||||
platformLog.info('Deselecting platform (returning to global mode)...');
|
||||
|
||||
try {
|
||||
const response = await apiClient.post('/admin/auth/deselect-platform');
|
||||
|
||||
if (response.access_token) {
|
||||
// Store new token without platform context
|
||||
localStorage.setItem('admin_token', response.access_token);
|
||||
localStorage.setItem('token', response.access_token);
|
||||
|
||||
// Remove platform info
|
||||
localStorage.removeItem('admin_platform');
|
||||
|
||||
platformLog.info('Platform deselected, redirecting to dashboard...');
|
||||
window.location.href = '/admin/dashboard';
|
||||
} else {
|
||||
throw new Error('No token received from server');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
platformLog.error('Platform deselection failed:', error);
|
||||
this.error = error.message || 'Failed to deselect platform. Please try again.';
|
||||
this.selecting = false;
|
||||
}
|
||||
},
|
||||
|
||||
async logout() {
|
||||
platformLog.info('Logging out...');
|
||||
|
||||
|
||||
@@ -8,6 +8,27 @@
|
||||
// Create custom logger for store login page
|
||||
const storeLoginLog = window.LogConfig.createLogger('STORE-LOGIN');
|
||||
|
||||
function languageSelector(currentLang, enabledLanguages) {
|
||||
return {
|
||||
currentLang: currentLang || 'fr',
|
||||
languages: enabledLanguages || ['en', 'fr', 'de', 'lb'],
|
||||
async setLanguage(lang) {
|
||||
if (lang === this.currentLang) return;
|
||||
try {
|
||||
// noqa: JS-008 - Login page has no apiClient; raw fetch is intentional
|
||||
await fetch('/api/v1/platform/language/set', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ language: lang }),
|
||||
});
|
||||
window.location.reload();
|
||||
} catch (error) {
|
||||
storeLoginLog.error('Failed to set language:', error);
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function storeLogin() {
|
||||
return {
|
||||
credentials: {
|
||||
@@ -159,6 +180,7 @@ function storeLogin() {
|
||||
},
|
||||
|
||||
// Forgot password state
|
||||
rememberMe: false,
|
||||
showForgotPassword: false,
|
||||
forgotPasswordEmail: '',
|
||||
forgotPasswordLoading: false,
|
||||
|
||||
@@ -39,7 +39,6 @@ function storeSettings() {
|
||||
{ id: 'invoices', label: 'Invoices', icon: 'document-text' },
|
||||
{ id: 'branding', label: 'Branding', icon: 'color-swatch' },
|
||||
{ id: 'domains', label: 'Domains', icon: 'globe-alt' },
|
||||
{ id: 'api', label: 'API & Payments', icon: 'key' },
|
||||
{ id: 'notifications', label: 'Notifications', icon: 'bell' },
|
||||
{ id: 'email', label: 'Email', icon: 'mail' }
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user