2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
2021-10-28 22:25:34 +02:00
|
|
|
import { Form } from 'component/common/form';
|
|
|
|
import { Lbryio } from 'lbryinc';
|
|
|
|
import { parseURI } from 'util/lbryURI';
|
2020-06-08 20:42:29 +02:00
|
|
|
import * as ICONS from 'constants/icons';
|
2020-06-10 00:09:24 +02:00
|
|
|
import * as PAGES from 'constants/pages';
|
2018-03-26 23:32:43 +02:00
|
|
|
import Button from 'component/button';
|
2020-06-08 20:42:29 +02:00
|
|
|
import Card from 'component/common/card';
|
2021-02-09 17:05:56 +01:00
|
|
|
import ChannelSelector from 'component/channelSelector';
|
2021-10-28 22:25:34 +02:00
|
|
|
import classnames from 'classnames';
|
|
|
|
import I18nMessage from 'component/i18nMessage';
|
2020-09-02 22:08:37 +02:00
|
|
|
import LbcSymbol from 'component/common/lbc-symbol';
|
2021-10-28 22:25:34 +02:00
|
|
|
import React from 'react';
|
2020-06-10 00:09:24 +02:00
|
|
|
import usePersistedState from 'effects/use-persisted-state';
|
2021-10-28 22:25:34 +02:00
|
|
|
import WalletTipAmountSelector from 'component/walletTipAmountSelector';
|
2017-09-17 22:33:52 +02:00
|
|
|
|
2021-10-28 22:25:34 +02:00
|
|
|
import { getStripeEnvironment } from 'util/stripe';
|
|
|
|
const stripeEnvironment = getStripeEnvironment();
|
2021-09-09 18:52:03 +02:00
|
|
|
|
2021-07-03 19:19:23 +02:00
|
|
|
const TAB_BOOST = 'TabBoost';
|
|
|
|
const TAB_FIAT = 'TabFiat';
|
|
|
|
const TAB_LBC = 'TabLBC';
|
2022-02-02 17:20:10 +01:00
|
|
|
|
2020-06-15 16:04:44 +02:00
|
|
|
type SupportParams = { amount: number, claim_id: string, channel_id?: string };
|
2021-10-28 22:25:34 +02:00
|
|
|
type TipParams = { tipAmount: number, tipChannelName: string, channelClaimId: string };
|
|
|
|
type UserParams = { activeChannelName: ?string, activeChannelId: ?string };
|
2020-06-15 16:04:44 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
type Props = {
|
2022-02-02 17:20:10 +01:00
|
|
|
activeChannelId?: string,
|
|
|
|
activeChannelName?: string,
|
2018-05-14 18:19:07 +02:00
|
|
|
balance: number,
|
2022-02-02 17:20:10 +01:00
|
|
|
claimId?: string,
|
|
|
|
claimType?: string,
|
|
|
|
channelClaimId?: string,
|
|
|
|
tipChannelName?: string,
|
2021-10-28 22:25:34 +02:00
|
|
|
claimIsMine: boolean,
|
2020-06-15 16:04:44 +02:00
|
|
|
fetchingChannels: boolean,
|
2021-10-28 22:25:34 +02:00
|
|
|
incognito: boolean,
|
2020-04-25 01:53:57 +02:00
|
|
|
instantTipEnabled: boolean,
|
|
|
|
instantTipMax: { amount: number, currency: string },
|
2021-10-28 22:25:34 +02:00
|
|
|
isPending: boolean,
|
|
|
|
isSupport: boolean,
|
|
|
|
title: string,
|
|
|
|
uri: string,
|
2022-02-02 17:20:10 +01:00
|
|
|
isTipOnly?: boolean,
|
|
|
|
hasSelectedTab?: string,
|
2022-02-04 21:59:11 +01:00
|
|
|
customText?: string,
|
2021-10-28 22:25:34 +02:00
|
|
|
doHideModal: () => void,
|
2022-03-28 23:56:40 +02:00
|
|
|
doSendCashTip: (
|
|
|
|
TipParams,
|
|
|
|
anonymous: boolean,
|
|
|
|
UserParams,
|
|
|
|
claimId: string,
|
|
|
|
stripe: ?string,
|
|
|
|
preferredCurrency: string,
|
|
|
|
?(any) => void
|
|
|
|
) => string,
|
2021-10-28 22:25:34 +02:00
|
|
|
doSendTip: (SupportParams, boolean) => void, // function that comes from lbry-redux
|
2022-02-02 17:20:10 +01:00
|
|
|
setAmount?: (number) => void,
|
2022-03-28 23:56:40 +02:00
|
|
|
preferredCurrency: string,
|
2018-03-26 23:32:43 +02:00
|
|
|
};
|
|
|
|
|
2022-02-02 17:20:10 +01:00
|
|
|
export default function WalletSendTip(props: Props) {
|
2020-04-25 01:53:57 +02:00
|
|
|
const {
|
2022-02-02 17:20:10 +01:00
|
|
|
activeChannelId,
|
|
|
|
activeChannelName,
|
2020-04-25 01:53:57 +02:00
|
|
|
balance,
|
2022-02-02 17:20:10 +01:00
|
|
|
claimId,
|
|
|
|
claimType,
|
|
|
|
channelClaimId,
|
|
|
|
tipChannelName,
|
2021-10-28 22:25:34 +02:00
|
|
|
claimIsMine,
|
2020-06-15 16:04:44 +02:00
|
|
|
fetchingChannels,
|
2021-02-09 17:05:56 +01:00
|
|
|
incognito,
|
2021-10-28 22:25:34 +02:00
|
|
|
instantTipEnabled,
|
|
|
|
instantTipMax,
|
|
|
|
isPending,
|
|
|
|
title,
|
|
|
|
uri,
|
2022-02-02 17:20:10 +01:00
|
|
|
isTipOnly,
|
|
|
|
hasSelectedTab,
|
2022-02-04 21:59:11 +01:00
|
|
|
customText,
|
2021-10-28 22:25:34 +02:00
|
|
|
doHideModal,
|
|
|
|
doSendCashTip,
|
|
|
|
doSendTip,
|
2022-02-02 17:20:10 +01:00
|
|
|
setAmount,
|
2022-03-28 23:40:56 +02:00
|
|
|
preferredCurrency,
|
2020-04-25 01:53:57 +02:00
|
|
|
} = props;
|
2021-09-09 18:52:03 +02:00
|
|
|
|
2021-11-05 20:27:43 +01:00
|
|
|
/** WHAT TAB TO SHOW **/
|
2022-03-24 16:33:27 +01:00
|
|
|
// if it's your content, we show boost, otherwise default is LBC
|
|
|
|
const defaultTabToShow = claimIsMine ? TAB_BOOST : TAB_FIAT;
|
2021-09-09 18:52:03 +02:00
|
|
|
|
2021-11-05 20:27:43 +01:00
|
|
|
// loads the default tab if nothing else is there yet
|
2022-02-02 17:20:10 +01:00
|
|
|
const [persistentTab, setPersistentTab] = usePersistedState('send-tip-modal', defaultTabToShow);
|
|
|
|
const [activeTab, setActiveTab] = React.useState(persistentTab);
|
|
|
|
const [hasSelected, setSelected] = React.useState(false);
|
2021-09-09 18:52:03 +02:00
|
|
|
|
2021-11-05 20:27:43 +01:00
|
|
|
/** STATE **/
|
|
|
|
const [tipAmount, setTipAmount] = usePersistedState('comment-support:customTip', 1.0);
|
|
|
|
const [isOnConfirmationPage, setConfirmationPage] = React.useState(false);
|
|
|
|
const [tipError, setTipError] = React.useState();
|
|
|
|
const [disableSubmitButton, setDisableSubmitButton] = React.useState();
|
|
|
|
|
2021-11-05 16:45:19 +01:00
|
|
|
/** CONSTS **/
|
2021-10-28 22:25:34 +02:00
|
|
|
const claimTypeText = getClaimTypeText();
|
|
|
|
const isSupport = claimIsMine || activeTab === TAB_BOOST;
|
2022-03-24 16:33:27 +01:00
|
|
|
|
|
|
|
// text for modal header
|
2022-02-02 17:20:10 +01:00
|
|
|
const titleText = isSupport
|
|
|
|
? __(claimIsMine ? 'Boost Your %claimTypeText%' : 'Boost This %claimTypeText%', { claimTypeText })
|
|
|
|
: __('Tip This %claimTypeText%', { claimTypeText });
|
|
|
|
|
2021-10-28 22:25:34 +02:00
|
|
|
let channelName;
|
|
|
|
try {
|
|
|
|
({ channelName } = parseURI(uri));
|
|
|
|
} catch (e) {}
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2021-10-28 22:25:34 +02:00
|
|
|
// icon to use or explainer text to show per tab
|
|
|
|
let explainerText = '',
|
|
|
|
confirmLabel = '';
|
|
|
|
switch (activeTab) {
|
|
|
|
case TAB_BOOST:
|
|
|
|
explainerText = __(
|
|
|
|
'This refundable boost will improve the discoverability of this %claimTypeText% while active. ',
|
|
|
|
{ claimTypeText }
|
|
|
|
);
|
|
|
|
confirmLabel = __('Boosting');
|
|
|
|
break;
|
|
|
|
case TAB_FIAT:
|
2022-03-28 23:56:40 +02:00
|
|
|
explainerText = __('Show this channel your appreciation by sending a donation in %currencyToUse%. ', {
|
|
|
|
currencyToUse: preferredCurrency,
|
|
|
|
});
|
2022-03-28 23:40:56 +02:00
|
|
|
confirmLabel = __('Tipping %currencyToUse%', { currencyToUse: preferredCurrency });
|
2021-10-28 22:25:34 +02:00
|
|
|
break;
|
|
|
|
case TAB_LBC:
|
|
|
|
explainerText = __('Show this channel your appreciation by sending a donation of Credits. ');
|
|
|
|
confirmLabel = __('Tipping Credit');
|
|
|
|
break;
|
2021-07-03 19:19:23 +02:00
|
|
|
}
|
|
|
|
|
2021-10-28 22:25:34 +02:00
|
|
|
/** FUNCTIONS **/
|
2021-07-05 13:35:17 +02:00
|
|
|
|
2021-08-18 00:34:16 +02:00
|
|
|
function getClaimTypeText() {
|
2022-02-02 17:20:10 +01:00
|
|
|
switch (claimType) {
|
2021-10-28 22:25:34 +02:00
|
|
|
case 'stream':
|
|
|
|
return __('Content');
|
|
|
|
case 'channel':
|
|
|
|
return __('Channel');
|
|
|
|
case 'repost':
|
|
|
|
return __('Repost');
|
|
|
|
case 'collection':
|
|
|
|
return __('List');
|
|
|
|
default:
|
|
|
|
return __('Claim');
|
2021-07-15 14:55:09 +02:00
|
|
|
}
|
|
|
|
}
|
2018-03-26 23:32:43 +02:00
|
|
|
|
2021-09-09 18:52:03 +02:00
|
|
|
// make call to the backend to send lbc or fiat
|
2020-04-25 01:53:57 +02:00
|
|
|
function sendSupportOrConfirm(instantTipMaxAmount = null) {
|
2021-10-28 22:25:34 +02:00
|
|
|
if (!isOnConfirmationPage && (!instantTipMaxAmount || !instantTipEnabled || tipAmount > instantTipMaxAmount)) {
|
|
|
|
setConfirmationPage(true);
|
2020-04-25 01:53:57 +02:00
|
|
|
} else {
|
2021-10-28 22:25:34 +02:00
|
|
|
const supportParams: SupportParams = {
|
|
|
|
amount: tipAmount,
|
2022-02-02 17:20:10 +01:00
|
|
|
claim_id: claimId || '',
|
|
|
|
channel_id: (!incognito && activeChannelId) || undefined,
|
2021-10-28 22:25:34 +02:00
|
|
|
};
|
2021-07-03 19:19:23 +02:00
|
|
|
|
|
|
|
// send tip/boost
|
2021-10-28 22:25:34 +02:00
|
|
|
doSendTip(supportParams, isSupport);
|
|
|
|
doHideModal();
|
2020-04-25 01:53:57 +02:00
|
|
|
}
|
|
|
|
}
|
2020-04-23 18:44:18 +02:00
|
|
|
|
2021-07-03 19:19:23 +02:00
|
|
|
// when the form button is clicked
|
2020-04-25 01:53:57 +02:00
|
|
|
function handleSubmit() {
|
2021-10-28 22:25:34 +02:00
|
|
|
if (!tipAmount || !claimId) return;
|
2021-07-06 22:28:29 +02:00
|
|
|
|
2022-02-02 17:20:10 +01:00
|
|
|
if (setAmount) {
|
|
|
|
setAmount(tipAmount);
|
|
|
|
doHideModal();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-28 22:25:34 +02:00
|
|
|
// send an instant tip (no need to go to an exchange first)
|
|
|
|
if (instantTipEnabled && activeTab !== TAB_FIAT) {
|
|
|
|
if (instantTipMax.currency === 'LBC') {
|
|
|
|
sendSupportOrConfirm(instantTipMax.amount);
|
2020-04-23 18:44:18 +02:00
|
|
|
} else {
|
2021-10-28 22:25:34 +02:00
|
|
|
// Need to convert currency of instant purchase maximum before trying to send support
|
|
|
|
Lbryio.getExchangeRates().then(({ LBC_USD }) => sendSupportOrConfirm(instantTipMax.amount / LBC_USD));
|
2021-08-11 22:58:55 +02:00
|
|
|
}
|
2021-10-28 22:25:34 +02:00
|
|
|
// sending fiat tip
|
|
|
|
} else if (activeTab === TAB_FIAT) {
|
|
|
|
if (!isOnConfirmationPage) {
|
|
|
|
setConfirmationPage(true);
|
2021-08-11 22:58:55 +02:00
|
|
|
} else {
|
2022-02-02 17:20:10 +01:00
|
|
|
const tipParams: TipParams = {
|
|
|
|
tipAmount,
|
|
|
|
tipChannelName: tipChannelName || '',
|
|
|
|
channelClaimId: channelClaimId || '',
|
|
|
|
};
|
2021-10-28 22:25:34 +02:00
|
|
|
const userParams: UserParams = { activeChannelName, activeChannelId };
|
|
|
|
|
|
|
|
// hit backend to send tip
|
2022-03-28 23:56:40 +02:00
|
|
|
doSendCashTip(
|
|
|
|
tipParams,
|
|
|
|
!activeChannelId || incognito,
|
|
|
|
userParams,
|
|
|
|
claimId,
|
|
|
|
stripeEnvironment,
|
|
|
|
preferredCurrency
|
|
|
|
);
|
2021-10-28 22:25:34 +02:00
|
|
|
doHideModal();
|
2021-08-11 22:58:55 +02:00
|
|
|
}
|
2021-10-28 22:25:34 +02:00
|
|
|
// if it's a boost (?)
|
2021-08-11 22:58:55 +02:00
|
|
|
} else {
|
2021-10-28 22:25:34 +02:00
|
|
|
sendSupportOrConfirm();
|
2021-08-11 22:58:55 +02:00
|
|
|
}
|
2017-09-17 22:33:52 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 19:19:23 +02:00
|
|
|
function buildButtonText() {
|
|
|
|
// test if frontend will show up as isNan
|
|
|
|
function isNan(tipAmount) {
|
|
|
|
// testing for NaN ES5 style https://stackoverflow.com/a/35912757/3973137
|
|
|
|
// also sometimes it's returned as a string
|
2021-07-05 13:35:17 +02:00
|
|
|
// eslint-disable-next-line
|
2021-10-28 22:25:34 +02:00
|
|
|
return tipAmount !== tipAmount || tipAmount === 'NaN';
|
2021-07-03 19:19:23 +02:00
|
|
|
}
|
|
|
|
|
2021-08-11 22:58:55 +02:00
|
|
|
function convertToTwoDecimals(number) {
|
|
|
|
return (Math.round(number * 100) / 100).toFixed(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
const amountToShow = activeTab === TAB_FIAT ? convertToTwoDecimals(tipAmount) : tipAmount;
|
|
|
|
|
2021-07-03 19:19:23 +02:00
|
|
|
// if it's a valid number display it, otherwise do an empty string
|
2021-08-11 22:58:55 +02:00
|
|
|
const displayAmount = !isNan(tipAmount) ? amountToShow : '';
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2021-09-09 18:52:03 +02:00
|
|
|
// build button text based on tab
|
2021-10-28 22:25:34 +02:00
|
|
|
switch (activeTab) {
|
|
|
|
case TAB_BOOST:
|
|
|
|
return titleText;
|
|
|
|
case TAB_FIAT:
|
2022-03-28 23:40:56 +02:00
|
|
|
return __('Send a %fiatSymbolToUse%%displayAmount% Tip', { displayAmount, fiatSymbolToUse });
|
2021-10-28 22:25:34 +02:00
|
|
|
case TAB_LBC:
|
|
|
|
return __('Send a %displayAmount% Credit Tip', { displayAmount });
|
2021-07-03 19:19:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-02 17:20:10 +01:00
|
|
|
React.useEffect(() => {
|
|
|
|
if (!hasSelected && hasSelectedTab && activeTab !== hasSelectedTab) {
|
|
|
|
setActiveTab(hasSelectedTab);
|
|
|
|
setSelected(true);
|
|
|
|
}
|
|
|
|
}, [activeTab, hasSelected, hasSelectedTab, setActiveTab]);
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
if (!hasSelectedTab && activeTab !== hasSelectedTab) {
|
|
|
|
setPersistentTab(activeTab);
|
|
|
|
}
|
|
|
|
}, [activeTab, hasSelectedTab, setPersistentTab]);
|
|
|
|
|
2021-10-28 22:25:34 +02:00
|
|
|
/** RENDER **/
|
|
|
|
|
2022-02-02 17:20:10 +01:00
|
|
|
const tabButtonProps = { isOnConfirmationPage, activeTab, setActiveTab };
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2022-03-28 23:40:56 +02:00
|
|
|
let fiatIconToUse = ICONS.FINANCE;
|
|
|
|
let fiatSymbolToUse = '$';
|
|
|
|
if (preferredCurrency === 'EUR') {
|
|
|
|
fiatIconToUse = ICONS.EURO;
|
|
|
|
fiatSymbolToUse = '€';
|
|
|
|
}
|
|
|
|
|
2020-03-13 20:53:53 +01:00
|
|
|
return (
|
2020-06-08 20:42:29 +02:00
|
|
|
<Form onSubmit={handleSubmit}>
|
2021-07-03 19:19:23 +02:00
|
|
|
{/* if there is no LBC balance, show user frontend to get credits */}
|
2021-08-11 22:58:55 +02:00
|
|
|
{/* if there is lbc, the main tip/boost gui with the 3 tabs at the top */}
|
|
|
|
<Card
|
2022-03-24 16:33:27 +01:00
|
|
|
title={titleText}
|
|
|
|
className={'wallet-send-tip-modal'}
|
2021-08-11 22:58:55 +02:00
|
|
|
subtitle={
|
2021-10-28 22:25:34 +02:00
|
|
|
<>
|
2021-08-11 22:58:55 +02:00
|
|
|
{!claimIsMine && (
|
|
|
|
<div className="section">
|
|
|
|
{/* tip fiat tab button */}
|
2022-02-02 17:20:10 +01:00
|
|
|
{stripeEnvironment && (
|
2022-03-28 23:40:56 +02:00
|
|
|
<TabSwitchButton icon={fiatIconToUse} label={__('Tip')} name={TAB_FIAT} {...tabButtonProps} />
|
2022-02-02 17:20:10 +01:00
|
|
|
)}
|
2021-10-28 22:25:34 +02:00
|
|
|
|
2022-03-24 16:33:27 +01:00
|
|
|
{/* tip LBC tab button */}
|
|
|
|
<TabSwitchButton icon={ICONS.LBC} label={__('Tip')} name={TAB_LBC} {...tabButtonProps} />
|
|
|
|
|
2021-10-28 22:25:34 +02:00
|
|
|
{/* support LBC tab button */}
|
2022-02-02 17:20:10 +01:00
|
|
|
{!isTipOnly && (
|
|
|
|
<TabSwitchButton icon={ICONS.TRENDING} label={__('Boost')} name={TAB_BOOST} {...tabButtonProps} />
|
|
|
|
)}
|
2021-08-11 22:58:55 +02:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{/* short explainer under the button */}
|
|
|
|
<div className="section__subtitle">
|
2021-10-28 22:25:34 +02:00
|
|
|
{explainerText}
|
2021-08-11 22:58:55 +02:00
|
|
|
{/* {activeTab === TAB_FIAT && !hasCardSaved && <Button navigate={`/$/${PAGES.SETTINGS_STRIPE_CARD}`} label={__('Add A Card')} button="link" />} */}
|
2022-01-31 17:38:57 +01:00
|
|
|
<Button
|
|
|
|
label={__('Learn more')}
|
|
|
|
button="link"
|
|
|
|
href="https://odysee.com/@OdyseeHelp:b/Monetization-of-Content:3"
|
|
|
|
/>
|
2020-06-10 00:09:24 +02:00
|
|
|
</div>
|
2021-10-28 22:25:34 +02:00
|
|
|
</>
|
2021-08-11 22:58:55 +02:00
|
|
|
}
|
|
|
|
actions={
|
|
|
|
// confirmation modal, allow user to confirm or cancel transaction
|
2021-10-28 22:25:34 +02:00
|
|
|
isOnConfirmationPage ? (
|
2021-08-11 22:58:55 +02:00
|
|
|
<>
|
|
|
|
<div className="section section--padded card--inline confirm__wrapper">
|
2021-03-19 07:47:29 +01:00
|
|
|
<div className="section">
|
2021-08-11 22:58:55 +02:00
|
|
|
<div className="confirm__label">{__('To --[the tip recipient]--')}</div>
|
|
|
|
<div className="confirm__value">{channelName || title}</div>
|
|
|
|
<div className="confirm__label">{__('From --[the tip sender]--')}</div>
|
2022-02-02 17:20:10 +01:00
|
|
|
<div className="confirm__value">{(!incognito && activeChannelName) || __('Anonymous')}</div>
|
2021-10-28 22:25:34 +02:00
|
|
|
<div className="confirm__label">{confirmLabel}</div>
|
2021-08-11 22:58:55 +02:00
|
|
|
<div className="confirm__value">
|
2021-08-18 00:34:16 +02:00
|
|
|
{activeTab === TAB_FIAT ? (
|
2022-03-28 23:40:56 +02:00
|
|
|
<p>{`${fiatSymbolToUse} ${(Math.round(tipAmount * 100) / 100).toFixed(2)}`}</p>
|
2021-08-18 00:34:16 +02:00
|
|
|
) : (
|
|
|
|
<LbcSymbol postfix={tipAmount} size={22} />
|
|
|
|
)}
|
2020-06-15 16:04:44 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-08-11 22:58:55 +02:00
|
|
|
</div>
|
|
|
|
<div className="section__actions">
|
2021-08-18 00:34:16 +02:00
|
|
|
<Button autoFocus onClick={handleSubmit} button="primary" disabled={isPending} label={__('Confirm')} />
|
2021-10-28 22:25:34 +02:00
|
|
|
<Button button="link" label={__('Cancel')} onClick={() => setConfirmationPage(false)} />
|
2021-08-11 22:58:55 +02:00
|
|
|
</div>
|
|
|
|
</>
|
2021-10-28 22:25:34 +02:00
|
|
|
) : !((activeTab === TAB_LBC || activeTab === TAB_BOOST) && balance === 0) ? (
|
2021-08-18 00:34:16 +02:00
|
|
|
<>
|
2021-10-28 22:25:34 +02:00
|
|
|
<ChannelSelector />
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2021-08-11 22:58:55 +02:00
|
|
|
{/* section to pick tip/boost amount */}
|
2021-10-28 22:25:34 +02:00
|
|
|
<WalletTipAmountSelector
|
|
|
|
setTipError={setTipError}
|
|
|
|
tipError={tipError}
|
2022-02-02 17:20:10 +01:00
|
|
|
uri={uri}
|
2021-10-28 22:25:34 +02:00
|
|
|
activeTab={activeTab === TAB_BOOST ? TAB_LBC : activeTab}
|
|
|
|
amount={tipAmount}
|
|
|
|
onChange={(amount) => setTipAmount(amount)}
|
|
|
|
setDisableSubmitButton={setDisableSubmitButton}
|
|
|
|
/>
|
2021-08-11 22:58:55 +02:00
|
|
|
|
|
|
|
{/* send tip/boost button */}
|
|
|
|
<div className="section__actions">
|
|
|
|
<Button
|
|
|
|
autoFocus
|
|
|
|
icon={isSupport ? ICONS.TRENDING : ICONS.SUPPORT}
|
|
|
|
button="primary"
|
|
|
|
type="submit"
|
2021-10-28 22:25:34 +02:00
|
|
|
disabled={fetchingChannels || isPending || tipError || !tipAmount || disableSubmitButton}
|
2022-02-04 21:59:11 +01:00
|
|
|
label={customText || buildButtonText()}
|
2021-08-11 22:58:55 +02:00
|
|
|
/>
|
|
|
|
{fetchingChannels && <span className="help">{__('Loading your channels...')}</span>}
|
|
|
|
</div>
|
|
|
|
</>
|
2021-08-18 00:34:16 +02:00
|
|
|
) : (
|
|
|
|
// if it's LBC and there is no balance, you can prompt to purchase LBC
|
|
|
|
<Card
|
|
|
|
title={
|
2022-03-10 05:02:24 +01:00
|
|
|
<I18nMessage tokens={{ lbc: <LbcSymbol size={22} /> }}>Supporting content requires %lbc%</I18nMessage>
|
2021-08-18 00:34:16 +02:00
|
|
|
}
|
|
|
|
subtitle={
|
|
|
|
<I18nMessage tokens={{ lbc: <LbcSymbol /> }}>
|
2022-03-10 05:02:24 +01:00
|
|
|
With %lbc%, you can send tips to your favorite creators, or help boost their content for more people
|
|
|
|
to see.
|
2021-08-18 00:34:16 +02:00
|
|
|
</I18nMessage>
|
|
|
|
}
|
|
|
|
actions={
|
|
|
|
<div className="section__actions">
|
|
|
|
<Button
|
|
|
|
icon={ICONS.REWARDS}
|
|
|
|
button="primary"
|
|
|
|
label={__('Earn Rewards')}
|
|
|
|
navigate={`/$/${PAGES.REWARDS}`}
|
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
icon={ICONS.BUY}
|
|
|
|
button="secondary"
|
|
|
|
label={__('Buy/Swap Credits')}
|
|
|
|
navigate={`/$/${PAGES.BUY}`}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
/>
|
2021-08-11 22:58:55 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
/>
|
2020-06-08 20:42:29 +02:00
|
|
|
</Form>
|
2020-03-13 20:53:53 +01:00
|
|
|
);
|
2017-09-17 22:33:52 +02:00
|
|
|
}
|
|
|
|
|
2022-02-02 17:20:10 +01:00
|
|
|
type TabButtonProps = {
|
|
|
|
icon: string,
|
|
|
|
label: string,
|
|
|
|
name: string,
|
|
|
|
isOnConfirmationPage: boolean,
|
|
|
|
activeTab: string,
|
|
|
|
setActiveTab: (string) => void,
|
|
|
|
};
|
|
|
|
|
|
|
|
const TabSwitchButton = (tabButtonProps: TabButtonProps) => {
|
|
|
|
const { icon, label, name, isOnConfirmationPage, activeTab, setActiveTab } = tabButtonProps;
|
|
|
|
return (
|
|
|
|
<Button
|
|
|
|
key={name}
|
|
|
|
icon={icon}
|
|
|
|
label={label}
|
|
|
|
button="alt"
|
|
|
|
onClick={() => {
|
|
|
|
const tipInputElement = document.getElementById('tip-input');
|
|
|
|
if (tipInputElement) tipInputElement.focus();
|
|
|
|
if (!isOnConfirmationPage) setActiveTab(name);
|
|
|
|
}}
|
|
|
|
className={classnames('button-toggle', { 'button-toggle--active': activeTab === name })}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|