From 01db5a2faa8189cc097f758f3e1c2532120cc77f Mon Sep 17 00:00:00 2001 From: elforjani13 <39470382+elforjani13@users.noreply.github.com> Date: Sun, 27 Feb 2022 14:23:57 +0200 Subject: [PATCH] feat(invoice detail): add exchange rate detail. --- src/components/DetailExchangeRate.js | 35 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 17 deletions(-) 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, +);