feat(webapp): hook up latest exchange rate api

This commit is contained in:
Ahmed Bouhuolia
2024-01-28 18:48:35 +02:00
parent 1b20d1b073
commit 1740226294
2 changed files with 20 additions and 28 deletions

View File

@@ -1,6 +1,5 @@
import { useExchangeRate } from '@/hooks/query';
import { useCurrentOrganization } from '@/hooks/state';
import React from 'react';
import { useLatestExchangeRate } from '@/hooks/query';
interface AutoExchangeRateProviderProps {
children: React.ReactNode;
@@ -18,15 +17,15 @@ const AutoExchangeRateContext = React.createContext(
function AutoExchangeRateProvider({ children }: AutoExchangeRateProviderProps) {
const [autoExRateCurrency, setAutoExRateCurrency] =
React.useState<string>('');
const currentOrganization = useCurrentOrganization();
// Retrieves the exchange rate.
const { data: autoExchangeRate, isLoading: isAutoExchangeRateLoading } =
useExchangeRate(autoExRateCurrency, currentOrganization.base_currency, {
enabled: Boolean(currentOrganization.base_currency && autoExRateCurrency),
useLatestExchangeRate(autoExRateCurrency, {
enabled: Boolean(autoExRateCurrency),
refetchOnWindowFocus: false,
staleTime: 0,
cacheTime: 0,
retry: 0,
});
const value = {