11import L , { Map as LeafletMap } from 'leaflet' ;
22import { MapInterface } from '../../createMap/mapInterface' ;
3- import { ListItemClickListener , SearchApiInterface , SearchLocationListItem , SearchUiInterface } from '../searchInterface' ;
3+ import { ListItemClickListener , PlaceObject , SearchApiInterface , SearchUiInterface } from '../searchInterface' ;
44import { SearchOptions } from '../createSearchInterface' ;
55
66export class SearchUi implements SearchUiInterface {
@@ -15,8 +15,8 @@ export class SearchUi implements SearchUiInterface {
1515 private listenForInput ( ) : void {
1616 const debouncedSearch = this . debounce ( ( value : string ) => {
1717 this . searchApi . search ( value )
18- . then ( ( data : any ) => {
19- console . log ( data ) ;
18+ . then ( ( data : PlaceObject [ ] ) => {
19+ this . setSearchListItems ( data ) ;
2020 } ) ;
2121 } , 500 ) ;
2222
@@ -32,7 +32,7 @@ export class SearchUi implements SearchUiInterface {
3232 return this ;
3333 }
3434
35- public setSearchListItems ( items : SearchLocationListItem [ ] ) : this {
35+ public setSearchListItems ( items : PlaceObject [ ] ) : this {
3636 const listContainer = this . getList ( ) ;
3737 if ( ! listContainer ) {
3838 throw new Error ( 'List container not found' ) ;
@@ -44,13 +44,13 @@ export class SearchUi implements SearchUiInterface {
4444 listContainer . innerHTML = '' ;
4545 }
4646
47- items . forEach ( item => {
47+ items . forEach ( ( item : PlaceObject ) => {
4848 const listItem = this . createListItem ( item ) ;
4949
5050 listItem . addEventListener ( 'click' , ( ) => {
5151 this . itemClickListeners . forEach ( listener => listener ( item ) ) ;
5252 if ( this . input ) {
53- this . input . value = item . title ;
53+ this . input . value = item . address as string ;
5454 this . input . focus ( ) ;
5555 }
5656
@@ -63,9 +63,10 @@ export class SearchUi implements SearchUiInterface {
6363 return this ;
6464 }
6565
66- private createListItem ( item : SearchLocationListItem ) : HTMLLIElement {
66+ private createListItem ( item : PlaceObject ) : HTMLLIElement {
67+ console . log ( item ) ;
6768 const li = document . createElement ( 'li' ) ;
68- li . innerHTML = `<span>${ item . title } </span>` ;
69+ li . innerHTML = `<span>${ item . address } </span>` ;
6970
7071 return li ;
7172 }
0 commit comments