|
| 1 | +import { useState } from 'react' |
| 2 | +import Image from 'next/image' |
| 3 | +import Stack from '@mui/material/Stack' |
| 4 | +import { useTheme } from '@mui/material/styles' |
| 5 | +import OutlinedInput from '@mui/material/OutlinedInput' |
| 6 | +import Card from '@mui/material/Card' |
| 7 | +import CardContent from '@mui/material/CardContent' |
| 8 | +import InputAdornment from '@mui/material/InputAdornment' |
| 9 | +import Button from '@mui/material/Button' |
| 10 | +import ContentCopyRoundedIcon from '@mui/icons-material/ContentCopyRounded' |
| 11 | +import InventoryRoundedIcon from '@mui/icons-material/InventoryRounded' |
| 12 | +import TwitterIcon from '@mui/icons-material/Twitter' |
| 13 | +import Box from '@mui/material/Box' |
| 14 | + |
| 15 | +import { toast } from 'lib/toastify' |
| 16 | +import { useUser } from 'domains/data' |
| 17 | +import { writeText } from 'app/utils/dom/clipboard' |
| 18 | +import { H2, H4, Paragraph } from 'components/Typography' |
| 19 | +import Link from '@mui/material/Link' |
| 20 | + |
| 21 | +import ReferralCard from './ReferralCard' |
| 22 | +import Invitees from './Invitees' |
| 23 | +import Links, { RightLinks } from './Links' |
| 24 | +import useMediaQuery from '@mui/material/useMediaQuery' |
| 25 | + |
| 26 | +const ReferralProgram: FC = () => { |
| 27 | + const theme = useTheme() |
| 28 | + const { didname } = useUser() |
| 29 | + const [copied, setCopied] = useState(false) |
| 30 | + |
| 31 | + const referralLink = 'https://isme.is?inviter=' + (didname?.replace(/\.isme$/, '') || '') |
| 32 | + const matches = useMediaQuery(theme.breakpoints.up('md')) |
| 33 | + |
| 34 | + return ( |
| 35 | + <Box position='relative'> |
| 36 | + <Card |
| 37 | + sx={{ |
| 38 | + marginTop: '30px', |
| 39 | + padding: { xs: theme.spacing(2), sm: theme.spacing(4) }, |
| 40 | + }} |
| 41 | + > |
| 42 | + <CardContent> |
| 43 | + <Stack spacing={4}> |
| 44 | + <Stack spacing={2} textAlign="center"> |
| 45 | + <div> |
| 46 | + <Image src="/crypto-banter-logo.png" alt='' width={185} height={142} /> |
| 47 | + </div> |
| 48 | + <H2>Refer Friends and Earn Rewards</H2> |
| 49 | + <Paragraph color="text.secondary"> |
| 50 | + Invite your friends to register for an ISME DID via the referral link of your account, and get rewarded |
| 51 | + with $ISME.{' '} |
| 52 | + <Link href="https://medium.com/nft3/announcing-the-isme-referral-program-3c55c4d6ae2b" target="_blank"> |
| 53 | + Referral program rules. |
| 54 | + </Link> |
| 55 | + </Paragraph> |
| 56 | + <H4>Check if you are eligible for your claimable $ISME</H4> |
| 57 | + <Box> |
| 58 | + <Button variant='contained' href='https://gleam.io/vDR5a/nft3-eligibility-checker' target='_blank'>Check Eligibility</Button> |
| 59 | + </Box> |
| 60 | + </Stack> |
| 61 | + |
| 62 | + <ReferralCard /> |
| 63 | + |
| 64 | + <Stack spacing={2}> |
| 65 | + <H4>Referral link</H4> |
| 66 | + <Stack spacing={2} direction={{ xs: 'column', sm: 'row' }}> |
| 67 | + <OutlinedInput |
| 68 | + fullWidth |
| 69 | + id="referral-link" |
| 70 | + type="text" |
| 71 | + value={referralLink} |
| 72 | + disabled |
| 73 | + endAdornment={ |
| 74 | + <InputAdornment position="end"> |
| 75 | + <Button |
| 76 | + variant="text" |
| 77 | + sx={{ |
| 78 | + color: 'text.disabled', |
| 79 | + ':hover': { backgroundColor: 'transparent', color: 'text.secondary' }, |
| 80 | + }} |
| 81 | + onClick={(e) => { |
| 82 | + e.stopPropagation() |
| 83 | + setCopied(true) |
| 84 | + writeText(referralLink) |
| 85 | + toast.success('Referral link copied successfully', { |
| 86 | + position: toast.POSITION.BOTTOM_RIGHT, |
| 87 | + }) |
| 88 | + }} |
| 89 | + > |
| 90 | + {copied ? ( |
| 91 | + <Stack spacing={1} direction="row"> |
| 92 | + <InventoryRoundedIcon fontSize="small" sx={{ color: 'text.disabled' }} /> |
| 93 | + <span>Copied</span> |
| 94 | + </Stack> |
| 95 | + ) : ( |
| 96 | + <Stack spacing={1} direction="row"> |
| 97 | + <ContentCopyRoundedIcon fontSize="small" sx={{ color: 'text.disabled' }} /> |
| 98 | + <span>Copy</span> |
| 99 | + </Stack> |
| 100 | + )} |
| 101 | + </Button> |
| 102 | + </InputAdornment> |
| 103 | + } |
| 104 | + label="Password" |
| 105 | + /> |
| 106 | + <Button |
| 107 | + variant="twitter" |
| 108 | + startIcon={<TwitterIcon />} |
| 109 | + disabled={!didname} |
| 110 | + onClick={() => { |
| 111 | + const text = `Get your #ISME domain now to earn your $ISME tokens by using the official @NFT3com referral link! |
| 112 | +
|
| 113 | + Your true digital self starts right here and now ⬇️` |
| 114 | + |
| 115 | + window.open( |
| 116 | + `https://twitter.com/share?text=${encodeURIComponent(text)}&url=${referralLink}`, |
| 117 | + `_blank` |
| 118 | + ) |
| 119 | + }} |
| 120 | + sx={{ |
| 121 | + borderRadius: '100px', |
| 122 | + width: { xs: '100%', sm: '150px' }, |
| 123 | + }} |
| 124 | + > |
| 125 | + Share |
| 126 | + </Button> |
| 127 | + </Stack> |
| 128 | + </Stack> |
| 129 | + {!matches && <Stack spacing={2}> |
| 130 | + <H4>Get real-time updates on $ISME</H4> |
| 131 | + <Links /> |
| 132 | + </Stack>} |
| 133 | + <Invitees /> |
| 134 | + </Stack> |
| 135 | + </CardContent> |
| 136 | + </Card> |
| 137 | + {matches && <RightLinks />} |
| 138 | + </Box> |
| 139 | + |
| 140 | + ) |
| 141 | +} |
| 142 | + |
| 143 | +export default ReferralProgram |
0 commit comments