vchikalkin 72560b3e8a Components/Calculation: rename load-addon -> irr-addon
config/elements-render: move irr functional to irr-addon
2024-02-12 12:41:20 +03:00

32 lines
873 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { useStore } from '@/stores/hooks';
import { observer } from 'mobx-react-lite';
import styled from 'styled-components';
import { LoadingOutlined } from 'ui/elements/icons';
const TextAddon = styled.span`
font-size: 14px;
`;
const formatter = Intl.NumberFormat('ru', {
minimumFractionDigits: 2,
}).format;
export const IRRAddon = observer(() => {
const { $calculation, $process } = useStore();
if ($process.has('Tarif')) {
return (
<TextAddon>
<LoadingOutlined rev="" />
{' Подбирается тариф...'}
</TextAddon>
);
}
const tarif = $calculation.element('selectTarif').getValue();
if (!tarif) return <TextAddon>Тариф не найден</TextAddon>;
const { min, max } = $calculation.$values.getValue('irrInfo');
return <TextAddon>{`${formatter(min)}% - ${formatter(max)}%`}</TextAddon>;
});