2020-09-15 21:46:36 +02:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
|
|
|
import I18nMessage from 'component/i18nMessage';
|
|
|
|
import CreditAmount from 'component/common/credit-amount';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
children: string,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function LbcMessage(props: Props) {
|
|
|
|
let amount;
|
2020-09-17 16:48:25 +02:00
|
|
|
const tokenizedMessage = props.children.replace(
|
2020-11-20 17:56:58 +01:00
|
|
|
/(\d?\.?\d?-?\d?\.?-?\d+?)\s(LBC|LBRY Credits?)/g,
|
2020-09-17 16:48:25 +02:00
|
|
|
(originalString, lbcAmount, thirdArg) => {
|
|
|
|
amount = lbcAmount;
|
|
|
|
return `%lbc%`;
|
|
|
|
}
|
|
|
|
);
|
2020-09-15 21:46:36 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<I18nMessage tokens={{ lbc: amount ? <CreditAmount badge noFormat amount={amount} /> : undefined }}>
|
|
|
|
{/* Catch any rogue LBC's left */}
|
2021-04-30 18:38:53 +02:00
|
|
|
{tokenizedMessage.replace(/\sLBC/g, ' Credits')}
|
2020-09-15 21:46:36 +02:00
|
|
|
</I18nMessage>
|
|
|
|
);
|
|
|
|
}
|