From fe9b33e42ba67708c2f8ba9e680d66e113c2bf5d Mon Sep 17 00:00:00 2001 From: Anthony Date: Mon, 28 Mar 2022 23:40:56 +0200 Subject: [PATCH] allow tips in euros --- ui/component/commentCreate/view.jsx | 2 +- ui/component/walletSendTip/index.js | 1 + ui/component/walletSendTip/view.jsx | 22 ++++++++++++++++------ ui/redux/actions/wallet.js | 16 +++++++++++++--- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/ui/component/commentCreate/view.jsx b/ui/component/commentCreate/view.jsx index 5ef268c41..d9994d90e 100644 --- a/ui/component/commentCreate/view.jsx +++ b/ui/component/commentCreate/view.jsx @@ -308,7 +308,7 @@ export function CommentCreate(props: Props) { const tipParams: TipParams = { tipAmount: Math.round(tipAmount * 100) / 100, tipChannelName, channelClaimId }; const userParams: UserParams = { activeChannelName, activeChannelId: activeChannelClaimId }; - doSendCashTip(tipParams, false, userParams, claimId, stripeEnvironment, (customerTipResponse) => { + doSendCashTip(tipParams, false, userParams, claimId, stripeEnvironment, preferredCurrency, (customerTipResponse) => { const { payment_intent_id } = customerTipResponse; handleCreateComment(null, payment_intent_id, stripeEnvironment); diff --git a/ui/component/walletSendTip/index.js b/ui/component/walletSendTip/index.js index e08987a94..956dfd0a0 100644 --- a/ui/component/walletSendTip/index.js +++ b/ui/component/walletSendTip/index.js @@ -43,6 +43,7 @@ const select = (state, props) => { instantTipMax: selectClientSetting(state, SETTINGS.INSTANT_PURCHASE_MAX), isPending: selectIsSendingSupport(state), title: selectTitleForUri(state, uri), + preferredCurrency: selectClientSetting(state, SETTINGS.PREFERRED_CURRENCY), }; }; diff --git a/ui/component/walletSendTip/view.jsx b/ui/component/walletSendTip/view.jsx index 45755ce0b..92653e49d 100644 --- a/ui/component/walletSendTip/view.jsx +++ b/ui/component/walletSendTip/view.jsx @@ -49,6 +49,7 @@ type Props = { doSendCashTip: (TipParams, boolean, UserParams, string, ?string) => string, doSendTip: (SupportParams, boolean) => void, // function that comes from lbry-redux setAmount?: (number) => void, + preferredCurrency?: boolean, }; export default function WalletSendTip(props: Props) { @@ -75,6 +76,7 @@ export default function WalletSendTip(props: Props) { doSendCashTip, doSendTip, setAmount, + preferredCurrency, } = props; /** WHAT TAB TO SHOW **/ @@ -118,8 +120,9 @@ export default function WalletSendTip(props: Props) { confirmLabel = __('Boosting'); break; case TAB_FIAT: - explainerText = __('Show this channel your appreciation by sending a donation in USD. '); - confirmLabel = __('Tipping Fiat (USD)'); + explainerText = __('Show this channel your appreciation by sending a donation in %currencyToUse%. ', + { currencyToUse: preferredCurrency}); + confirmLabel = __('Tipping %currencyToUse%', { currencyToUse: preferredCurrency }); break; case TAB_LBC: explainerText = __('Show this channel your appreciation by sending a donation of Credits. '); @@ -192,7 +195,7 @@ export default function WalletSendTip(props: Props) { const userParams: UserParams = { activeChannelName, activeChannelId }; // hit backend to send tip - doSendCashTip(tipParams, !activeChannelId || incognito, userParams, claimId, stripeEnvironment); + doSendCashTip(tipParams, !activeChannelId || incognito, userParams, claimId, stripeEnvironment, preferredCurrency); doHideModal(); } // if it's a boost (?) @@ -224,7 +227,7 @@ export default function WalletSendTip(props: Props) { case TAB_BOOST: return titleText; case TAB_FIAT: - return __('Send a $%displayAmount% Tip', { displayAmount }); + return __('Send a %fiatSymbolToUse%%displayAmount% Tip', { displayAmount, fiatSymbolToUse }); case TAB_LBC: return __('Send a %displayAmount% Credit Tip', { displayAmount }); } @@ -247,6 +250,13 @@ export default function WalletSendTip(props: Props) { const tabButtonProps = { isOnConfirmationPage, activeTab, setActiveTab }; + let fiatIconToUse = ICONS.FINANCE; + let fiatSymbolToUse = '$'; + if (preferredCurrency === 'EUR') { + fiatIconToUse = ICONS.EURO; + fiatSymbolToUse = '€'; + } + return (
{/* if there is no LBC balance, show user frontend to get credits */} @@ -260,7 +270,7 @@ export default function WalletSendTip(props: Props) {
{/* tip fiat tab button */} {stripeEnvironment && ( - + )} {/* tip LBC tab button */} @@ -298,7 +308,7 @@ export default function WalletSendTip(props: Props) {
{confirmLabel}
{activeTab === TAB_FIAT ? ( -

{`$ ${(Math.round(tipAmount * 100) / 100).toFixed(2)}`}

+

{`${fiatSymbolToUse} ${(Math.round(tipAmount * 100) / 100).toFixed(2)}`}

) : ( )} diff --git a/ui/redux/actions/wallet.js b/ui/redux/actions/wallet.js index a88b1050d..7010e9ca0 100644 --- a/ui/redux/actions/wallet.js +++ b/ui/redux/actions/wallet.js @@ -715,7 +715,14 @@ export const doCheckPendingTxs = () => (dispatch, getState) => { }, 30000); }; -export const doSendCashTip = (tipParams, anonymous, userParams, claimId, stripeEnvironment, successCallback) => ( +export const doSendCashTip = ( + tipParams, + anonymous, + userParams, + claimId, + stripeEnvironment, + preferredCurrency, + successCallback) => ( dispatch ) => { Lbryio.call( @@ -728,7 +735,7 @@ export const doSendCashTip = (tipParams, anonymous, userParams, claimId, stripeE creator_channel_claim_id: tipParams.channelClaimId, tipper_channel_name: anonymous ? '' : userParams.activeChannelName, tipper_channel_claim_id: anonymous ? '' : userParams.activeChannelId, - currency: 'EUR', + currency: preferredCurrency || 'USD', anonymous: anonymous, source_claim_id: claimId, environment: stripeEnvironment, @@ -736,11 +743,14 @@ export const doSendCashTip = (tipParams, anonymous, userParams, claimId, stripeE 'post' ) .then((customerTipResponse) => { + const fiatIconToUse = preferredCurrency === 'USD' ? '$' : '€'; + dispatch( doToast({ - message: __('You sent $%tipAmount% as a tip to %tipChannelName%, I\'m sure they appreciate it!', { + message: __('You sent %fiatIconToUse%%tipAmount% as a tip to %tipChannelName%, I\'m sure they appreciate it!', { tipAmount: tipParams.tipAmount, tipChannelName: tipParams.tipChannelName, + fiatIconToUse, }), }) );