diff --git a/src/components/DetailExchangeRate.js b/src/components/DetailExchangeRate.js index 2b7399e99..636db4297 100644 --- a/src/components/DetailExchangeRate.js +++ b/src/components/DetailExchangeRate.js @@ -1,33 +1,34 @@ import React from 'react'; -import { DetailItem } from 'components'; import intl from 'react-intl-universal'; - -import { useSelector } from 'react-redux'; -import { createSelector } from 'reselect'; +import * as R from 'ramda'; +import { DetailItem } from 'components'; import { isEqual } from 'lodash'; -const organizationBaseCurrecy = createSelector( - (state) => { - const tenantId = state.authentication.tenantId; - return state.organizations.data[tenantId]; - }, - (organization) => organization?.base_currency, -); +import withCurrentOrganization from 'containers/Organization/withCurrentOrganization'; -export function ExchangeRateDetailItem({ - // #ownProps +/** + * Detail exchange rate item. + * @param {*} param0 + * @param {*} param1 + * @returns + */ +function DetailExchangeRate({ exchangeRate, toCurrency, + // #withCurrentOrganization + organization: { base_currency }, }) { - const fromCurrency = useSelector(organizationBaseCurrecy); - - if (isEqual(fromCurrency, toCurrency)) { + if (isEqual(base_currency, toCurrency)) { return null; } return ( - 1 {fromCurrency} = {exchangeRate} {toCurrency} + 1 {base_currency} = {exchangeRate} {toCurrency} ); } + +export const ExchangeRateDetailItem = R.compose(withCurrentOrganization())( + DetailExchangeRate, +);