@@ -9,15 +9,17 @@ import debounce from 'lodash/debounce';
99interface LocationSelectorModalProps {
1010 isOpen : boolean ;
1111 onClose : ( ) => void ;
12- onSelectLocation : ( countryCode : string , locationName : string ) => void ;
12+ onSelectLocation : ( location : Location ) => void ;
1313 currentCountryCode ?: string ;
14+ currentLocationId ?: string ;
1415}
1516
1617const LocationSelectorModal : React . FC < LocationSelectorModalProps > = ( {
1718 isOpen,
1819 onClose,
1920 onSelectLocation,
2021 currentCountryCode,
22+ currentLocationId,
2123} ) => {
2224 const [ searchQuery , setSearchQuery ] = useState ( '' ) ;
2325 const [ locations , setLocations ] = useState < Location [ ] > ( [ ] ) ;
@@ -134,11 +136,12 @@ const LocationSelectorModal: React.FC<LocationSelectorModalProps> = ({
134136 } ;
135137
136138 const handleSelectLocation = ( location : Location ) => {
137- if ( location . country_code ) {
138- onSelectLocation ( location . country_code . toLowerCase ( ) , location . name ) ;
139- toast . success ( `Selected ${ location . name } (${ location . country_code . toUpperCase ( ) } )` ) ;
140- onClose ( ) ;
141- }
139+ onSelectLocation ( location ) ;
140+ const label = location . location_type === 'country'
141+ ? `${ location . name } (${ location . country_code . toUpperCase ( ) } )`
142+ : `${ location . name } (${ location . location_type } )` ;
143+ toast . success ( `Selected ${ label } ` ) ;
144+ onClose ( ) ;
142145 } ;
143146
144147 const handleBackdropClick = ( e : React . MouseEvent < HTMLDivElement > ) => {
@@ -243,15 +246,27 @@ const LocationSelectorModal: React.FC<LocationSelectorModalProps> = ({
243246 key = { location . location_id }
244247 onClick = { ( ) => handleSelectLocation ( location ) }
245248 className = { `bg-gray-750 rounded-lg p-4 border transition-all duration-200 text-left hover:scale-105 hover:shadow-lg ${
246- currentCountryCode ?. toLowerCase ( ) === location . country_code ?. toLowerCase ( )
249+ ( currentLocationId && currentLocationId === location . location_id ) ||
250+ ( ! currentLocationId && currentCountryCode ?. toLowerCase ( ) === location . country_code ?. toLowerCase ( ) && location . location_type === 'country' )
247251 ? 'border-teal-500 bg-teal-900/30'
248252 : 'border-gray-600 hover:border-teal-500'
249253 } `}
250254 >
251255 < div className = "flex items-center justify-between mb-3" >
252- < h3 className = "font-medium text-gray-100 truncate flex-1" title = { location . name } >
253- { location . name }
254- </ h3 >
256+ < div className = "flex items-center gap-2 min-w-0 flex-1" >
257+ < h3 className = "font-medium text-gray-100 truncate" title = { location . name } >
258+ { location . name }
259+ </ h3 >
260+ < span className = { `text-[10px] font-medium px-1.5 py-0.5 rounded flex-shrink-0 ${
261+ location . location_type === 'city'
262+ ? 'bg-blue-900/50 text-blue-300 border border-blue-700/50'
263+ : location . location_type === 'region'
264+ ? 'bg-yellow-900/50 text-yellow-300 border border-yellow-700/50'
265+ : 'bg-gray-700 text-gray-400 border border-gray-600'
266+ } `} >
267+ { location . location_type }
268+ </ span >
269+ </ div >
255270 < span className = "bg-teal-900 text-teal-300 text-xs font-medium px-2 py-1 rounded border border-teal-700 ml-2 flex-shrink-0" >
256271 { location . provider_count }
257272 </ span >
0 commit comments