allow tips in euros
This commit is contained in:
parent
631d3cc1f3
commit
fe9b33e42b
4 changed files with 31 additions and 10 deletions
|
@ -308,7 +308,7 @@ export function CommentCreate(props: Props) {
|
||||||
const tipParams: TipParams = { tipAmount: Math.round(tipAmount * 100) / 100, tipChannelName, channelClaimId };
|
const tipParams: TipParams = { tipAmount: Math.round(tipAmount * 100) / 100, tipChannelName, channelClaimId };
|
||||||
const userParams: UserParams = { activeChannelName, activeChannelId: activeChannelClaimId };
|
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;
|
const { payment_intent_id } = customerTipResponse;
|
||||||
|
|
||||||
handleCreateComment(null, payment_intent_id, stripeEnvironment);
|
handleCreateComment(null, payment_intent_id, stripeEnvironment);
|
||||||
|
|
|
@ -43,6 +43,7 @@ const select = (state, props) => {
|
||||||
instantTipMax: selectClientSetting(state, SETTINGS.INSTANT_PURCHASE_MAX),
|
instantTipMax: selectClientSetting(state, SETTINGS.INSTANT_PURCHASE_MAX),
|
||||||
isPending: selectIsSendingSupport(state),
|
isPending: selectIsSendingSupport(state),
|
||||||
title: selectTitleForUri(state, uri),
|
title: selectTitleForUri(state, uri),
|
||||||
|
preferredCurrency: selectClientSetting(state, SETTINGS.PREFERRED_CURRENCY),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ type Props = {
|
||||||
doSendCashTip: (TipParams, boolean, UserParams, string, ?string) => string,
|
doSendCashTip: (TipParams, boolean, UserParams, string, ?string) => string,
|
||||||
doSendTip: (SupportParams, boolean) => void, // function that comes from lbry-redux
|
doSendTip: (SupportParams, boolean) => void, // function that comes from lbry-redux
|
||||||
setAmount?: (number) => void,
|
setAmount?: (number) => void,
|
||||||
|
preferredCurrency?: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function WalletSendTip(props: Props) {
|
export default function WalletSendTip(props: Props) {
|
||||||
|
@ -75,6 +76,7 @@ export default function WalletSendTip(props: Props) {
|
||||||
doSendCashTip,
|
doSendCashTip,
|
||||||
doSendTip,
|
doSendTip,
|
||||||
setAmount,
|
setAmount,
|
||||||
|
preferredCurrency,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
/** WHAT TAB TO SHOW **/
|
/** WHAT TAB TO SHOW **/
|
||||||
|
@ -118,8 +120,9 @@ export default function WalletSendTip(props: Props) {
|
||||||
confirmLabel = __('Boosting');
|
confirmLabel = __('Boosting');
|
||||||
break;
|
break;
|
||||||
case TAB_FIAT:
|
case TAB_FIAT:
|
||||||
explainerText = __('Show this channel your appreciation by sending a donation in USD. ');
|
explainerText = __('Show this channel your appreciation by sending a donation in %currencyToUse%. ',
|
||||||
confirmLabel = __('Tipping Fiat (USD)');
|
{ currencyToUse: preferredCurrency});
|
||||||
|
confirmLabel = __('Tipping %currencyToUse%', { currencyToUse: preferredCurrency });
|
||||||
break;
|
break;
|
||||||
case TAB_LBC:
|
case TAB_LBC:
|
||||||
explainerText = __('Show this channel your appreciation by sending a donation of Credits. ');
|
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 };
|
const userParams: UserParams = { activeChannelName, activeChannelId };
|
||||||
|
|
||||||
// hit backend to send tip
|
// hit backend to send tip
|
||||||
doSendCashTip(tipParams, !activeChannelId || incognito, userParams, claimId, stripeEnvironment);
|
doSendCashTip(tipParams, !activeChannelId || incognito, userParams, claimId, stripeEnvironment, preferredCurrency);
|
||||||
doHideModal();
|
doHideModal();
|
||||||
}
|
}
|
||||||
// if it's a boost (?)
|
// if it's a boost (?)
|
||||||
|
@ -224,7 +227,7 @@ export default function WalletSendTip(props: Props) {
|
||||||
case TAB_BOOST:
|
case TAB_BOOST:
|
||||||
return titleText;
|
return titleText;
|
||||||
case TAB_FIAT:
|
case TAB_FIAT:
|
||||||
return __('Send a $%displayAmount% Tip', { displayAmount });
|
return __('Send a %fiatSymbolToUse%%displayAmount% Tip', { displayAmount, fiatSymbolToUse });
|
||||||
case TAB_LBC:
|
case TAB_LBC:
|
||||||
return __('Send a %displayAmount% Credit Tip', { displayAmount });
|
return __('Send a %displayAmount% Credit Tip', { displayAmount });
|
||||||
}
|
}
|
||||||
|
@ -247,6 +250,13 @@ export default function WalletSendTip(props: Props) {
|
||||||
|
|
||||||
const tabButtonProps = { isOnConfirmationPage, activeTab, setActiveTab };
|
const tabButtonProps = { isOnConfirmationPage, activeTab, setActiveTab };
|
||||||
|
|
||||||
|
let fiatIconToUse = ICONS.FINANCE;
|
||||||
|
let fiatSymbolToUse = '$';
|
||||||
|
if (preferredCurrency === 'EUR') {
|
||||||
|
fiatIconToUse = ICONS.EURO;
|
||||||
|
fiatSymbolToUse = '€';
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form onSubmit={handleSubmit}>
|
<Form onSubmit={handleSubmit}>
|
||||||
{/* if there is no LBC balance, show user frontend to get credits */}
|
{/* if there is no LBC balance, show user frontend to get credits */}
|
||||||
|
@ -260,7 +270,7 @@ export default function WalletSendTip(props: Props) {
|
||||||
<div className="section">
|
<div className="section">
|
||||||
{/* tip fiat tab button */}
|
{/* tip fiat tab button */}
|
||||||
{stripeEnvironment && (
|
{stripeEnvironment && (
|
||||||
<TabSwitchButton icon={ICONS.FINANCE} label={__('Tip')} name={TAB_FIAT} {...tabButtonProps} />
|
<TabSwitchButton icon={fiatIconToUse} label={__('Tip')} name={TAB_FIAT} {...tabButtonProps} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* tip LBC tab button */}
|
{/* tip LBC tab button */}
|
||||||
|
@ -298,7 +308,7 @@ export default function WalletSendTip(props: Props) {
|
||||||
<div className="confirm__label">{confirmLabel}</div>
|
<div className="confirm__label">{confirmLabel}</div>
|
||||||
<div className="confirm__value">
|
<div className="confirm__value">
|
||||||
{activeTab === TAB_FIAT ? (
|
{activeTab === TAB_FIAT ? (
|
||||||
<p>{`$ ${(Math.round(tipAmount * 100) / 100).toFixed(2)}`}</p>
|
<p>{`${fiatSymbolToUse} ${(Math.round(tipAmount * 100) / 100).toFixed(2)}`}</p>
|
||||||
) : (
|
) : (
|
||||||
<LbcSymbol postfix={tipAmount} size={22} />
|
<LbcSymbol postfix={tipAmount} size={22} />
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -715,7 +715,14 @@ export const doCheckPendingTxs = () => (dispatch, getState) => {
|
||||||
}, 30000);
|
}, 30000);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const doSendCashTip = (tipParams, anonymous, userParams, claimId, stripeEnvironment, successCallback) => (
|
export const doSendCashTip = (
|
||||||
|
tipParams,
|
||||||
|
anonymous,
|
||||||
|
userParams,
|
||||||
|
claimId,
|
||||||
|
stripeEnvironment,
|
||||||
|
preferredCurrency,
|
||||||
|
successCallback) => (
|
||||||
dispatch
|
dispatch
|
||||||
) => {
|
) => {
|
||||||
Lbryio.call(
|
Lbryio.call(
|
||||||
|
@ -728,7 +735,7 @@ export const doSendCashTip = (tipParams, anonymous, userParams, claimId, stripeE
|
||||||
creator_channel_claim_id: tipParams.channelClaimId,
|
creator_channel_claim_id: tipParams.channelClaimId,
|
||||||
tipper_channel_name: anonymous ? '' : userParams.activeChannelName,
|
tipper_channel_name: anonymous ? '' : userParams.activeChannelName,
|
||||||
tipper_channel_claim_id: anonymous ? '' : userParams.activeChannelId,
|
tipper_channel_claim_id: anonymous ? '' : userParams.activeChannelId,
|
||||||
currency: 'EUR',
|
currency: preferredCurrency || 'USD',
|
||||||
anonymous: anonymous,
|
anonymous: anonymous,
|
||||||
source_claim_id: claimId,
|
source_claim_id: claimId,
|
||||||
environment: stripeEnvironment,
|
environment: stripeEnvironment,
|
||||||
|
@ -736,11 +743,14 @@ export const doSendCashTip = (tipParams, anonymous, userParams, claimId, stripeE
|
||||||
'post'
|
'post'
|
||||||
)
|
)
|
||||||
.then((customerTipResponse) => {
|
.then((customerTipResponse) => {
|
||||||
|
const fiatIconToUse = preferredCurrency === 'USD' ? '$' : '€';
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
doToast({
|
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,
|
tipAmount: tipParams.tipAmount,
|
||||||
tipChannelName: tipParams.tipChannelName,
|
tipChannelName: tipParams.tipChannelName,
|
||||||
|
fiatIconToUse,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue