@cloud-ru/ds-uikit-product-price-summary 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/LICENSE +201 -0
- package/README.md +408 -0
- package/dist/cjs/components/ContentBlock/ContentBlock.d.ts +7 -0
- package/dist/cjs/components/ContentBlock/ContentBlock.js +24 -0
- package/dist/cjs/components/ContentBlock/index.d.ts +1 -0
- package/dist/cjs/components/ContentBlock/index.js +17 -0
- package/dist/cjs/components/ContentBlock/styles.module.css +12 -0
- package/dist/cjs/components/PriceSummary/PriceSummary.d.ts +22 -0
- package/dist/cjs/components/PriceSummary/PriceSummary.js +23 -0
- package/dist/cjs/components/PriceSummary/components/CoveredByGrantLabel/CoveredByGrantLabel.d.ts +5 -0
- package/dist/cjs/components/PriceSummary/components/CoveredByGrantLabel/CoveredByGrantLabel.js +16 -0
- package/dist/cjs/components/PriceSummary/components/CoveredByGrantLabel/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/CoveredByGrantLabel/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/CoveredByGrantLabel/styles.module.css +6 -0
- package/dist/cjs/components/PriceSummary/components/DiscountBlock/DiscountBlock.d.ts +5 -0
- package/dist/cjs/components/PriceSummary/components/DiscountBlock/DiscountBlock.js +17 -0
- package/dist/cjs/components/PriceSummary/components/DiscountBlock/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/DiscountBlock/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/DiscountBlock/styles.module.css +16 -0
- package/dist/cjs/components/PriceSummary/components/DiscountPercentCell/DiscountPercentCell.d.ts +5 -0
- package/dist/cjs/components/PriceSummary/components/DiscountPercentCell/DiscountPercentCell.js +16 -0
- package/dist/cjs/components/PriceSummary/components/DiscountPercentCell/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/DiscountPercentCell/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/DiscountPercentCell/styles.module.css +5 -0
- package/dist/cjs/components/PriceSummary/components/Divider/Divider.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/Divider/Divider.js +11 -0
- package/dist/cjs/components/PriceSummary/components/Divider/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/Divider/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/Divider/styles.module.css +6 -0
- package/dist/cjs/components/PriceSummary/components/HeaderBlock/HeaderBlock.d.ts +8 -0
- package/dist/cjs/components/PriceSummary/components/HeaderBlock/HeaderBlock.js +17 -0
- package/dist/cjs/components/PriceSummary/components/HeaderBlock/constants.d.ts +4 -0
- package/dist/cjs/components/PriceSummary/components/HeaderBlock/constants.js +7 -0
- package/dist/cjs/components/PriceSummary/components/HeaderBlock/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/HeaderBlock/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/HeaderBlock/styles.module.css +14 -0
- package/dist/cjs/components/PriceSummary/components/HeaderBlock/types.d.ts +3 -0
- package/dist/cjs/components/PriceSummary/components/HeaderBlock/types.js +2 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceBlock/InvoiceBlock.d.ts +6 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceBlock/InvoiceBlock.js +18 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceBlock/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceBlock/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceBlock/styles.module.css +13 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceDetailsBlock/InvoiceDetailsBlock.d.ts +5 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceDetailsBlock/InvoiceDetailsBlock.js +23 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceDetailsBlock/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceDetailsBlock/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceDetailsBlock/styles.module.css +16 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemBlock/InvoiceItemBlock.d.ts +7 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemBlock/InvoiceItemBlock.js +27 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemBlock/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemBlock/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemBlock/styles.module.css +36 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemLabelCell/InvoiceItemLabelCell.d.ts +5 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemLabelCell/InvoiceItemLabelCell.js +19 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemLabelCell/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemLabelCell/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemLabelCell/styles.module.css +14 -0
- package/dist/cjs/components/PriceSummary/components/PeriodDropdown/PeriodDropdown.d.ts +7 -0
- package/dist/cjs/components/PriceSummary/components/PeriodDropdown/PeriodDropdown.js +26 -0
- package/dist/cjs/components/PriceSummary/components/PeriodDropdown/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/PeriodDropdown/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/PeriodDropdown/styles.module.css +15 -0
- package/dist/cjs/components/PriceSummary/components/TotalValueBlock/TotalValueBlock.d.ts +17 -0
- package/dist/cjs/components/PriceSummary/components/TotalValueBlock/TotalValueBlock.js +22 -0
- package/dist/cjs/components/PriceSummary/components/TotalValueBlock/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/TotalValueBlock/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/TotalValueBlock/styles.module.css +51 -0
- package/dist/cjs/components/PriceSummary/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/index.js +17 -0
- package/dist/cjs/components/PriceSummary/styles.module.css +227 -0
- package/dist/cjs/components/PriceSummarySmall/PriceSummarySmall.d.ts +18 -0
- package/dist/cjs/components/PriceSummarySmall/PriceSummarySmall.js +23 -0
- package/dist/cjs/components/PriceSummarySmall/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummarySmall/index.js +17 -0
- package/dist/cjs/components/PriceSummarySmall/styles.module.css +242 -0
- package/dist/cjs/components/index.d.ts +2 -0
- package/dist/cjs/components/index.js +18 -0
- package/dist/cjs/constants.d.ts +34 -0
- package/dist/cjs/constants.js +37 -0
- package/dist/cjs/helpers/formatters.d.ts +2 -0
- package/dist/cjs/helpers/formatters.js +14 -0
- package/dist/cjs/helpers/index.d.ts +1 -0
- package/dist/cjs/helpers/index.js +17 -0
- package/dist/cjs/hooks/index.d.ts +1 -0
- package/dist/cjs/hooks/index.js +17 -0
- package/dist/cjs/hooks/usePeriodFormat.d.ts +5 -0
- package/dist/cjs/hooks/usePeriodFormat.js +21 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/locale/index.d.ts +107 -0
- package/dist/cjs/locale/index.js +58 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/style.css +673 -0
- package/dist/cjs/types.d.ts +79 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/utils/getAppearanceIcon.d.ts +2 -0
- package/dist/cjs/utils/getAppearanceIcon.js +25 -0
- package/dist/cjs/utils/index.d.ts +1 -0
- package/dist/cjs/utils/index.js +17 -0
- package/dist/esm/components/ContentBlock/ContentBlock.d.ts +7 -0
- package/dist/esm/components/ContentBlock/ContentBlock.js +18 -0
- package/dist/esm/components/ContentBlock/index.d.ts +1 -0
- package/dist/esm/components/ContentBlock/index.js +1 -0
- package/dist/esm/components/ContentBlock/styles.module.css +12 -0
- package/dist/esm/components/PriceSummary/PriceSummary.d.ts +22 -0
- package/dist/esm/components/PriceSummary/PriceSummary.js +17 -0
- package/dist/esm/components/PriceSummary/components/CoveredByGrantLabel/CoveredByGrantLabel.d.ts +5 -0
- package/dist/esm/components/PriceSummary/components/CoveredByGrantLabel/CoveredByGrantLabel.js +10 -0
- package/dist/esm/components/PriceSummary/components/CoveredByGrantLabel/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/CoveredByGrantLabel/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/CoveredByGrantLabel/styles.module.css +6 -0
- package/dist/esm/components/PriceSummary/components/DiscountBlock/DiscountBlock.d.ts +5 -0
- package/dist/esm/components/PriceSummary/components/DiscountBlock/DiscountBlock.js +11 -0
- package/dist/esm/components/PriceSummary/components/DiscountBlock/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/DiscountBlock/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/DiscountBlock/styles.module.css +16 -0
- package/dist/esm/components/PriceSummary/components/DiscountPercentCell/DiscountPercentCell.d.ts +5 -0
- package/dist/esm/components/PriceSummary/components/DiscountPercentCell/DiscountPercentCell.js +10 -0
- package/dist/esm/components/PriceSummary/components/DiscountPercentCell/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/DiscountPercentCell/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/DiscountPercentCell/styles.module.css +5 -0
- package/dist/esm/components/PriceSummary/components/Divider/Divider.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/Divider/Divider.js +5 -0
- package/dist/esm/components/PriceSummary/components/Divider/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/Divider/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/Divider/styles.module.css +6 -0
- package/dist/esm/components/PriceSummary/components/HeaderBlock/HeaderBlock.d.ts +8 -0
- package/dist/esm/components/PriceSummary/components/HeaderBlock/HeaderBlock.js +11 -0
- package/dist/esm/components/PriceSummary/components/HeaderBlock/constants.d.ts +4 -0
- package/dist/esm/components/PriceSummary/components/HeaderBlock/constants.js +4 -0
- package/dist/esm/components/PriceSummary/components/HeaderBlock/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/HeaderBlock/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/HeaderBlock/styles.module.css +14 -0
- package/dist/esm/components/PriceSummary/components/HeaderBlock/types.d.ts +3 -0
- package/dist/esm/components/PriceSummary/components/HeaderBlock/types.js +1 -0
- package/dist/esm/components/PriceSummary/components/InvoiceBlock/InvoiceBlock.d.ts +6 -0
- package/dist/esm/components/PriceSummary/components/InvoiceBlock/InvoiceBlock.js +12 -0
- package/dist/esm/components/PriceSummary/components/InvoiceBlock/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/InvoiceBlock/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/InvoiceBlock/styles.module.css +13 -0
- package/dist/esm/components/PriceSummary/components/InvoiceDetailsBlock/InvoiceDetailsBlock.d.ts +5 -0
- package/dist/esm/components/PriceSummary/components/InvoiceDetailsBlock/InvoiceDetailsBlock.js +17 -0
- package/dist/esm/components/PriceSummary/components/InvoiceDetailsBlock/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/InvoiceDetailsBlock/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/InvoiceDetailsBlock/styles.module.css +16 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemBlock/InvoiceItemBlock.d.ts +7 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemBlock/InvoiceItemBlock.js +21 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemBlock/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemBlock/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemBlock/styles.module.css +36 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemLabelCell/InvoiceItemLabelCell.d.ts +5 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemLabelCell/InvoiceItemLabelCell.js +13 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemLabelCell/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemLabelCell/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemLabelCell/styles.module.css +14 -0
- package/dist/esm/components/PriceSummary/components/PeriodDropdown/PeriodDropdown.d.ts +7 -0
- package/dist/esm/components/PriceSummary/components/PeriodDropdown/PeriodDropdown.js +20 -0
- package/dist/esm/components/PriceSummary/components/PeriodDropdown/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/PeriodDropdown/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/PeriodDropdown/styles.module.css +15 -0
- package/dist/esm/components/PriceSummary/components/TotalValueBlock/TotalValueBlock.d.ts +17 -0
- package/dist/esm/components/PriceSummary/components/TotalValueBlock/TotalValueBlock.js +16 -0
- package/dist/esm/components/PriceSummary/components/TotalValueBlock/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/TotalValueBlock/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/TotalValueBlock/styles.module.css +51 -0
- package/dist/esm/components/PriceSummary/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/index.js +1 -0
- package/dist/esm/components/PriceSummary/styles.module.css +227 -0
- package/dist/esm/components/PriceSummarySmall/PriceSummarySmall.d.ts +18 -0
- package/dist/esm/components/PriceSummarySmall/PriceSummarySmall.js +17 -0
- package/dist/esm/components/PriceSummarySmall/index.d.ts +1 -0
- package/dist/esm/components/PriceSummarySmall/index.js +1 -0
- package/dist/esm/components/PriceSummarySmall/styles.module.css +242 -0
- package/dist/esm/components/index.d.ts +2 -0
- package/dist/esm/components/index.js +2 -0
- package/dist/esm/constants.d.ts +34 -0
- package/dist/esm/constants.js +34 -0
- package/dist/esm/helpers/formatters.d.ts +2 -0
- package/dist/esm/helpers/formatters.js +10 -0
- package/dist/esm/helpers/index.d.ts +1 -0
- package/dist/esm/helpers/index.js +1 -0
- package/dist/esm/hooks/index.d.ts +1 -0
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/usePeriodFormat.d.ts +5 -0
- package/dist/esm/hooks/usePeriodFormat.js +17 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/locale/index.d.ts +107 -0
- package/dist/esm/locale/index.js +55 -0
- package/dist/esm/style.css +673 -0
- package/dist/esm/types.d.ts +79 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/utils/getAppearanceIcon.d.ts +2 -0
- package/dist/esm/utils/getAppearanceIcon.js +22 -0
- package/dist/esm/utils/index.d.ts +1 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/package.json +61 -0
- package/src/components/ContentBlock/ContentBlock.tsx +41 -0
- package/src/components/ContentBlock/index.ts +1 -0
- package/src/components/ContentBlock/styles.module.scss +14 -0
- package/src/components/PriceSummary/PriceSummary.tsx +107 -0
- package/src/components/PriceSummary/components/CoveredByGrantLabel/CoveredByGrantLabel.tsx +32 -0
- package/src/components/PriceSummary/components/CoveredByGrantLabel/index.ts +1 -0
- package/src/components/PriceSummary/components/CoveredByGrantLabel/styles.module.scss +8 -0
- package/src/components/PriceSummary/components/DiscountBlock/DiscountBlock.tsx +42 -0
- package/src/components/PriceSummary/components/DiscountBlock/index.ts +1 -0
- package/src/components/PriceSummary/components/DiscountBlock/styles.module.scss +17 -0
- package/src/components/PriceSummary/components/DiscountPercentCell/DiscountPercentCell.tsx +30 -0
- package/src/components/PriceSummary/components/DiscountPercentCell/index.ts +1 -0
- package/src/components/PriceSummary/components/DiscountPercentCell/styles.module.scss +7 -0
- package/src/components/PriceSummary/components/Divider/Divider.tsx +5 -0
- package/src/components/PriceSummary/components/Divider/index.ts +1 -0
- package/src/components/PriceSummary/components/Divider/styles.module.scss +8 -0
- package/src/components/PriceSummary/components/HeaderBlock/HeaderBlock.tsx +41 -0
- package/src/components/PriceSummary/components/HeaderBlock/constants.ts +4 -0
- package/src/components/PriceSummary/components/HeaderBlock/index.ts +1 -0
- package/src/components/PriceSummary/components/HeaderBlock/styles.module.scss +16 -0
- package/src/components/PriceSummary/components/HeaderBlock/types.ts +5 -0
- package/src/components/PriceSummary/components/InvoiceBlock/InvoiceBlock.tsx +37 -0
- package/src/components/PriceSummary/components/InvoiceBlock/index.ts +1 -0
- package/src/components/PriceSummary/components/InvoiceBlock/styles.module.scss +15 -0
- package/src/components/PriceSummary/components/InvoiceDetailsBlock/InvoiceDetailsBlock.tsx +63 -0
- package/src/components/PriceSummary/components/InvoiceDetailsBlock/index.ts +1 -0
- package/src/components/PriceSummary/components/InvoiceDetailsBlock/styles.module.scss +18 -0
- package/src/components/PriceSummary/components/InvoiceItemBlock/InvoiceItemBlock.tsx +82 -0
- package/src/components/PriceSummary/components/InvoiceItemBlock/index.ts +1 -0
- package/src/components/PriceSummary/components/InvoiceItemBlock/styles.module.scss +42 -0
- package/src/components/PriceSummary/components/InvoiceItemLabelCell/InvoiceItemLabelCell.tsx +37 -0
- package/src/components/PriceSummary/components/InvoiceItemLabelCell/index.ts +1 -0
- package/src/components/PriceSummary/components/InvoiceItemLabelCell/styles.module.scss +16 -0
- package/src/components/PriceSummary/components/PeriodDropdown/PeriodDropdown.tsx +54 -0
- package/src/components/PriceSummary/components/PeriodDropdown/index.ts +1 -0
- package/src/components/PriceSummary/components/PeriodDropdown/styles.module.scss +18 -0
- package/src/components/PriceSummary/components/TotalValueBlock/TotalValueBlock.tsx +82 -0
- package/src/components/PriceSummary/components/TotalValueBlock/index.ts +1 -0
- package/src/components/PriceSummary/components/TotalValueBlock/styles.module.scss +54 -0
- package/src/components/PriceSummary/index.ts +1 -0
- package/src/components/PriceSummary/styles.module.scss +27 -0
- package/src/components/PriceSummarySmall/PriceSummarySmall.tsx +89 -0
- package/src/components/PriceSummarySmall/index.ts +1 -0
- package/src/components/PriceSummarySmall/styles.module.scss +42 -0
- package/src/components/index.ts +2 -0
- package/src/constants.ts +37 -0
- package/src/helpers/formatters.ts +12 -0
- package/src/helpers/index.ts +1 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/usePeriodFormat.ts +30 -0
- package/src/index.ts +5 -0
- package/src/locale/index.ts +59 -0
- package/src/types.ts +93 -0
- package/src/utils/getAppearanceIcon.tsx +26 -0
- package/src/utils/index.ts +1 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Button } from '@cloud-ru/ds-button';
|
|
2
|
+
import { UpdateSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
3
|
+
import { Sun } from '@cloud-ru/ds-loader';
|
|
4
|
+
import { SIZE, Typography, VARIANT } from '@cloud-ru/ds-typography';
|
|
5
|
+
import { PropsWithChildren } from 'react';
|
|
6
|
+
|
|
7
|
+
import { TEST_IDS } from '../../constants';
|
|
8
|
+
import { priceSummaryLocale } from '../../locale';
|
|
9
|
+
import styles from './styles.module.scss';
|
|
10
|
+
|
|
11
|
+
export type ContentBlockProps = {
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
dataError?: boolean;
|
|
14
|
+
onRetry?(): void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function ContentBlock({ loading, dataError, onRetry, children }: PropsWithChildren<ContentBlockProps>) {
|
|
18
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
19
|
+
|
|
20
|
+
if (loading) {
|
|
21
|
+
return (
|
|
22
|
+
<div className={styles.loadingBlock} data-test-id={TEST_IDS.loadingBlock}>
|
|
23
|
+
<Sun size='m' />
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (dataError) {
|
|
29
|
+
return (
|
|
30
|
+
<div className={styles.dataErrorBlock}>
|
|
31
|
+
<Button view='function' icon={<UpdateSVG />} onClick={onRetry} data-test-id={TEST_IDS.contentBlockRetry} />
|
|
32
|
+
|
|
33
|
+
<Typography variant={VARIANT.body} size={SIZE.s}>
|
|
34
|
+
{t('dataError')}
|
|
35
|
+
</Typography>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return children;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ContentBlock';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
|
|
2
|
+
|
|
3
|
+
.loadingBlock {
|
|
4
|
+
display: flex;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
padding: base.$sn-primitive-dimension-4;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.dataErrorBlock {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
align-items: center;
|
|
13
|
+
color: base.$sn-theme-color-available-version-textTertiary;
|
|
14
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Link, LinkProps } from '@cloud-ru/ds-link';
|
|
2
|
+
import { BACKGROUND_PREDEFINED_FILL, backgroundPredefinedFillToAcrylic } from '@cloud-ru/ds-materials';
|
|
3
|
+
import { extractSupportProps, WithSupportProps } from '@cloud-ru/ds-utils';
|
|
4
|
+
import cn from 'classnames';
|
|
5
|
+
|
|
6
|
+
import { priceSummaryLocale } from '../../locale';
|
|
7
|
+
import { DiscountDetails, InvoiceDetails } from '../../types';
|
|
8
|
+
import { ContentBlock, ContentBlockProps } from '../ContentBlock';
|
|
9
|
+
import { DiscountBlock } from './components/DiscountBlock';
|
|
10
|
+
import { HeaderBlock, HeaderBlockProps } from './components/HeaderBlock';
|
|
11
|
+
import { InvoiceBlock } from './components/InvoiceBlock';
|
|
12
|
+
import { TotalValueBlock, TotalValueBlockProps } from './components/TotalValueBlock';
|
|
13
|
+
import styles from './styles.module.scss';
|
|
14
|
+
|
|
15
|
+
export type PriceSummaryProps = WithSupportProps<
|
|
16
|
+
// Раскладку (desktop / mobile) внутренние блоки и адаптивные компоненты @ds/* читают из контекста
|
|
17
|
+
// `@cloud-ru/ds-adaptive` сами — `layoutType` в публичном API не нужен.
|
|
18
|
+
TotalValueBlockProps &
|
|
19
|
+
HeaderBlockProps &
|
|
20
|
+
ContentBlockProps & {
|
|
21
|
+
/** Блок базовой цены и скидок. */
|
|
22
|
+
discount?: DiscountDetails;
|
|
23
|
+
/** Секции детализации заказа в аккордеоне. */
|
|
24
|
+
invoice?: InvoiceDetails[];
|
|
25
|
+
/** Начальное состояние раскрытия аккордеона invoice. */
|
|
26
|
+
invoiceExpandedDefault?: boolean;
|
|
27
|
+
/** Ссылка «Подробнее о расчёте». */
|
|
28
|
+
docsLink?: {
|
|
29
|
+
href?: LinkProps['href'];
|
|
30
|
+
label?: LinkProps['label'];
|
|
31
|
+
};
|
|
32
|
+
/** Дополнительный класс корневого контейнера. */
|
|
33
|
+
className?: string;
|
|
34
|
+
}
|
|
35
|
+
>;
|
|
36
|
+
|
|
37
|
+
export function PriceSummary({
|
|
38
|
+
value,
|
|
39
|
+
totalSumType,
|
|
40
|
+
hint,
|
|
41
|
+
period,
|
|
42
|
+
onPeriodChanged,
|
|
43
|
+
periodOptions,
|
|
44
|
+
promoBadge,
|
|
45
|
+
loading,
|
|
46
|
+
dataError,
|
|
47
|
+
onRetry,
|
|
48
|
+
discount,
|
|
49
|
+
invoice,
|
|
50
|
+
invoiceExpandedDefault = true,
|
|
51
|
+
docsLink,
|
|
52
|
+
className,
|
|
53
|
+
hintAppearance,
|
|
54
|
+
showHintTooltip = false,
|
|
55
|
+
hintTooltipText,
|
|
56
|
+
hintLink,
|
|
57
|
+
showHintLink,
|
|
58
|
+
valueDelta,
|
|
59
|
+
vatType,
|
|
60
|
+
...rest
|
|
61
|
+
}: PriceSummaryProps) {
|
|
62
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
63
|
+
const { appearance, level } = backgroundPredefinedFillToAcrylic(BACKGROUND_PREDEFINED_FILL.NeutralBackground1Level);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<div
|
|
67
|
+
className={cn(styles.priceSummary, className)}
|
|
68
|
+
data-acrylic-appearance={appearance}
|
|
69
|
+
data-acrylic-level={level}
|
|
70
|
+
{...extractSupportProps(rest)}
|
|
71
|
+
>
|
|
72
|
+
<span className={styles.acrylic} aria-hidden data-acrylic-background />
|
|
73
|
+
|
|
74
|
+
<div className={styles.content}>
|
|
75
|
+
<HeaderBlock
|
|
76
|
+
period={period}
|
|
77
|
+
onPeriodChanged={onPeriodChanged}
|
|
78
|
+
periodOptions={periodOptions}
|
|
79
|
+
promoBadge={promoBadge}
|
|
80
|
+
vatType={vatType}
|
|
81
|
+
/>
|
|
82
|
+
|
|
83
|
+
<ContentBlock loading={loading} dataError={dataError} onRetry={onRetry}>
|
|
84
|
+
{discount && <DiscountBlock value={discount} />}
|
|
85
|
+
|
|
86
|
+
<TotalValueBlock
|
|
87
|
+
value={value}
|
|
88
|
+
totalSumType={totalSumType}
|
|
89
|
+
hint={hint}
|
|
90
|
+
hintAppearance={hintAppearance}
|
|
91
|
+
showHintTooltip={showHintTooltip}
|
|
92
|
+
hintTooltipText={hintTooltipText}
|
|
93
|
+
hintLink={hintLink}
|
|
94
|
+
showHintLink={showHintLink}
|
|
95
|
+
valueDelta={valueDelta}
|
|
96
|
+
/>
|
|
97
|
+
|
|
98
|
+
{invoice && invoice.length > 0 && (
|
|
99
|
+
<InvoiceBlock invoice={invoice} invoiceExpandedDefault={invoiceExpandedDefault} />
|
|
100
|
+
)}
|
|
101
|
+
|
|
102
|
+
{docsLink?.href && <Link label={docsLink.label || t('docsLink')} href={docsLink.href} target='_blank' />}
|
|
103
|
+
</ContentBlock>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PromoTag, ROLE_APPEARANCE } from '@cloud-ru/ds-promo-tag';
|
|
2
|
+
import { QuestionTooltip } from '@cloud-ru/ds-tooltip';
|
|
3
|
+
import cn from 'classnames';
|
|
4
|
+
|
|
5
|
+
import { priceSummaryLocale } from '../../../../locale';
|
|
6
|
+
import styles from './styles.module.scss';
|
|
7
|
+
|
|
8
|
+
export type CoveredByGrantLabelProps = {
|
|
9
|
+
covered: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function CoveredByGrantLabel({ covered, className }: CoveredByGrantLabelProps) {
|
|
14
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div className={cn(styles.coveredByGrant, className)}>
|
|
18
|
+
<PromoTag
|
|
19
|
+
appearance={covered ? 'green' : 'neutral'}
|
|
20
|
+
roleAppearance={ROLE_APPEARANCE.Decor}
|
|
21
|
+
label={covered ? t('coveredByGrant') : t('notCoveredByGrant')}
|
|
22
|
+
/>
|
|
23
|
+
<QuestionTooltip
|
|
24
|
+
tip={covered ? t('coveredByGrantTooltip') : t('notCoveredByGrantTooltip')}
|
|
25
|
+
size='xs'
|
|
26
|
+
placement='top'
|
|
27
|
+
trigger='hover'
|
|
28
|
+
tabIndex={-1}
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CoveredByGrantLabel';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { SIZE, Typography, VARIANT } from '@cloud-ru/ds-typography';
|
|
2
|
+
import { Fragment } from 'react';
|
|
3
|
+
|
|
4
|
+
import { formatCurrency } from '../../../../helpers';
|
|
5
|
+
import { priceSummaryLocale } from '../../../../locale';
|
|
6
|
+
import { DiscountDetails } from '../../../../types';
|
|
7
|
+
import { DiscountPercentCell } from '../DiscountPercentCell';
|
|
8
|
+
import styles from './styles.module.scss';
|
|
9
|
+
|
|
10
|
+
export type DiscountBlockProps = {
|
|
11
|
+
value: DiscountDetails;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function DiscountBlock({ value }: DiscountBlockProps) {
|
|
15
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<>
|
|
19
|
+
<div className={styles.discountGrid}>
|
|
20
|
+
<Typography variant={VARIANT.body} size={SIZE.s} as='div'>
|
|
21
|
+
{t('basePrice')}
|
|
22
|
+
</Typography>
|
|
23
|
+
|
|
24
|
+
<Typography variant={VARIANT.label} size={SIZE.m} as='div' className={styles.priceCell}>
|
|
25
|
+
{formatCurrency(value.price)}
|
|
26
|
+
</Typography>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<div className={styles.discountGrid}>
|
|
30
|
+
{value.discounts.map((discount, index) => (
|
|
31
|
+
<Fragment key={index}>
|
|
32
|
+
<DiscountPercentCell discount={discount} />
|
|
33
|
+
|
|
34
|
+
<Typography variant={VARIANT.label} size={SIZE.m} as='div' className={styles.discountCell}>
|
|
35
|
+
{formatCurrency(-Math.abs(discount.value))}
|
|
36
|
+
</Typography>
|
|
37
|
+
</Fragment>
|
|
38
|
+
))}
|
|
39
|
+
</div>
|
|
40
|
+
</>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DiscountBlock';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
|
|
2
|
+
|
|
3
|
+
.discountGrid {
|
|
4
|
+
display: grid;
|
|
5
|
+
grid-template-columns: 1fr 1fr;
|
|
6
|
+
column-gap: base.$sn-primitive-dimension-8;
|
|
7
|
+
color: base.$sn-theme-color-available-version-textSecondary;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.priceCell {
|
|
11
|
+
justify-self: end;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.discountCell {
|
|
15
|
+
justify-self: end;
|
|
16
|
+
color: base.$sn-theme-color-red-text;
|
|
17
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { QuestionTooltip } from '@cloud-ru/ds-tooltip';
|
|
2
|
+
import { SIZE, Typography, VARIANT } from '@cloud-ru/ds-typography';
|
|
3
|
+
|
|
4
|
+
import { formatNumber } from '@cloud-ru/ft-formatters';
|
|
5
|
+
|
|
6
|
+
import { priceSummaryLocale } from '../../../../locale';
|
|
7
|
+
import { DiscountItem } from '../../../../types';
|
|
8
|
+
import styles from './styles.module.scss';
|
|
9
|
+
|
|
10
|
+
export type DiscountPercentCellProps = {
|
|
11
|
+
discount: DiscountItem;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function DiscountPercentCell({ discount }: DiscountPercentCellProps) {
|
|
15
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div className={styles.percentCell}>
|
|
19
|
+
{discount.percent && (
|
|
20
|
+
<>
|
|
21
|
+
<Typography variant={VARIANT.body} size={SIZE.s}>
|
|
22
|
+
{t('discount')} {formatNumber(-Math.abs(discount.percent))}%
|
|
23
|
+
</Typography>
|
|
24
|
+
|
|
25
|
+
{discount.tooltip && <QuestionTooltip tip={discount.tooltip} />}
|
|
26
|
+
</>
|
|
27
|
+
)}
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DiscountPercentCell';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Divider';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
|
|
2
|
+
|
|
3
|
+
.divider {
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 0;
|
|
6
|
+
margin: base.$sn-primitive-dimension-4 0;
|
|
7
|
+
border-top: base.$sn-primitive-strokeWeight-strokeRegular dashed base.$sn-theme-color-neutral-decor;
|
|
8
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { PromoTag, PromoTagProps } from '@cloud-ru/ds-promo-tag';
|
|
2
|
+
import { SIZE, Typography, VARIANT } from '@cloud-ru/ds-typography';
|
|
3
|
+
|
|
4
|
+
import { priceSummaryLocale } from '../../../../locale';
|
|
5
|
+
import { PeriodDropdown, PeriodDropdownProps } from '../PeriodDropdown';
|
|
6
|
+
import { VAT_TYPE } from './constants';
|
|
7
|
+
import styles from './styles.module.scss';
|
|
8
|
+
import { VatType } from './types';
|
|
9
|
+
|
|
10
|
+
export type HeaderBlockProps = PeriodDropdownProps & {
|
|
11
|
+
vatType?: VatType;
|
|
12
|
+
promoBadge?: Pick<PromoTagProps, 'label' | 'appearance'> | string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function HeaderBlock({
|
|
16
|
+
period,
|
|
17
|
+
onPeriodChanged,
|
|
18
|
+
periodOptions,
|
|
19
|
+
promoBadge,
|
|
20
|
+
vatType = VAT_TYPE.Including,
|
|
21
|
+
}: HeaderBlockProps) {
|
|
22
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
{promoBadge && (
|
|
27
|
+
<div className={styles.promoBadge}>
|
|
28
|
+
<PromoTag {...(typeof promoBadge === 'string' ? { label: promoBadge } : promoBadge)} />
|
|
29
|
+
</div>
|
|
30
|
+
)}
|
|
31
|
+
|
|
32
|
+
<div className={styles.headline}>
|
|
33
|
+
<PeriodDropdown period={period} onPeriodChanged={onPeriodChanged} periodOptions={periodOptions} />
|
|
34
|
+
|
|
35
|
+
<Typography variant={VARIANT.body} size={SIZE.m} className={styles.vat}>
|
|
36
|
+
{t(vatType === VAT_TYPE.Including ? 'vat' : 'vatExcluded')}
|
|
37
|
+
</Typography>
|
|
38
|
+
</div>
|
|
39
|
+
</>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './HeaderBlock';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
|
|
2
|
+
|
|
3
|
+
.headline {
|
|
4
|
+
display: flex;
|
|
5
|
+
gap: base.$sn-primitive-dimension-4;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: space-between;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.vat {
|
|
11
|
+
color: base.$sn-theme-color-available-version-textTertiary;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.promoBadge {
|
|
15
|
+
display: flex;
|
|
16
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Accordion } from '@cloud-ru/ds-accordion';
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
|
|
4
|
+
import { TEST_IDS } from '../../../../constants';
|
|
5
|
+
import { priceSummaryLocale } from '../../../../locale';
|
|
6
|
+
import { InvoiceDetails } from '../../../../types';
|
|
7
|
+
import { InvoiceDetailsBlock } from '../InvoiceDetailsBlock';
|
|
8
|
+
import styles from './styles.module.scss';
|
|
9
|
+
|
|
10
|
+
export type InvoiceBlockProps = {
|
|
11
|
+
invoice: InvoiceDetails[];
|
|
12
|
+
invoiceExpandedDefault?: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function InvoiceBlock({ invoice, invoiceExpandedDefault }: InvoiceBlockProps) {
|
|
16
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
17
|
+
|
|
18
|
+
const invoiceBlockId = useId();
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div className={styles.accordion}>
|
|
22
|
+
<Accordion expandedDefault={invoiceExpandedDefault ? invoiceBlockId : undefined}>
|
|
23
|
+
<Accordion.CollapseBlockTertiary
|
|
24
|
+
id={invoiceBlockId}
|
|
25
|
+
title={t('orderDetails')}
|
|
26
|
+
data-test-id={TEST_IDS.orderDetails}
|
|
27
|
+
>
|
|
28
|
+
<div className={styles.accordionContent} data-test-id={TEST_IDS.orderDetailsContent}>
|
|
29
|
+
{invoice.map((invoice, index) => (
|
|
30
|
+
<InvoiceDetailsBlock key={index} invoice={invoice} />
|
|
31
|
+
))}
|
|
32
|
+
</div>
|
|
33
|
+
</Accordion.CollapseBlockTertiary>
|
|
34
|
+
</Accordion>
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InvoiceBlock';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
|
|
2
|
+
|
|
3
|
+
.accordion {
|
|
4
|
+
--space-accordion-collapse-block-secondary-horizontal-padding: 0;
|
|
5
|
+
--space-accordion-collapse-block-secondary-vertical-padding: #{base.$sn-primitive-dimension-8};
|
|
6
|
+
--space-accordion-collapse-block-secondary-gap: #{base.$sn-primitive-dimension-8};
|
|
7
|
+
--border-width-accordion-collapse-block-secondary: 0;
|
|
8
|
+
--accordion-header-padding-vertical: 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.accordionContent {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
gap: base.$sn-primitive-dimension-8;
|
|
15
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { SIZE, Typography, VARIANT } from '@cloud-ru/ds-typography';
|
|
2
|
+
|
|
3
|
+
import { formatCurrency, formatQuantity } from '../../../../helpers';
|
|
4
|
+
import { priceSummaryLocale } from '../../../../locale';
|
|
5
|
+
import { InvoiceDetails } from '../../../../types';
|
|
6
|
+
import { CoveredByGrantLabel } from '../CoveredByGrantLabel';
|
|
7
|
+
import { Divider } from '../Divider';
|
|
8
|
+
import { InvoiceItemBlock } from '../InvoiceItemBlock';
|
|
9
|
+
import styles from './styles.module.scss';
|
|
10
|
+
|
|
11
|
+
export type InvoiceDetailsBlockProps = {
|
|
12
|
+
invoice: InvoiceDetails;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function InvoiceDetailsBlock({ invoice }: InvoiceDetailsBlockProps) {
|
|
16
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
17
|
+
|
|
18
|
+
const primaryItems = invoice.items.filter(item => item.primary);
|
|
19
|
+
const firstValue = primaryItems[0]?.coveredByGrant;
|
|
20
|
+
const allSameValue = primaryItems.length > 0 && primaryItems.every(item => item.coveredByGrant === firstValue);
|
|
21
|
+
|
|
22
|
+
const showBlockLabel = allSameValue && firstValue !== undefined;
|
|
23
|
+
const showItemLabels = !showBlockLabel;
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className={styles.main}>
|
|
27
|
+
{showBlockLabel && <CoveredByGrantLabel covered={firstValue} />}
|
|
28
|
+
|
|
29
|
+
{invoice.title && (
|
|
30
|
+
<>
|
|
31
|
+
<div className={styles.header}>
|
|
32
|
+
<Typography variant={VARIANT.label} size={SIZE.m}>
|
|
33
|
+
{invoice.title}
|
|
34
|
+
</Typography>
|
|
35
|
+
{invoice.quantity && (
|
|
36
|
+
<Typography variant={VARIANT.label} size={SIZE.m}>
|
|
37
|
+
{formatQuantity(invoice.quantity)}
|
|
38
|
+
</Typography>
|
|
39
|
+
)}
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<Divider />
|
|
43
|
+
</>
|
|
44
|
+
)}
|
|
45
|
+
|
|
46
|
+
{invoice.items.map((item, index) => (
|
|
47
|
+
<InvoiceItemBlock key={index} item={item} index={index} showCoveredByGrantLabel={showItemLabels} />
|
|
48
|
+
))}
|
|
49
|
+
|
|
50
|
+
{invoice.price !== undefined && (
|
|
51
|
+
<>
|
|
52
|
+
<Divider />
|
|
53
|
+
|
|
54
|
+
<div className={styles.footer}>
|
|
55
|
+
<Typography variant={VARIANT.label} size={SIZE.m}>
|
|
56
|
+
{t('price')}: {formatCurrency(invoice.price)}
|
|
57
|
+
</Typography>
|
|
58
|
+
</div>
|
|
59
|
+
</>
|
|
60
|
+
)}
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InvoiceDetailsBlock';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
|
|
2
|
+
|
|
3
|
+
.main {
|
|
4
|
+
padding: base.$sn-primitive-dimension-4 base.$sn-primitive-dimension-8;
|
|
5
|
+
border: base.$sn-primitive-strokeWeight-strokeRegular dashed base.$sn-theme-color-neutral-decor;
|
|
6
|
+
border-radius: base.$sn-brand-anatomy-radius-block-m;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.header {
|
|
10
|
+
display: flex;
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.footer {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: flex-end;
|
|
18
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { SIZE, Typography, VARIANT } from '@cloud-ru/ds-typography';
|
|
2
|
+
|
|
3
|
+
import { formatCurrency } from '../../../../helpers';
|
|
4
|
+
import { priceSummaryLocale } from '../../../../locale';
|
|
5
|
+
import { InvoiceItem } from '../../../../types';
|
|
6
|
+
import { CoveredByGrantLabel } from '../CoveredByGrantLabel';
|
|
7
|
+
import { DiscountPercentCell } from '../DiscountPercentCell';
|
|
8
|
+
import { Divider } from '../Divider';
|
|
9
|
+
import { InvoiceItemLabelCell } from '../InvoiceItemLabelCell';
|
|
10
|
+
import styles from './styles.module.scss';
|
|
11
|
+
|
|
12
|
+
export type InvoiceItemBlockProps = {
|
|
13
|
+
item: InvoiceItem;
|
|
14
|
+
index: number;
|
|
15
|
+
showCoveredByGrantLabel?: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export function InvoiceItemBlock({ item, index, showCoveredByGrantLabel }: InvoiceItemBlockProps) {
|
|
19
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
20
|
+
const isEven = (index + 1) % 2 === 0;
|
|
21
|
+
|
|
22
|
+
const isSecondary = item.primary === undefined ? isEven : !item.primary;
|
|
23
|
+
|
|
24
|
+
const getPriceItem = () => {
|
|
25
|
+
if (item.hidePrice) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return item.price !== undefined ? formatCurrency(item.price) : (t as (key: string) => string)('notAvailable');
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<>
|
|
34
|
+
{item.topDivider && <Divider />}
|
|
35
|
+
|
|
36
|
+
{item.coveredByGrant !== undefined && showCoveredByGrantLabel && (
|
|
37
|
+
<CoveredByGrantLabel covered={item.coveredByGrant} />
|
|
38
|
+
)}
|
|
39
|
+
|
|
40
|
+
<div className={styles.itemGrid} data-discount={Boolean(item.discount)}>
|
|
41
|
+
{'label' in item && item.label !== undefined && (
|
|
42
|
+
<>
|
|
43
|
+
<div className={styles.labelCell} data-secondary={isSecondary}>
|
|
44
|
+
<InvoiceItemLabelCell item={item} />
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<Typography
|
|
48
|
+
variant={VARIANT.body}
|
|
49
|
+
size={SIZE.s}
|
|
50
|
+
as='div'
|
|
51
|
+
className={styles.priceCell}
|
|
52
|
+
data-secondary={isSecondary}
|
|
53
|
+
data-price-color={item.priceColor ?? 'default'}
|
|
54
|
+
>
|
|
55
|
+
{getPriceItem()}
|
|
56
|
+
</Typography>
|
|
57
|
+
</>
|
|
58
|
+
)}
|
|
59
|
+
|
|
60
|
+
{item.discount && (
|
|
61
|
+
<>
|
|
62
|
+
<div className={styles.percentCell} data-secondary={isSecondary}>
|
|
63
|
+
<DiscountPercentCell discount={item.discount} />
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<Typography
|
|
67
|
+
variant={VARIANT.body}
|
|
68
|
+
size={SIZE.s}
|
|
69
|
+
as='div'
|
|
70
|
+
className={styles.discountCell}
|
|
71
|
+
data-secondary={isSecondary}
|
|
72
|
+
>
|
|
73
|
+
{formatCurrency(-Math.abs(item.discount.value))}
|
|
74
|
+
</Typography>
|
|
75
|
+
</>
|
|
76
|
+
)}
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
{item.bottomDivider && <Divider />}
|
|
80
|
+
</>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InvoiceItemBlock';
|