feat: implement auto entries rates re-calculation after change the exchange rate

This commit is contained in:
Ahmed Bouhuolia
2024-01-14 14:44:48 +02:00
parent 2cb8c2932f
commit 2b03ac7f16
24 changed files with 522 additions and 241 deletions

View File

@@ -6,7 +6,9 @@ function getRandomItemFromArray(arr) {
const randomIndex = Math.floor(Math.random() * arr.length);
return arr[randomIndex];
}
function delay(t, val) {
return new Promise((resolve) => setTimeout(resolve, t, val));
}
/**
* Retrieves tax rates.
* @param {number} customerId - Customer id.
@@ -18,12 +20,15 @@ export function useExchangeRate(
) {
return useQuery(
[QUERY_TYPES.EXCHANGE_RATE, fromCurrency, toCurrency],
() =>
Promise.resolve({
async () => {
await delay(100);
return {
from_currency: fromCurrency,
to_currency: toCurrency,
exchange_rate: getRandomItemFromArray([4.231, 2.231]),
}),
exchange_rate: 1.00,
};
},
props,
);
}