fixed cache and locals issues
This commit is contained in:
parent
95780a9911
commit
d8e51c3d0a
2 changed files with 8 additions and 14 deletions
|
|
@ -190,21 +190,12 @@ export function FormGeneratorTable<T extends Record<string, any>>({
|
|||
emptyMessage,
|
||||
apiEndpoint
|
||||
}: FormGeneratorTableProps<T>) {
|
||||
const { t } = useLanguage();
|
||||
// Get current language from localStorage or default to 'en'
|
||||
const { t, currentLanguage: contextLanguage } = useLanguage();
|
||||
// Map frontend language codes (de/en/fr) to backend codes (ge/en/fr) for multilingual field resolution
|
||||
const currentLanguage = useMemo(() => {
|
||||
try {
|
||||
const stored = localStorage.getItem('language') || localStorage.getItem('app-language');
|
||||
if (stored) {
|
||||
// Map frontend language codes to backend codes
|
||||
const langMap: Record<string, string> = { 'de': 'ge', 'en': 'en', 'fr': 'fr', 'it': 'it' };
|
||||
return langMap[stored] || stored;
|
||||
}
|
||||
} catch {
|
||||
// Ignore localStorage errors
|
||||
}
|
||||
return 'en'; // Default to English
|
||||
}, []);
|
||||
const langMap: Record<string, string> = { 'de': 'ge', 'en': 'en', 'fr': 'fr', 'it': 'it' };
|
||||
return langMap[contextLanguage] || contextLanguage || 'en';
|
||||
}, [contextLanguage]);
|
||||
// Use provided columns from Pydantic attribute definitions
|
||||
// NO AUTO-DETECTION - columns must come from backend attribute definitions
|
||||
// Use a ref to cache columns so they persist across data changes (e.g., when filtering)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ export const setUserDataCache = (userData: CachedUserData): void => {
|
|||
// roleLabels/privilege are optional metadata, not required for app functionality
|
||||
try {
|
||||
sessionStorage.setItem(USER_CACHE_KEY, JSON.stringify(userData));
|
||||
// Notify listeners (e.g. LanguageProvider) that user data has changed.
|
||||
// This ensures the UI language syncs after login/refresh/profile update.
|
||||
window.dispatchEvent(new CustomEvent('userInfoUpdated'));
|
||||
} catch (error) {
|
||||
console.error('Failed to cache user data:', error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue