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,
|
emptyMessage,
|
||||||
apiEndpoint
|
apiEndpoint
|
||||||
}: FormGeneratorTableProps<T>) {
|
}: FormGeneratorTableProps<T>) {
|
||||||
const { t } = useLanguage();
|
const { t, currentLanguage: contextLanguage } = useLanguage();
|
||||||
// Get current language from localStorage or default to 'en'
|
// Map frontend language codes (de/en/fr) to backend codes (ge/en/fr) for multilingual field resolution
|
||||||
const currentLanguage = useMemo(() => {
|
const currentLanguage = useMemo(() => {
|
||||||
try {
|
const langMap: Record<string, string> = { 'de': 'ge', 'en': 'en', 'fr': 'fr', 'it': 'it' };
|
||||||
const stored = localStorage.getItem('language') || localStorage.getItem('app-language');
|
return langMap[contextLanguage] || contextLanguage || 'en';
|
||||||
if (stored) {
|
}, [contextLanguage]);
|
||||||
// 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
|
|
||||||
}, []);
|
|
||||||
// Use provided columns from Pydantic attribute definitions
|
// Use provided columns from Pydantic attribute definitions
|
||||||
// NO AUTO-DETECTION - columns must come from backend 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)
|
// 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
|
// roleLabels/privilege are optional metadata, not required for app functionality
|
||||||
try {
|
try {
|
||||||
sessionStorage.setItem(USER_CACHE_KEY, JSON.stringify(userData));
|
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) {
|
} catch (error) {
|
||||||
console.error('Failed to cache user data:', error);
|
console.error('Failed to cache user data:', error);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue