|
| 1 | +'use client' |
| 2 | + |
| 3 | +import { useState, useEffect } from 'react' |
| 4 | + |
| 5 | +import { getSession } from '@/app/utils/auth' |
| 6 | +import Pill from '@/components/ui/pill' |
| 7 | +import { |
| 8 | + Popover, |
| 9 | + PopoverTrigger, |
| 10 | + PopoverContent, |
| 11 | +} from '@/components/ui/popover' |
| 12 | +import Icon from '@hackclub/icons' |
| 13 | + |
| 14 | +export default function Referral() { |
| 15 | + const [shareLink, setShareLink] = useState<string | null>(null) |
| 16 | + const [open, setOpen] = useState(false) |
| 17 | + |
| 18 | + useEffect(() => { |
| 19 | + getSession().then((session) => { |
| 20 | + if (session) { |
| 21 | + setShareLink(`https://highseas.hackclub.com/?ref=${session.slackId}`) |
| 22 | + } |
| 23 | + }) |
| 24 | + }, []) |
| 25 | + |
| 26 | + if (!shareLink) return null |
| 27 | + |
| 28 | + return ( |
| 29 | + <Popover open={open} onOpenChange={setOpen}> |
| 30 | + <PopoverTrigger |
| 31 | + asChild |
| 32 | + onMouseEnter={() => setOpen(true)} |
| 33 | + onMouseLeave={() => setOpen(false)} |
| 34 | + > |
| 35 | + <div className="text-center mb-5"> |
| 36 | + <a href={shareLink} target="_blank"> |
| 37 | + <Pill msg="Referral link" color="green" glyph="link" /> |
| 38 | + </a> |
| 39 | + </div> |
| 40 | + </PopoverTrigger> |
| 41 | + <PopoverContent className="text-sm"> |
| 42 | + <div> |
| 43 | + <p className="inline-flex text-base">Your referral link!</p> |
| 44 | + <ul className="flex flex-col gap-1 mt-2"> |
| 45 | + <li className="flex gap-1"> |
| 46 | + <Icon glyph="friend" size={20} className="inline flex-shrink-0" />{' '} |
| 47 | + Get your friends to sign up at this link! |
| 48 | + </li> |
| 49 | + <li className="flex gap-1"> |
| 50 | + <img |
| 51 | + sizes="20px" |
| 52 | + src="doubloon.svg" |
| 53 | + alt="doubloons" |
| 54 | + className="w-4 sm:w-5 h-4 sm:h-5" |
| 55 | + />{' '} |
| 56 | + Once they ship you'll earn 4 doubloons! |
| 57 | + </li> |
| 58 | + <li className="flex gap-1"> |
| 59 | + <span className="w-4 sm:w-5 h-4 sm:h-5">🦈</span> |
| 60 | + You'll also be entered into a raffle to win a smolhaj! |
| 61 | + </li> |
| 62 | + </ul> |
| 63 | + </div> |
| 64 | + </PopoverContent> |
| 65 | + </Popover> |
| 66 | + ) |
| 67 | +} |
0 commit comments