bigbuffet-rw/app/soapbox/features/crypto_donate/components/crypto_donate_panel.tsx

53 lines
1.6 KiB
TypeScript
Raw Normal View History

import React from 'react';
2022-04-18 20:49:17 -07:00
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
import { useHistory } from 'react-router-dom';
2022-03-25 12:42:04 -07:00
import { Text, Widget } from 'soapbox/components/ui';
import { useAppSelector, useSoapboxConfig } from 'soapbox/hooks';
import SiteWallet from './site_wallet';
2022-04-18 20:49:17 -07:00
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 => {
2022-04-18 20:49:17 -07:00
const intl = useIntl();
const history = useHistory();
const addresses = useSoapboxConfig().get('cryptoAddresses');
const siteTitle = useAppSelector((state) => state.instance.title);
if (limit === 0 || addresses.size === 0) {
return null;
}
2022-04-18 20:49:17 -07:00
const handleAction = () => {
history.push('/donate/crypto');
};
return (
2022-04-18 20:49:17 -07:00
<Widget
title={<FormattedMessage id='crypto_donate_panel.heading' defaultMessage='Donate Cryptocurrency' />}
onActionClick={handleAction}
actionTitle={intl.formatMessage(messages.actionTitle, { count: addresses.size })}
>
2022-03-25 12:42:04 -07:00
<Text>
<FormattedMessage
id='crypto_donate_panel.intro.message'
defaultMessage='{siteTitle} accepts cryptocurrency donations to fund our service. Thank you for your support!'
values={{ siteTitle }}
/>
</Text>
<SiteWallet limit={limit} />
</Widget>
);
};
export default CryptoDonatePanel;