mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat (invoice detail): deatil exhange rate item.
This commit is contained in:
33
src/components/DetailExchangeRate.js
Normal file
33
src/components/DetailExchangeRate.js
Normal 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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user