Skip to content

Commit

Permalink
feat: implement copy referral link
Browse files Browse the repository at this point in the history
  • Loading branch information
EjembiEmmanuel committed Sep 15, 2024
1 parent 7b2a571 commit 4bb6715
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/app/community/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { NextPage } from 'next';
import React from 'react';
'use client';

import x from '@/assets/x.svg';
import illustration from '@/assets/illustration.svg';
import { useAtomValue } from 'jotai';
import { referralCodeAtom } from '@/store/referral.store';
import toast from 'react-hot-toast';
import { getReferralUrl } from '@/utils';

import {
Box,
Expand All @@ -12,9 +16,21 @@ import {
Text,
} from '@chakra-ui/react';

interface CommunityPage {}
const CommunityPage = () => {
const referralCode = useAtomValue(referralCodeAtom);

function copyReferralLink() {
if (window.location.origin.includes('app.strkfarm.xyz')) {
navigator.clipboard.writeText(`https://strkfarm.xyz/r/${referralCode}`);
} else {
navigator.clipboard.writeText(getReferralUrl(referralCode));
}

toast.success('Referral link copied to clipboard', {
position: 'bottom-right',
});
}

const CommunityPage: NextPage<CommunityPage> = () => {
return (
<Container maxWidth="1000px" margin="0 auto" padding="30px 10px">
<Box
Expand Down Expand Up @@ -94,7 +110,7 @@ const CommunityPage: NextPage<CommunityPage> = () => {
borderColor="#3B4A3E"
>
<Text color="white" fontSize={{ base: '8px', md: '12px' }}>
https://strkfarm.xyz/?referralCode+undefined&refer....
{`https://strkfarm.xyz/r/${referralCode}`}
</Text>
<Button
background="transparent"
Expand All @@ -104,12 +120,13 @@ const CommunityPage: NextPage<CommunityPage> = () => {
_hover={{
bg: 'transparent',
}}
onClick={copyReferralLink}
>
Copy link
</Button>
</Box>
<Link
href={`https://twitter.com/intent/tweet?text=${encodeURIComponent('Check out this awesome community program! Join using my referral link:')}%20https://docs.strkfarm.xyz/p/community/referral-campaign`}
href={`https://twitter.com/intent/tweet?text=${encodeURIComponent('I am proud to be part of @strkfarm community. They are issuing points and NFTs for their active users.\n\nJoin using my referral link:')}%20https://strkfarm.xyz/r/${referralCode}`}
isExternal={true}
display="flex"
alignItems="center"
Expand Down

0 comments on commit 4bb6715

Please sign in to comment.