From 78e37bb90f2ddc14299e1c39a15e18391ba88f7e Mon Sep 17 00:00:00 2001 From: estifanos Date: Sat, 8 Aug 2026 09:06:12 +0000 Subject: [PATCH] Refactor LocationPicker to remove unused translation for sub-location and adjust level rendering logic --- .../app/features/location/components/LocationPicker.tsx | 8 ++++++-- apps/portal/src/app/i18n/locales/am.ts | 1 - apps/portal/src/app/i18n/locales/en.ts | 1 - 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/portal/src/app/features/location/components/LocationPicker.tsx b/apps/portal/src/app/features/location/components/LocationPicker.tsx index 3f9f2be26..d0e629252 100644 --- a/apps/portal/src/app/features/location/components/LocationPicker.tsx +++ b/apps/portal/src/app/features/location/components/LocationPicker.tsx @@ -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); diff --git a/apps/portal/src/app/i18n/locales/am.ts b/apps/portal/src/app/i18n/locales/am.ts index 1fe2d9a39..fb540d064 100644 --- a/apps/portal/src/app/i18n/locales/am.ts +++ b/apps/portal/src/app/i18n/locales/am.ts @@ -247,7 +247,6 @@ export const am: Translations = { noOptions: 'ምንም አማራጮች አልተገኙም', noLocationsAvailable: 'ምንም አካባቢዎች የሉም', chooseFirst: 'መጀመሪያ አካባቢ ይምረጡ', - subLocation: 'ንዑስ አካባቢ', loading: 'አካባቢዎች በመጫን ላይ...', loadFailed: 'አካባቢዎችን መጫን አልተቻለም', }, diff --git a/apps/portal/src/app/i18n/locales/en.ts b/apps/portal/src/app/i18n/locales/en.ts index c23ee7ccb..adae0568b 100644 --- a/apps/portal/src/app/i18n/locales/en.ts +++ b/apps/portal/src/app/i18n/locales/en.ts @@ -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', },