feat (invoice detail): deatil exhange rate item.

This commit is contained in:
elforjani13
2022-02-23 18:35:54 +02:00
parent 22eb7a1cc1
commit e0126018b8
4 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import React from 'react';
import { DetailItem } from 'components';
import intl from 'react-intl-universal';
import { useSelector } from 'react-redux';
import { createSelector } from 'reselect';
import { isEqual } from 'lodash';
const organizationBaseCurrecy = createSelector(
(state) => {
const tenantId = state.authentication.tenantId;
return state.organizations.data[tenantId];
},
(organization) => organization?.base_currency,
);
export function ExchangeRateDetailItem({
// #ownProps
exchangeRate,
toCurrency,
}) {
const fromCurrency = useSelector(organizationBaseCurrecy);
if (isEqual(fromCurrency, toCurrency)) {
return null;
}
return (
<DetailItem label={intl.get('invoice.details.exchange_rate')}>
1 {fromCurrency} = {exchangeRate} {toCurrency}
</DetailItem>
);
}