2022-09-09 17:18:04 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { withTranslation } from 'react-i18next';
|
|
|
|
import PaymentIcon from './payment-methods/Icons';
|
|
|
|
import { Tooltip } from '@mui/material';
|
|
|
|
import { paymentMethods, swapDestinations } from './payment-methods/Methods';
|
2022-03-29 23:16:59 +00:00
|
|
|
|
2022-09-09 17:18:04 +00:00
|
|
|
const ns = [{ name: 'not specified', icon: 'notspecified' }];
|
2022-04-17 20:33:43 +00:00
|
|
|
const methods = ns.concat(swapDestinations).concat(paymentMethods);
|
2022-03-29 23:16:59 +00:00
|
|
|
|
2022-04-17 19:14:22 +00:00
|
|
|
class PaymentText extends Component {
|
2022-09-09 17:18:04 +00:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
}
|
|
|
|
|
|
|
|
parseText() {
|
|
|
|
const { t } = this.props;
|
2022-09-09 17:33:29 +00:00
|
|
|
const rows = [];
|
|
|
|
let custom_methods = this.props.text;
|
2022-09-09 17:18:04 +00:00
|
|
|
// Adds icons for each PaymentMethod that matches
|
|
|
|
methods.forEach((method, i) => {
|
|
|
|
if (this.props.text.includes(method.name)) {
|
|
|
|
custom_methods = custom_methods.replace(method.name, '');
|
|
|
|
rows.push(
|
|
|
|
<Tooltip
|
|
|
|
key={`${method.name}-${i}`}
|
|
|
|
placement='top'
|
|
|
|
enterTouchDelay={0}
|
|
|
|
title={t(method.name)}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
display: 'inline-block',
|
|
|
|
width: this.props.size + 2,
|
|
|
|
height: this.props.size,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<PaymentIcon width={this.props.size} height={this.props.size} icon={method.icon} />
|
|
|
|
</div>
|
|
|
|
</Tooltip>,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2022-03-30 14:26:13 +00:00
|
|
|
|
2022-09-09 17:18:04 +00:00
|
|
|
// Adds a Custom icon if there are words that do not match
|
2022-09-09 17:33:29 +00:00
|
|
|
const chars_left = custom_methods
|
2022-09-09 17:18:04 +00:00
|
|
|
.replace(' ', '')
|
|
|
|
.replace(' ', '')
|
|
|
|
.replace(' ', '')
|
|
|
|
.replace(' ', '')
|
|
|
|
.replace(' ', '');
|
|
|
|
|
|
|
|
if (chars_left.length > 0) {
|
|
|
|
rows.push(
|
|
|
|
<Tooltip
|
|
|
|
key={'pushed'}
|
|
|
|
placement='top'
|
|
|
|
enterTouchDelay={0}
|
|
|
|
title={
|
|
|
|
this.props.verbose
|
|
|
|
? this.props.othersText
|
|
|
|
: this.props.othersText + ': ' + custom_methods
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
position: 'relative',
|
|
|
|
display: 'inline-block',
|
|
|
|
width: this.props.size + 2,
|
|
|
|
maxHeight: this.props.size,
|
|
|
|
top: '-1px',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<PaymentIcon
|
|
|
|
width={this.props.size * 1.1}
|
|
|
|
height={this.props.size * 1.1}
|
|
|
|
icon={'custom'}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</Tooltip>,
|
|
|
|
);
|
2022-03-30 14:26:13 +00:00
|
|
|
}
|
2022-03-29 23:16:59 +00:00
|
|
|
|
2022-09-09 17:18:04 +00:00
|
|
|
if (this.props.verbose) {
|
2022-05-02 19:28:34 +00:00
|
|
|
return (
|
2022-09-09 17:18:04 +00:00
|
|
|
<>
|
|
|
|
{rows}{' '}
|
|
|
|
<div style={{ display: 'inline-block' }}>
|
|
|
|
{' '}
|
|
|
|
<span>{custom_methods}</span>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return rows;
|
2022-03-29 23:16:59 +00:00
|
|
|
}
|
2022-09-09 17:18:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div style={{ display: 'flex', alignItems: 'center', flexWrap: 'wrap' }}>
|
|
|
|
{this.parseText()}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2022-05-02 19:28:34 +00:00
|
|
|
}
|
2022-04-17 19:14:22 +00:00
|
|
|
|
2022-05-02 19:28:34 +00:00
|
|
|
export default withTranslation()(PaymentText);
|