MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / SponseePage

Function SponseePage

web/src/app/[sponsee]/page.tsx:25–87  ·  view source on GitHub ↗
({
  params,
  searchParams,
}: {
  params: Promise<{ sponsee: string }>
  searchParams: Promise<Record<string, string | string[] | undefined>>
})

Source from the content-addressed store, hash-verified

23}
24
25export default async function SponseePage({
26 params,
27 searchParams,
28}: {
29 params: Promise<{ sponsee: string }>
30 searchParams: Promise<Record<string, string | string[] | undefined>>
31}) {
32 const { sponsee } = await params
33 const resolvedSearchParams = await searchParams
34 const sponseeName = sponsee.toLowerCase()
35
36 const referralCode = await db
37 .select({
38 referralCode: schema.user.referral_code,
39 })
40 .from(schema.user)
41 .where(eq(schema.user.handle, sponseeName))
42 .limit(1)
43 .then((result) => result[0]?.referralCode ?? null)
44
45 if (!referralCode) {
46 return (
47 <CardWithBeams
48 title="Hmm, that link doesn't look right."
49 description={`We don't have a referral code for "${sponsee}".`}
50 content={
51 <>
52 <p className="text-center">
53 Please double-check the link you used or try contacting the person
54 who shared it.
55 </p>
56 <p className="text-center text-sm text-muted-foreground">
57 You can also reach out to our support team at{' '}
58 <Link
59 href={`mailto:${env.NEXT_PUBLIC_SUPPORT_EMAIL}`}
60 className="underline"
61 >
62 {env.NEXT_PUBLIC_SUPPORT_EMAIL}
63 </Link>
64 .
65 </p>
66 </>
67 }
68 />
69 )
70 }
71
72 const queryParams = new URLSearchParams()
73 for (const [key, value] of Object.entries(resolvedSearchParams)) {
74 if (value !== undefined) {
75 if (Array.isArray(value)) {
76 for (const v of value) {
77 queryParams.append(key, v)
78 }
79 } else {
80 queryParams.set(key, value)
81 }
82 }

Callers

nothing calls this directly

Calls 3

fromMethod · 0.80
setMethod · 0.80
redirectFunction · 0.50

Tested by

no test coverage detected