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-09-18 05:49:45 +02:00
|
|
|
/(\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 */}
|
2020-09-17 16:48:25 +02:00
|
|
|
{tokenizedMessage.replace(/LBC/g, 'Credits')}
|
2020-09-15 21:46:36 +02:00
|
|
|
</I18nMessage>
|
|
|
|
);
|
|
|
|
}
|