Skip to content

Commit

Permalink
Merge pull request #138 from valory-xyz/mohan/share-on-twitter
Browse files Browse the repository at this point in the history
feat: share first reward on twitter
  • Loading branch information
mohandast52 authored May 28, 2024
2 parents 549d4c8 + e0b21be commit 533211f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions frontend/components/Main/MainRewards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ const DisplayRewards = () => {
);
};

const SHARE_TEXT = `I just earned my first reward through the Operate app powered by #olas!\n\nDownload the Pearl app:`;
const OPERATE_URL = 'https://olas.network/operate?pearl=first-reward';

const NotifyRewards = () => {
const { isEligibleForRewards, availableRewardsForEpochEth } = useReward();
const { totalOlasBalance } = useBalance();
Expand Down Expand Up @@ -119,6 +122,16 @@ const NotifyRewards = () => {
store?.set?.('firstRewardNotificationShown', true);
}, [store]);

const onTwitterShare = useCallback(() => {
const encodedText = encodeURIComponent(SHARE_TEXT);
const encodedURL = encodeURIComponent(OPERATE_URL);

window.open(
`https://twitter.com/intent/tweet?text=${encodedText}&url=${encodedURL}`,
'_blank',
);
}, []);

if (!canShowNotification) return null;

return (
Expand All @@ -133,8 +146,7 @@ const NotifyRewards = () => {
block
size="large"
className="mt-8"
disabled
style={{ display: 'none' }} // TODO: add twitter share functionality
onClick={onTwitterShare}
>
<Flex align="center" justify="center" gap={2}>
Share on
Expand Down

0 comments on commit 533211f

Please sign in to comment.