Hey guys,
I have a DB collection showing Exchange Rates like below
And then,
I have a Repeater displaying info from another DB Collection like below
If you see the screenshot above I have a Currency Dropdown which retrieves and shows the Currency Exchange Rates from the ExchangeRates DB Collection as below
Now,
after the exchange rate is displayed I am calculating the amount to be displayed in the repeater. The initial amount is being held in the same DB the repeater info is coming from.
I am using the following code and its working fine
export function dropdown1_change(event) {
$w("#repeater1").forEachItem( ($w) => {
wixData.query("ExchangeRates")
.eq('title', $w("#dropdown1").value)
.find()
.then((results) => {
let Item = results.items[0];
getRates(Item);
});
});
}
async function getRates(Item) {
$w("#exrate").text = Item.exchangeRates;
$w("#currency").text = Item.title;
await $w("#exbox").show();
await $w("#repeater1").forEachItem( ($w) => {
wixData.query("SalesInventory")
.eq('title', $w("#iid").text)
.find()
.then((results) => {
let item = results.items[0];
getFinalRates(item);
});
});
}
async function getFinalRates(item) {
$w("#repeater1").forEachItem( ($w, itemData, index) => {
let adultprice = (Number($w('#exrate').text)) * (Number(itemData.adultPrice));
$w('#aprix').text = String(adultprice);
});
}
I just want to know from the pros if my method is clean or am I getting results but in a messy way ??
Any comments would be helpful