Skip to content

Commit f90210d

Browse files
committed
feat(web): show referrer name in referral onboarding flow
- Display referrer name on referral landing page and onboarding steps - Pass referrerName prop through OnboardClientWrapper to OnboardingFlow - Personalize welcome message: "{name} invited you to Codebuff!" - Show mutual benefit on redeem step: "You and {name} will both earn credits!" - Fix React 19 useFormState -> useActionState migration in affiliates page
1 parent 308eeff commit f90210d

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

web/src/app/affiliates/affiliates-client.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {
77
} from '@codebuff/common/old-constants'
88
import Link from 'next/link'
99
import { useSession } from 'next-auth/react'
10-
import React, { useEffect, useState, useCallback } from 'react'
11-
import { useFormState, useFormStatus } from 'react-dom'
10+
import React, { useEffect, useState, useCallback, useActionState } from 'react'
11+
import { useFormStatus } from 'react-dom'
1212

1313
import { setAffiliateHandleAction } from './actions'
1414

@@ -49,7 +49,7 @@ function SetHandleForm({
4949
success: false,
5050
fieldErrors: {},
5151
}
52-
const [state, formAction] = useFormState(
52+
const [state, formAction] = useActionState(
5353
setAffiliateHandleAction,
5454
initialState,
5555
)

web/src/app/referrals/[code]/page.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { env } from '@codebuff/common/env'
2+
import { CREDITS_REFERRAL_BONUS } from '@codebuff/common/old-constants'
23
import { headers } from 'next/headers'
34
import Link from 'next/link'
45
import { getServerSession } from 'next-auth'
@@ -113,13 +114,18 @@ export default async function ReferralPage({
113114

114115
// Show onboarding flow for valid referrals
115116
return (
116-
<OnboardClientWrapper hasReferralCode={true} referralCode={code}>
117+
<OnboardClientWrapper
118+
hasReferralCode={true}
119+
referralCode={code}
120+
referrerName={referrerDisplayName}
121+
>
117122
<CardWithBeams
118-
title="Welcome to Codebuff!"
119-
description="You can close this window and continue with the installation."
123+
title={`${referrerDisplayName} invited you to Codebuff!`}
124+
description={`Sign up and you'll both earn ${CREDITS_REFERRAL_BONUS} bonus credits per month.`}
120125
content={
121126
<div className="text-center text-muted-foreground">
122-
Your referral code is ready to use in the CLI!
127+
Follow the steps below to get started, then redeem your referral
128+
code in the CLI!
123129
</div>
124130
}
125131
/>

web/src/components/onboard/onboard-client-wrapper.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import { OnboardingFlow } from './onboarding-flow'
88
interface OnboardClientWrapperProps {
99
hasReferralCode: boolean
1010
referralCode?: string
11+
referrerName?: string
1112
children: React.ReactNode
1213
}
1314

1415
export function OnboardClientWrapper({
1516
hasReferralCode,
1617
referralCode,
18+
referrerName,
1719
children,
1820
}: OnboardClientWrapperProps) {
1921
const [hasStoredReferral, setHasStoredReferral] = useState(false)
@@ -61,6 +63,7 @@ export function OnboardClientWrapper({
6163
<OnboardingFlow
6264
hasReferralCode={shouldShowOnboarding}
6365
referralCode={actualReferralCode || undefined}
66+
referrerName={referrerName}
6467
onComplete={handleOnboardingComplete}
6568
/>
6669
</div>

web/src/components/onboard/onboarding-flow.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { cn } from '@/lib/utils'
2929
interface OnboardingFlowProps {
3030
hasReferralCode: boolean
3131
referralCode?: string
32+
referrerName?: string
3233
onComplete?: () => void
3334
}
3435

@@ -98,6 +99,7 @@ const detectOS = (): OS => {
9899
export function OnboardingFlow({
99100
hasReferralCode,
100101
referralCode,
102+
referrerName,
101103
onComplete,
102104
}: OnboardingFlowProps) {
103105
const [mounted, setMounted] = useState(false)
@@ -213,12 +215,13 @@ export function OnboardingFlow({
213215
<div className="space-y-4">
214216
<h3 className="text-xl font-semibold">🎉 Redeem Your Referral Code</h3>
215217
<p className="text-muted-foreground">
216-
You're almost done! Paste your referral code in the CLI to claim your
217-
bonus credits.
218+
You're almost done! Redeem your code to claim bonus credits
219+
{referrerName ? ` — ${referrerName} will earn credits too!` : '.'}
218220
</p>
219221
<div className="bg-acid-matrix/30 border border-acid-matrix/40 rounded-lg p-6">
220222
<p className="text-black dark:text-green-200 text-lg font-semibold mb-3">
221-
🎁 Your referral code is ready!
223+
🎁 {referrerName ? `You and ${referrerName} will both` : "You'll"} earn
224+
bonus credits!
222225
</p>
223226
<div className="bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-md p-3 flex items-center justify-between">
224227
<code
@@ -314,15 +317,19 @@ export function OnboardingFlow({
314317

315318
const renderInstallStep = () => (
316319
<div className="space-y-4">
317-
<h3 className="text-xl font-semibold">Welcome to Codebuff! 🎉</h3>
320+
<h3 className="text-xl font-semibold">
321+
{referrerName
322+
? `${referrerName} invited you to Codebuff! 🎉`
323+
: 'Welcome to Codebuff! 🎉'}
324+
</h3>
318325
<p className="text-muted-foreground">
319326
Install the Codebuff CLI tool globally on your system.
320327
</p>
321328
{referralCode && (
322329
<div className="bg-terminal-yellow/20 border border-terminal-yellow/30 rounded-lg p-4">
323330
<p className="text-yellow-900 dark:text-terminal-yellow font-semibold">
324-
🎁 You're almost there! Follow the next steps to redeem your
325-
referral code for bonus credits.
331+
🎁 Follow the next steps to redeem your referral code for bonus
332+
credits.
326333
</p>
327334
</div>
328335
)}

0 commit comments

Comments
 (0)