feat(cashflow): add ExchangeRateMutedField.

This commit is contained in:
elforjani13
2022-03-06 20:20:25 +02:00
parent 5c52f80536
commit 7467b63e54
20 changed files with 382 additions and 58 deletions

View File

@@ -0,0 +1,84 @@
import React from 'react';
import moment from 'moment';
import styled from 'styled-components';
import intl from 'react-intl-universal';
import {
Button,
Popover,
PopoverInteractionKind,
FormGroup,
Position,
Menu,
Classes,
} from '@blueprintjs/core';
import {
If,
ExchangeRateInputGroup,
Icon,
FormattedMessage as T,
} from 'components';
import { isEqual, isUndefined } from 'lodash';
export function ExchangeRateMutedField({
name,
toCurrency,
fromCurrency,
exchangeRate,
...ExchangeRateprops
}) {
if (isEqual(toCurrency, fromCurrency) && !isUndefined(toCurrency)) {
return null;
}
const content = (
<Menu>
<ExchangeRateInputGroup
name={name}
fromCurrency={fromCurrency}
toCurrency={toCurrency}
{...ExchangeRateprops}
/>
</Menu>
);
return (
<ExchangeRateFormGroup
label={`As on ${moment(new Date()).format('YYYY-MM-DD')},`}
>
<Popover
content={content}
interactionKind={PopoverInteractionKind.CLICK}
position={Position.RIGHT_TOP}
modifiers={{
offset: { offset: '0, 4' },
}}
minimal={true}
>
<ExchangeRateButton
className={Classes.MINIMAL}
rightIcon={<Icon icon="pen-18" />}
>
1 {fromCurrency} = {exchangeRate} {toCurrency}
</ExchangeRateButton>
</Popover>
</ExchangeRateFormGroup>
);
}
const ExchangeRateFormGroup = styled(FormGroup)`
.bp3-label {
font-size: 12px !important;
opacity: 0.7;
line-height: 0.1rem;
}
`;
const ExchangeRateButton = styled(Button)`
.bp3-button-text {
display: flex;
font-size: 13px;
font-weight: 500;
color: #0d244a;
}
padding: 0;
`;

View File

@@ -1 +1,2 @@
export * from './ExchangeRateInput';
export * from './ExchangeRateInput';
export * from './ExchangeRateMutedField'