Hey @ahmadnasriya , i really need help implementing mega search feauture: https://www.wix.com/corvid/example/mega-search
I have done all the necessary changes, but still the properties are not displayed, this is how it looks while viewing the site: https://www.saifahamedmasood.com/blank-2
Here are my codes:
Mega search page code
import wixData from 'wix-data';
import { debounce } from 'lodash';
const collectionName = 'realEstateProperties';
const debounceTime = 500;
$w.onReady(function () {
initComps();
initRepeater();
buildFiltersAndPopulateRepeater();
});
async function initComps() {
// populate iLocation dropdown
const res = await wixData.query(collectionName)
.ascending('mainLocation')
.distinct('mainLocation')
.then((locationData) => {
return locationData.items.map((location) => {
return {
value: location,
label: location
}
});
});
$w('#iLocation').options = res;
// change max price according to type selection
$w('#iType').onChange((event) => {
$w('#iMaxPrice').max = event.target.value === 'RENT' ? 20000 : 50000000;
});
// bind all input elements
const componentsTypeArray = ['RadioButtonGroup', 'Dropdown', 'Slider', 'CheckboxGroup'];
const debounceFunction = debounce(buildFiltersAndPopulateRepeater, debounceTime);
componentsTypeArray.forEach((compType) => {
const compArray = $w(compType);
compArray.forEach((comp) => {
comp.onChange((event) => {
debounceFunction();
});
});
});
}
async function buildFiltersAndPopulateRepeater() {
let dataQuery = wixData.query(collectionName);
dataQuery = dataQuery.eq('type', $w('#iType').value);
if ($w('#iLocation').value) {
dataQuery = dataQuery.eq('mainLocation', $w('#iLocation').value);
}
// sliders
dataQuery = dataQuery.ge('squareFeet', $w('#iSize').value);
dataQuery = dataQuery.ge('bedrooms', $w('#iBedrooms').value);
dataQuery = dataQuery.ge('bathrooms', $w('#iBathrooms').value);
dataQuery = dataQuery.ge('levels', $w('#iLevels').value);
dataQuery = dataQuery.ge('price', $w('#iMinPrice').value);
if ($w('#iMaxPrice').value > 0) {
dataQuery = dataQuery.le('price', $w('#iMaxPrice').value);
}
// multiple selection
$w('#iOptions').value.forEach((selectedOption) => {
dataQuery = dataQuery.eq(selectedOption, true);
})
$w('#propertyList').data = await dataQuery.find().then((res) => res.items);
}
function initRepeater() {
$w('#propertyList').onItemReady(($item, itemData) => {
$item('#pImage').src = itemData.thumbnailImage;
$item('#pName').label = itemData.propertyName;
$item('#pLocation').text = itemData.mainLocation;
$item('#pPrice').text = '$' + String(itemData.price);
$item('#pTyp').text = itemData.type;
$item('#pBedrooms').text = String(itemData.bedrooms);
$item('#pLevels').text = String(itemData.levels);
$item('#pBaths').text = String(itemData.bathrooms);
$item('#pSize').text = String(itemData.squareFeet);
});
}
This is how my databse looks:
I’ve also synced it to live!
Can’t figure out where is the problem. Please help me with this, thanks in advance!