Refactor LocationPicker to remove unused translation for sub-location and adjust level rendering logic

This commit is contained in:
estifanos
2026-08-08 09:06:12 +00:00
parent cfc9bc1a93
commit 78e37bb90f
3 changed files with 6 additions and 4 deletions

View File

@@ -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);

View File

@@ -247,7 +247,6 @@ export const am: Translations = {
noOptions: 'ምንም አማራጮች አልተገኙም',
noLocationsAvailable: 'ምንም አካባቢዎች የሉም',
chooseFirst: 'መጀመሪያ አካባቢ ይምረጡ',
subLocation: 'ንዑስ አካባቢ',
loading: 'አካባቢዎች በመጫን ላይ...',
loadFailed: 'አካባቢዎችን መጫን አልተቻለም',
},

View File

@@ -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',
},