The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Fix referral indicator
Terry Suttonb0e2cdede282
diff --git a/apps/www/components/LaunchWeek/ReferralIndicator.tsx b/apps/www/components/LaunchWeek/ReferralIndicator.tsxindex 7d0cd71a645..ee31e495f50 100644--- a/apps/www/components/LaunchWeek/ReferralIndicator.tsx+++ b/apps/www/components/LaunchWeek/ReferralIndicator.tsx@@ -1,29 +1,37 @@import React from 'react'+import useConfData from '~/components/LaunchWeek/Ticket//hooks/use-conf-data'-interface Props {- referrals: number-}+function calculateWinChances(+ sharedOnLinkedIn: string | undefined,+ sharedOnTwitter: string | undefined+) {+ let numChances = 1++ let chancesText = 'chances'-export default function ReferralIndicator({ referrals }: Props) {- let text+ if (sharedOnLinkedIn) {+ numChances+++ }+ if (sharedOnTwitter) {+ numChances+++ }- switch (referrals) {- case 0:- text = '1x chance'- break- case 1:- text = '2x chance'- break- case 2:- text = '3x chance'- break- default:- text = 'You have more than three referrals.'+ if (numChances === 1) {+ chancesText = 'chance'}++ return `${numChances}x ${chancesText}`+}++export default function ReferralIndicator() {+ const { userData } = useConfData()+ const { sharedOnLinkedIn, sharedOnTwitter } = userData+ const computedWinningOdds = calculateWinChances(sharedOnLinkedIn, sharedOnTwitter)+return (<div className="bg-[#EAEAEA75] rounded-full mt-4 flex">- <span className="bg-gradient-to-l from-[#A141E4] to-[#6300F569] rounded-full pl-4 pr-6 py-2 text-xs">- {text}+ <span className="bg-gradient-to-l from-[#A141E4] to-[#6300F569] rounded-full pl-4 pr-6 py-1.5 text-xs">+ {computedWinningOdds}</span></div>)diff --git a/apps/www/components/LaunchWeek/Ticket/hooks/use-conf-data.ts b/apps/www/components/LaunchWeek/Ticket/hooks/use-conf-data.tsindex 574e23fca2e..2588205aaf6 100644--- a/apps/www/components/LaunchWeek/Ticket/hooks/use-conf-data.ts+++ b/apps/www/components/LaunchWeek/Ticket/hooks/use-conf-data.ts@@ -10,6 +10,8 @@ export type UserData = {name?: stringgolden?: booleanreferrals?: number+ sharedOnTwitter?: string+ sharedOnLinkedIn?: string}type ConfDataContextType = {diff --git a/apps/www/components/LaunchWeek/Ticket/ticket-actions.tsx b/apps/www/components/LaunchWeek/Ticket/ticket-actions.tsxindex 8cb309656ae..d2afdfe8977 100644--- a/apps/www/components/LaunchWeek/Ticket/ticket-actions.tsx+++ b/apps/www/components/LaunchWeek/Ticket/ticket-actions.tsx@@ -38,17 +38,9 @@ export default function TicketActions({ username, golden = false }: Props) {}}, [downloadUrl])- const ActionStyle = ({ children }: any) => {- return (- <div className="rounded-md bg-[#E6E8EB] text-scale-500 py-1 px-3 border border-scale-1100 text-sm mb-1 transition-all ease-out hover:bg-[#dfe1e3]">- {children}- </div>- )- }-return (- <>- <ActionStyle>+ <div className="grid gap-1">+ <div className="rounded-md bg-[#E6E8EB] text-scale-500 py-1 px-3 border border-scale-1100 text-xs mb-1 transition-all ease-out hover:bg-[#dfe1e3]"><ahref={tweetUrl}rel="noopener noreferrer"@@ -56,58 +48,49 @@ export default function TicketActions({ username, golden = false }: Props) {className="flex items-center justify-center gap-2"><div className="text-scale-900">- <IconCheckCircle size={12} strokeWidth={1.5} />+ <IconCheckCircle size={10} strokeWidth={1} /></div>Connect with Github</a>- </ActionStyle>- <ActionStyle>+ </div>+ <div+ className={`rounded-md ${+ userData.sharedOnTwitter ? 'bg-[#E6E8EB]' : ''+ } text-scale-500 py-1 px-3 border border-scale-1100 text-xs mb-1 transition-all ease-out hover:bg-[#dfe1e3]`}+ ><ahref={tweetUrl}rel="noopener noreferrer"target="_blank"className="flex items-center justify-center gap-2">- <div className="text-scale-900">- <IconTwitter size={12} strokeWidth={1.5} />- </div>- Tweet it+ {userData.sharedOnTwitter && (+ <div className="text-scale-900">+ <IconCheckCircle size={10} strokeWidth={1} />+ </div>+ )}+ Share on Twitter</a>- </ActionStyle>- <ActionStyle>+ </div>+ <div+ className={`rounded-md ${+ userData.sharedOnLinkedIn ? 'bg-[#E6E8EB] text-scale-500' : 'text-white'+ } py-1 px-3 border border-scale-1100 text-xs mb-1 transition-all ease-out hover:bg-[#dfe1e3] hover:text-scale-500`}+ ><ahref={linkedInUrl}rel="noopener noreferrer"target="_blank"className="flex items-center justify-center gap-2">- <div className="text-scale-900">- <IconLinkedin size={12} strokeWidth={1.5} />- </div>+ {userData.sharedOnLinkedIn && (+ <div className="text-scale-900">+ <IconCheckCircle size={10} strokeWidth={1} />+ </div>+ )}Share on Linkedin</a>- </ActionStyle>- <ActionStyle>- <a- href={loading ? undefined : downloadUrl}- onClick={(e) => {- if (imgReady) return-- e.preventDefault()- downloadLink.current = e.currentTarget- // Wait for the image download to finish- setLoading(true)- }}- download="ticket.png"- className="flex items-center justify-center gap-2"- >- <div className="text-scale-900">- <IconDownload size={12} strokeWidth={1.5} />- </div>- Download- {loading ? <LoadingDots size={4} /> : <>{/* <IconDownload width={24} /> Download */}</>}- </a>- </ActionStyle>- </>+ </div>+ </div>)}diff --git a/apps/www/components/LaunchWeek/Ticket/ticket.tsx b/apps/www/components/LaunchWeek/Ticket/ticket.tsxindex 5e716fa529c..89813f45000 100644--- a/apps/www/components/LaunchWeek/Ticket/ticket.tsx+++ b/apps/www/components/LaunchWeek/Ticket/ticket.tsx@@ -149,7 +149,7 @@ export default function Ticket({ticket. Get sharing!</p>- <ReferralIndicator referrals={referrals} />+ <ReferralIndicator /></>) : (<p>