Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: share first reward on twitter #138

Merged
merged 5 commits into from
May 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading