Thank you very much, but I have this error:
I may have forgotten something in your explanations but in any case thank you for your help.
UserError: An error occurred in one of datasetReady callbacks Caused by ReferenceError: xxxxx is not defined
And I have an error on line 8 and 14 at the :
‘await’ has no effect on the type of this expression.
And I also have the XXX which I don’t see what it is for.
And I have the get_DataPraticien function which is transparent.
Here is the complete new code:
import wixData from 'wix-data';
$w.onReady(()=> {
$w('#dataPraticien').onReady(()=>{
$w("#dropdownreg").onChange(async()=>{
let dropdownregValue = $w("#dropdownreg").value;
let resultReg = await search(dropdownregValue);
console.log(resultReg);
});
$w("#dropdowndep").onChange(async()=>{
let dropdowndepValue = $w("#dropdowndep").value;
let resultDep = await search(dropdowndepValue);
console.log(resultDep);
});
xxxxx();
});
});
function get_DataPraticien() {
wixData.query("#dataPraticien")
.limit(1000)
.find()
.then(results => {
const uniqueTitles = getUniqueTitles(results.items);
$w("#dropdownreg").options = buildOptions(uniqueTitles);
});
function getUniqueTitles(items) {
const titlesOnly = items.map(item => item.region);
return [...new Set(titlesOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return { label: curr, value: curr };
});
}
}
export function dropdownreg_change(event, $w) {
dropdowndep();
$w("#dropdowndep").enable();
locationCityFilter();
}
function locationCityFilter() {
$w("#dataPraticien").setFilter(wixData.filter()
.eq("region", $w("#dropdownreg").value)
);
}
function dropdowndep() {
wixData.query("Listepraticiens")
.contains("departement", $w("#dropdownreg").value)
.limit(1000)
.find()
.then(results => {
const uniqueTitles = getUniqueTitles(results.items);
$w("#dropdowndep").options = buildOptions(uniqueTitles);
});
function getUniqueTitles(items) {
const titlesOnly = items.map(item => item.departement);
return [...new Set(titlesOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return { label: curr, value: curr };
});
}
}
function search() {
$w("#dataPraticien").onReady(function () {
$w("#dataPraticien").setFilter(wixData.filter().contains('departement', String($w('#dropdowndep').value))
.and(wixData.filter().contains("region", String($w('#dropdownreg').value))))
.then(count)
});
//CLEAR FILTER 🚀
$w("#button31").onClick(function () {
$w("#dropdowndep").value = undefined;
$w("#dropdownreg").value = undefined;
$w("#dataPraticien").setFilter(wixData.filter());
$w('#nbrpraticiens').hide();
});
//COUNT FUNCTION👍
function count() {
let total = $w('#dataPraticien').getTotalCount();
if (total > 1) {
$w('#nbrpraticiens').text = `${total} praticiens trouvés`;
$w('#nbrpraticiens').show();
}
if (total === 1) {
$w('#nbrpraticiens').text = `${total} praticien trouvé`;
$w('#nbrpraticiens').show();
}
if (total === 0) {
$w('#nbrpraticiens').text = "Nous n'avons pas encore de praticien dans ce secteur";
$w('#nbrpraticiens').show();
}
//SCROLL TO THE TOP WHEN PAGINATION IS CHANGED ⚡
$w("#pagination1").onChange(() => {
$w("#haut").scrollTo();
});
}
}
I may have forgotten something in your explanations but in any case thank you for your help.