mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat(server): ability to assign the base currency as api query when getting latest ex. rate
This commit is contained in:
@@ -3,15 +3,23 @@ import { useQuery } from 'react-query';
|
||||
import QUERY_TYPES from './types';
|
||||
import useApiRequest from '../useRequest';
|
||||
|
||||
interface LatestExchangeRateQuery {
|
||||
fromCurrency?: string;
|
||||
toCurrency?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves latest exchange rate.
|
||||
* @param {number} customerId - Customer id.
|
||||
*/
|
||||
export function useLatestExchangeRate(toCurrency: string, props) {
|
||||
export function useLatestExchangeRate(
|
||||
{ toCurrency, fromCurrency }: LatestExchangeRateQuery,
|
||||
props,
|
||||
) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
[QUERY_TYPES.EXCHANGE_RATE, toCurrency],
|
||||
[QUERY_TYPES.EXCHANGE_RATE, toCurrency, fromCurrency],
|
||||
() =>
|
||||
apiRequest
|
||||
.http({
|
||||
@@ -19,6 +27,7 @@ export function useLatestExchangeRate(toCurrency: string, props) {
|
||||
method: 'get',
|
||||
params: {
|
||||
to_currency: toCurrency,
|
||||
from_currency: fromCurrency,
|
||||
},
|
||||
})
|
||||
.then((res) => res.data),
|
||||
|
||||
Reference in New Issue
Block a user