mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 19:12:50 +00:00
Refactor LocationPicker to remove unused translation for sub-location and adjust level rendering logic
This commit is contained in:
@@ -144,7 +144,7 @@ export function LocationPicker({ value, onChange, onChainChange, required }: Loc
|
||||
const names = typeIds
|
||||
.map((id) => typeMap.get(id)?.names.en)
|
||||
.filter(Boolean) as string[];
|
||||
return names.join(' / ') || t('location.subLocation');
|
||||
return names.join(' / ');
|
||||
};
|
||||
|
||||
const selectedPath = useMemo(() => {
|
||||
@@ -183,9 +183,13 @@ export function LocationPicker({ value, onChange, onChainChange, required }: Loc
|
||||
);
|
||||
}
|
||||
|
||||
// Only offer a further level when its location type resolves to a known
|
||||
// name — an unnamed/unmapped type (e.g. a stray Kebele row) would otherwise
|
||||
// render as a dead-end "Sub-location" picker whose selection is silently
|
||||
// dropped (AddressFormContent only maps Region/City/SubCity/Woreda).
|
||||
const totalRenderedLevels = Math.max(
|
||||
1,
|
||||
selectedChain.length + (currentLevelChildren.length > 0 ? 1 : 0),
|
||||
selectedChain.length + (currentLevelChildren.length > 0 && levelLabel ? 1 : 0),
|
||||
);
|
||||
|
||||
const levels = Array.from({ length: totalRenderedLevels }, (_, i) => i);
|
||||
|
||||
@@ -247,7 +247,6 @@ export const am: Translations = {
|
||||
noOptions: 'ምንም አማራጮች አልተገኙም',
|
||||
noLocationsAvailable: 'ምንም አካባቢዎች የሉም',
|
||||
chooseFirst: 'መጀመሪያ አካባቢ ይምረጡ',
|
||||
subLocation: 'ንዑስ አካባቢ',
|
||||
loading: 'አካባቢዎች በመጫን ላይ...',
|
||||
loadFailed: 'አካባቢዎችን መጫን አልተቻለም',
|
||||
},
|
||||
|
||||
@@ -246,7 +246,6 @@ export const en = {
|
||||
noOptions: 'No options found',
|
||||
noLocationsAvailable: 'No locations available',
|
||||
chooseFirst: 'Choose a location first',
|
||||
subLocation: 'Sub-location',
|
||||
loading: 'Loading locations...',
|
||||
loadFailed: 'Could not load locations',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user