Connect, collaborate, and grow with a community of TypeScript developers
feat: Waitlist referrers (#466)
typesafegh6510706f7c18
diff --git a/apps/web/src/app/page.tsx b/apps/web/src/app/page.tsxindex ae323de6..cb943833 100644--- a/apps/web/src/app/page.tsx+++ b/apps/web/src/app/page.tsx@@ -11,13 +11,13 @@ export const metadata: Metadata = {'Connect, collaborate, and grow with a community of TypeScript developers. Elevate your skills through interactive coding challenges, discussions, and knowledge sharing',};-export default async function Index() {+export default async function Index({ searchParams }: { searchParams: Record<string, string> }) {return (<><Hero /><Features /><Community />- <Waitlist />+ <Waitlist ref={searchParams.ref} /><Footsies /></>);diff --git a/apps/web/src/components/landing/waitlist/banner.tsx b/apps/web/src/components/landing/waitlist/banner.tsxindex e361098b..db4a144a 100644--- a/apps/web/src/components/landing/waitlist/banner.tsx+++ b/apps/web/src/components/landing/waitlist/banner.tsx@@ -5,7 +5,15 @@ import { Balancer } from 'react-wrap-balancer';import { Button } from '@repo/ui';import styles from '~/components/landing/waitlist/waitlist.module.css';-function Waitlist() {+export interface WaitlistProps {+ ref?: string;+}++function Waitlist({ ref }: WaitlistProps) {+ let waitlistUrl = `/waitlist`;+ const searchParams = new URLSearchParams(ref ? { ref } : undefined).toString();+ if (searchParams.length) waitlistUrl += `?${searchParams}`;+return (<section className={clsx(styles.backdrop, 'relative overflow-hidden')}><div className="container relative grid grid-cols-1 items-center justify-center py-[64px] md:grid-cols-2">@@ -26,7 +34,7 @@ function Waitlist() {asChildclassName="group relative w-fit overflow-hidden rounded-xl bg-gradient-to-bl from-indigo-400 via-blue-400 to-emerald-400 p-[2px] font-bold transition-all duration-300 hover:rounded-3xl active:rounded-xl active:duration-150 sm:mx-16 md:mx-auto md:mr-0 lg:mr-auto lg:scale-[1.5] lg:hover:scale-[1.6] lg:active:scale-[1.5]">- <Link href="/waitlist">+ <Link href={waitlistUrl}><span className="inline-flex h-full w-fit items-center gap-1 rounded-[10px] bg-white/90 px-4 py-2 text-black transition-all duration-300 group-hover:rounded-3xl group-hover:bg-white/0 group-hover:text-white dark:bg-black/80 dark:text-white group-hover:dark:bg-black/0 dark:group-hover:text-black"><Mail className="mr-1 h-4 w-4 stroke-[3]" />Join the Waitlistdiff --git a/apps/web/src/components/landing/waitlist/create.action.ts b/apps/web/src/components/landing/waitlist/create.action.tsindex 949d863c..dd7dc2bd 100644--- a/apps/web/src/components/landing/waitlist/create.action.ts+++ b/apps/web/src/components/landing/waitlist/create.action.ts@@ -28,6 +28,7 @@ export const sendUserSignupEmail = async (to: string) => {export async function uploadWaitlistEntry(data: WaitlistFormSchema) {const isUser = data.intention === 'user';const isBuilder = data.intention === 'builder';+ const ref = data.ref;const existingEntry = await prisma.waitlist.findFirst({where: {@@ -44,6 +45,7 @@ export async function uploadWaitlistEntry(data: WaitlistFormSchema) {name: data.name,email: data.email,intention: isUser ? 'USER' : isBuilder ? 'BUILDER' : 'BOTH',+ referrer: ref,},});diff --git a/apps/web/src/components/landing/waitlist/index.tsx b/apps/web/src/components/landing/waitlist/index.tsxindex b1ec634f..e9911192 100644--- a/apps/web/src/components/landing/waitlist/index.tsx+++ b/apps/web/src/components/landing/waitlist/index.tsx@@ -2,7 +2,11 @@ import { Balancer } from 'react-wrap-balancer';import { WaitlistForm } from '~/components/landing/waitlist/waitlist-form';import styles from '~/components/landing/waitlist/waitlist.module.css';-export function Waitlist() {+export interface WaitlistPageProps {+ searchParams: Record<string, string>;+}++export function Waitlist({ searchParams }: WaitlistPageProps) {return (<main className="relative min-h-[calc(100vh-56px)] sm:px-16 md:px-0"><div className={`${styles.waitlistBackground} fixed left-0 top-0 -z-10 h-full w-full`} />@@ -27,7 +31,7 @@ export function Waitlist() {getting early access</Balancer></p>- <WaitlistForm />+ <WaitlistForm ref={searchParams.ref} /></div></div></main>diff --git a/apps/web/src/components/landing/waitlist/waitlist-form.tsx b/apps/web/src/components/landing/waitlist/waitlist-form.tsxindex 707e6706..3672678d 100644--- a/apps/web/src/components/landing/waitlist/waitlist-form.tsx+++ b/apps/web/src/components/landing/waitlist/waitlist-form.tsx@@ -27,11 +27,15 @@ const waitlistFormSchema = z.object({name: z.string().min(1, 'Please enter your name'),email: z.string().email(),intention: z.string(),+ ref: z.string().optional(),});export type WaitlistFormSchema = z.infer<typeof waitlistFormSchema>;+export interface WaitlistFormProps {+ ref?: string;+}-export function WaitlistForm() {+export function WaitlistForm({ ref }: WaitlistFormProps) {const [state, setState] = useState<'error' | 'idle' | 'submitting' | 'success'>('idle');const isSubmitting = state === 'submitting';@@ -66,6 +70,7 @@ export function WaitlistForm() {render={({ field }) => (<FormItem><FormControl>+ <input type="hidden" name="ref" value={ref} /><InputclassName={clsx({'rounded-b-none rounded-t-xl border border-b-0 border-red-600 bg-white/50 backdrop-blur-md dark:border-red-400 dark:bg-neutral-950/50':diff --git a/packages/db/schema.prisma b/packages/db/schema.prismaindex 12a443df..efc36c4d 100644--- a/packages/db/schema.prisma+++ b/packages/db/schema.prisma@@ -369,6 +369,7 @@ model Waitlist {id Int @id @default(autoincrement())name Stringemail String+ referrer String?intention WaitlistIntention}