|
|
|
@ -1,17 +1,24 @@
|
|
|
|
|
import React from 'react';
|
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
|
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
|
|
|
|
|
import { useHistory } from 'react-router-dom';
|
|
|
|
|
|
|
|
|
|
import { Text, Widget } from 'soapbox/components/ui';
|
|
|
|
|
import { useAppSelector, useSoapboxConfig } from 'soapbox/hooks';
|
|
|
|
|
|
|
|
|
|
import SiteWallet from './site_wallet';
|
|
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
|
actionTitle: { id: 'crypto_donate_panel.actions.view', defaultMessage: 'Click to see {count} {count, plural, one {wallet} other {wallets}}' },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
interface ICryptoDonatePanel {
|
|
|
|
|
limit: number,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CryptoDonatePanel: React.FC<ICryptoDonatePanel> = ({ limit = 3 }): JSX.Element | null => {
|
|
|
|
|
const intl = useIntl();
|
|
|
|
|
const history = useHistory();
|
|
|
|
|
|
|
|
|
|
const addresses = useSoapboxConfig().get('cryptoAddresses');
|
|
|
|
|
const siteTitle = useAppSelector((state) => state.instance.title);
|
|
|
|
|
|
|
|
|
@ -19,11 +26,16 @@ const CryptoDonatePanel: React.FC<ICryptoDonatePanel> = ({ limit = 3 }): JSX.Ele
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const more = addresses.size - limit;
|
|
|
|
|
const hasMore = more > 0;
|
|
|
|
|
const handleAction = () => {
|
|
|
|
|
history.push('/donate/crypto');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Widget title={<FormattedMessage id='crypto_donate_panel.heading' defaultMessage='Donate Cryptocurrency' />}>
|
|
|
|
|
<Widget
|
|
|
|
|
title={<FormattedMessage id='crypto_donate_panel.heading' defaultMessage='Donate Cryptocurrency' />}
|
|
|
|
|
onActionClick={handleAction}
|
|
|
|
|
actionTitle={intl.formatMessage(messages.actionTitle, { count: addresses.size })}
|
|
|
|
|
>
|
|
|
|
|
<Text>
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
id='crypto_donate_panel.intro.message'
|
|
|
|
@ -33,18 +45,6 @@ const CryptoDonatePanel: React.FC<ICryptoDonatePanel> = ({ limit = 3 }): JSX.Ele
|
|
|
|
|
</Text>
|
|
|
|
|
|
|
|
|
|
<SiteWallet limit={limit} />
|
|
|
|
|
|
|
|
|
|
{hasMore && (
|
|
|
|
|
<Link className='wtf-panel__expand-btn' to='/donate/crypto'>
|
|
|
|
|
<Text>
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
id='crypto_donate_panel.actions.more'
|
|
|
|
|
defaultMessage='Click to see {count} more {count, plural, one {wallet} other {wallets}}'
|
|
|
|
|
values={{ count: more }}
|
|
|
|
|
/>
|
|
|
|
|
</Text>
|
|
|
|
|
</Link>
|
|
|
|
|
)}
|
|
|
|
|
</Widget>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|