2021-06-24 01:39:44 +02:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2021-11-29 17:53:37 +01:00
|
|
|
import classnames from 'classnames';
|
2021-06-24 01:39:44 +02:00
|
|
|
|
|
|
|
import Typography from '../../ui/typography/typography';
|
|
|
|
import {
|
|
|
|
COLORS,
|
|
|
|
FONT_WEIGHT,
|
|
|
|
TYPOGRAPHY,
|
2021-12-07 04:51:26 +01:00
|
|
|
DISPLAY,
|
|
|
|
FLEX_WRAP,
|
|
|
|
ALIGN_ITEMS,
|
2022-01-10 17:23:53 +01:00
|
|
|
TEXT_ALIGN,
|
2021-06-24 01:39:44 +02:00
|
|
|
} from '../../../helpers/constants/design-system';
|
|
|
|
|
|
|
|
export default function TransactionDetailItem({
|
2021-07-16 17:00:03 +02:00
|
|
|
detailTitle = '',
|
|
|
|
detailText = '',
|
2022-03-17 19:04:01 +01:00
|
|
|
detailTitleColor = COLORS.TEXT_DEFAULT,
|
2021-07-16 17:00:03 +02:00
|
|
|
detailTotal = '',
|
|
|
|
subTitle = '',
|
|
|
|
subText = '',
|
2021-11-29 17:53:37 +01:00
|
|
|
boldHeadings = true,
|
|
|
|
flexWidthValues = false,
|
2021-06-24 01:39:44 +02:00
|
|
|
}) {
|
|
|
|
return (
|
|
|
|
<div className="transaction-detail-item">
|
|
|
|
<div className="transaction-detail-item__row">
|
|
|
|
<Typography
|
2021-07-16 17:00:03 +02:00
|
|
|
color={detailTitleColor}
|
2021-11-29 17:53:37 +01:00
|
|
|
fontWeight={boldHeadings ? FONT_WEIGHT.BOLD : FONT_WEIGHT.NORMAL}
|
2021-08-03 04:08:20 +02:00
|
|
|
variant={TYPOGRAPHY.H6}
|
2021-12-07 04:51:26 +01:00
|
|
|
boxProps={{
|
|
|
|
display: DISPLAY.FLEX,
|
|
|
|
flexWrap: FLEX_WRAP.NO_WRAP,
|
|
|
|
alignItems: ALIGN_ITEMS.CENTER,
|
|
|
|
}}
|
2021-06-24 01:39:44 +02:00
|
|
|
>
|
|
|
|
{detailTitle}
|
|
|
|
</Typography>
|
2021-11-29 17:53:37 +01:00
|
|
|
<div
|
|
|
|
className={classnames('transaction-detail-item__detail-values', {
|
|
|
|
'transaction-detail-item__detail-values--flex-width': flexWidthValues,
|
|
|
|
})}
|
|
|
|
>
|
2021-11-22 18:19:29 +01:00
|
|
|
{detailText && (
|
2022-03-09 16:24:53 +01:00
|
|
|
<Typography variant={TYPOGRAPHY.H6} color={COLORS.TEXT_ALTERNATIVE}>
|
2021-11-22 18:19:29 +01:00
|
|
|
{detailText}
|
|
|
|
</Typography>
|
|
|
|
)}
|
2021-06-30 18:58:18 +02:00
|
|
|
<Typography
|
2022-03-09 16:24:53 +01:00
|
|
|
color={COLORS.TEXT_DEFAULT}
|
2021-11-29 17:53:37 +01:00
|
|
|
fontWeight={boldHeadings ? FONT_WEIGHT.BOLD : FONT_WEIGHT.NORMAL}
|
2021-08-03 04:08:20 +02:00
|
|
|
variant={TYPOGRAPHY.H6}
|
2021-11-24 18:02:53 +01:00
|
|
|
margin={[1, 0, 1, 1]}
|
2022-01-10 17:23:53 +01:00
|
|
|
boxProps={{ textAlign: TEXT_ALIGN.RIGHT }}
|
2021-06-30 18:58:18 +02:00
|
|
|
>
|
2021-11-22 18:19:29 +01:00
|
|
|
{detailTotal}
|
2021-06-24 01:39:44 +02:00
|
|
|
</Typography>
|
2021-11-22 18:19:29 +01:00
|
|
|
</div>
|
2021-06-24 01:39:44 +02:00
|
|
|
</div>
|
|
|
|
<div className="transaction-detail-item__row">
|
2021-07-30 13:35:30 +02:00
|
|
|
{React.isValidElement(subTitle) ? (
|
2021-11-22 18:19:29 +01:00
|
|
|
<div>{subTitle}</div>
|
2021-07-30 13:35:30 +02:00
|
|
|
) : (
|
2022-03-09 16:24:53 +01:00
|
|
|
<Typography variant={TYPOGRAPHY.H7} color={COLORS.TEXT_ALTERNATIVE}>
|
2021-07-30 13:35:30 +02:00
|
|
|
{subTitle}
|
|
|
|
</Typography>
|
|
|
|
)}
|
2021-07-22 18:33:34 +02:00
|
|
|
|
2021-11-29 20:02:54 +01:00
|
|
|
<Typography
|
|
|
|
variant={TYPOGRAPHY.H7}
|
2022-03-09 16:24:53 +01:00
|
|
|
color={COLORS.TEXT_ALTERNATIVE}
|
2021-11-29 20:02:54 +01:00
|
|
|
align="end"
|
|
|
|
className="transaction-detail-item__row-subText"
|
|
|
|
>
|
2021-07-02 21:12:13 +02:00
|
|
|
{subText}
|
|
|
|
</Typography>
|
2021-06-24 01:39:44 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TransactionDetailItem.propTypes = {
|
2021-12-07 17:40:05 +01:00
|
|
|
/**
|
|
|
|
* Detail title text wrapped in Typography component.
|
|
|
|
*/
|
2021-06-24 01:39:44 +02:00
|
|
|
detailTitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
2021-12-07 17:40:05 +01:00
|
|
|
/**
|
|
|
|
* The color of the detailTitle text accepts all Typography color props
|
|
|
|
*/
|
2021-07-16 17:00:03 +02:00
|
|
|
detailTitleColor: PropTypes.string,
|
2021-12-07 17:40:05 +01:00
|
|
|
/**
|
|
|
|
* Text to show on the left of the detailTotal. Wrapped in Typography component.
|
|
|
|
*/
|
2021-06-24 01:39:44 +02:00
|
|
|
detailText: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
2021-12-07 17:40:05 +01:00
|
|
|
/**
|
|
|
|
* Total amount to show. Wrapped in Typography component. Will be bold if boldHeadings is true
|
|
|
|
*/
|
2021-06-24 01:39:44 +02:00
|
|
|
detailTotal: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
2021-12-07 17:40:05 +01:00
|
|
|
/**
|
|
|
|
* Subtitle text. Checks if React.isValidElement before displaying. Displays under detailTitle
|
|
|
|
*/
|
2021-06-24 01:39:44 +02:00
|
|
|
subTitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
2021-12-07 17:40:05 +01:00
|
|
|
/**
|
|
|
|
* Text to show under detailTotal. Wrapped in Typography component.
|
|
|
|
*/
|
2021-06-24 01:39:44 +02:00
|
|
|
subText: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
2021-12-07 17:40:05 +01:00
|
|
|
/**
|
|
|
|
* Whether detailTotal is bold or not. Defaults to true
|
|
|
|
*/
|
2021-11-29 17:53:37 +01:00
|
|
|
boldHeadings: PropTypes.bool,
|
2021-12-07 17:40:05 +01:00
|
|
|
/**
|
|
|
|
* Changes width to auto for transaction-detail-item__detail-values
|
|
|
|
*/
|
2021-11-29 17:53:37 +01:00
|
|
|
flexWidthValues: PropTypes.bool,
|
2021-06-24 01:39:44 +02:00
|
|
|
};
|