improve listing and search on home
This commit is contained in:
@@ -337,8 +337,8 @@ class SearchBox extends HTMLElement {
|
||||
this.selectedCategory = ''
|
||||
this.selectedSubcategory = ''
|
||||
this._expandedCategory = ''
|
||||
this.saveFiltersToStorage()
|
||||
categoryMenu?.classList.remove('open')
|
||||
this.emitFilterChange()
|
||||
this.render()
|
||||
this.setupEventListeners()
|
||||
})
|
||||
@@ -350,8 +350,8 @@ class SearchBox extends HTMLElement {
|
||||
this.selectedCategory = item.dataset.category
|
||||
this.selectedSubcategory = item.dataset.subcategory
|
||||
this._expandedCategory = ''
|
||||
this.saveFiltersToStorage()
|
||||
categoryMenu?.classList.remove('open')
|
||||
this.emitFilterChange()
|
||||
this.render()
|
||||
this.setupEventListeners()
|
||||
})
|
||||
@@ -366,7 +366,7 @@ class SearchBox extends HTMLElement {
|
||||
this.useCurrentLocation = false
|
||||
this.selectedCountry = e.target.value
|
||||
}
|
||||
this.saveFiltersToStorage()
|
||||
this.emitFilterChange()
|
||||
this.render()
|
||||
this.setupEventListeners()
|
||||
}
|
||||
@@ -377,7 +377,7 @@ class SearchBox extends HTMLElement {
|
||||
// Radius select handler (both desktop and mobile)
|
||||
const handleRadiusChange = (e) => {
|
||||
this.selectedRadius = parseInt(e.target.value)
|
||||
this.saveFiltersToStorage()
|
||||
this.emitFilterChange()
|
||||
}
|
||||
|
||||
radiusSelect?.addEventListener('change', handleRadiusChange)
|
||||
@@ -410,6 +410,28 @@ class SearchBox extends HTMLElement {
|
||||
measurer.remove()
|
||||
}
|
||||
|
||||
getFilterDetails() {
|
||||
return {
|
||||
query: this.searchQuery,
|
||||
category: this.selectedCategory,
|
||||
subcategory: this.selectedSubcategory,
|
||||
country: this.selectedCountry,
|
||||
useCurrentLocation: this.useCurrentLocation,
|
||||
lat: this.currentLat,
|
||||
lng: this.currentLng,
|
||||
radius: this.selectedRadius
|
||||
}
|
||||
}
|
||||
|
||||
emitFilterChange() {
|
||||
this.saveFiltersToStorage()
|
||||
|
||||
this.dispatchEvent(new CustomEvent('filter-change', {
|
||||
bubbles: true,
|
||||
detail: this.getFilterDetails()
|
||||
}))
|
||||
}
|
||||
|
||||
handleSearch() {
|
||||
const params = new URLSearchParams()
|
||||
|
||||
@@ -432,14 +454,7 @@ class SearchBox extends HTMLElement {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
detail: {
|
||||
query: this.searchQuery,
|
||||
category: this.selectedCategory,
|
||||
subcategory: this.selectedSubcategory,
|
||||
country: this.selectedCountry,
|
||||
useCurrentLocation: this.useCurrentLocation,
|
||||
lat: this.currentLat,
|
||||
lng: this.currentLng,
|
||||
radius: this.selectedRadius,
|
||||
...this.getFilterDetails(),
|
||||
params: params.toString()
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user