diff --git a/src/app/community/page.tsx b/src/app/community/page.tsx index 0bf8ad7..bf9344d 100644 --- a/src/app/community/page.tsx +++ b/src/app/community/page.tsx @@ -4,8 +4,7 @@ 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 { copyReferralLink, getReferralUrl } from '@/utils'; import { Box, @@ -15,21 +14,17 @@ import { Link, Text, } from '@chakra-ui/react'; +import mixpanel from 'mixpanel-browser'; +import { useEffect } from 'react'; +import { addressAtom } from '@/store/claims.atoms'; const CommunityPage = () => { const referralCode = useAtomValue(referralCodeAtom); + const address = useAtomValue(addressAtom); - 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', - }); - } + useEffect(() => { + mixpanel.track('Community Page open'); + }, []); return ( @@ -110,9 +105,11 @@ const CommunityPage = () => { borderColor="#3B4A3E" > - {!referralCode - ? 'Referral link loading...' - : `https://strkfarm.xyz/r/${referralCode}`} + {!address + ? 'Connect wallet for your referral link' + : !referralCode + ? 'Referral link loading...' + : `${getReferralUrl(referralCode)}`} diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index a706232..5dba832 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -285,8 +285,11 @@ export default function Navbar(props: NavbarProps) { bg: 'color2_50p', }} display={{ base: 'none !important', md: 'flex !important' }} + onClick={() => { + mixpanel.track('community_program_click'); + }} > - Community + ✨ Community Program @@ -310,7 +313,6 @@ export default function Navbar(props: NavbarProps) { bg: 'color2_50p', }} display={{ base: 'none !important', md: 'flex !important' }} - className="glow-button" > Join Telegram @@ -433,10 +435,13 @@ export default function Navbar(props: NavbarProps) { { + onClose(); + mixpanel.track('community_program_click'); + }} mt={4} > - Community + ✨ Community Program diff --git a/src/components/TVL.tsx b/src/components/TVL.tsx index 614c9dd..4318d67 100755 --- a/src/components/TVL.tsx +++ b/src/components/TVL.tsx @@ -2,7 +2,7 @@ import { addressAtom } from '@/store/claims.atoms'; import { referralCodeAtom } from '@/store/referral.store'; import { strategiesAtom } from '@/store/strategies.atoms'; import { dAppStatsAtom, userStatsAtom } from '@/store/utils.atoms'; -import { getReferralUrl } from '@/utils'; +import { copyReferralLink } from '@/utils'; import { CopyIcon } from '@chakra-ui/icons'; import { Box, @@ -18,7 +18,6 @@ import { import { useAtomValue } from 'jotai'; import Link from 'next/link'; import React from 'react'; -import toast from 'react-hot-toast'; const TVL: React.FC = () => { const _strategies = useAtomValue(strategiesAtom); @@ -29,18 +28,6 @@ const TVL: React.FC = () => { const address = useAtomValue(addressAtom); 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', - }); - } - return ( { textDecoration="underline" fontWeight="600" cursor={'pointer'} - onClick={copyReferralLink} + onClick={() => { + copyReferralLink(referralCode); + }} > {referralCode} @@ -124,7 +113,12 @@ const TVL: React.FC = () => { )} {address && ( - + { + copyReferralLink(referralCode); + }} + /> )} diff --git a/src/utils.ts b/src/utils.ts index dfc2c87..81e5379 100755 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,6 +1,7 @@ import { MenuItemProps, MenuListProps } from '@chakra-ui/react'; import { num } from 'starknet'; import { TOKENS } from './constants'; +import toast from 'react-hot-toast'; export function getUniqueStrings(arr: Array) { const _arr: string[] = []; @@ -92,6 +93,9 @@ export function generateReferralCode() { } export function getReferralUrl(referralCode: string) { + if (window.location.origin.includes('app.strkfarm.xyz')) { + return `https://strkfarm.xyz/r/${referralCode}`; + } return `${window.location.origin}/r/${referralCode}`; } @@ -101,3 +105,11 @@ export function getDisplayCurrencyAmount( ) { return Number(Number(amount).toFixed(decimals)).toLocaleString(); } + +export function copyReferralLink(refCode: string) { + navigator.clipboard.writeText(getReferralUrl(refCode)); + + toast.success('Referral link copied to clipboard', { + position: 'bottom-right', + }); +}