-
Notifications
You must be signed in to change notification settings - Fork 3k
Expand file tree
/
Copy pathpage.tsx
More file actions
81 lines (71 loc) · 2.57 KB
/
page.tsx
File metadata and controls
81 lines (71 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { getProgram } from "@/lib/fetchers/get-program";
import { DEFAULT_PARTNER_GROUP } from "@/lib/zod/schemas/groups";
import { programLanderSchema } from "@/lib/zod/schemas/program-lander";
import { ApplicationTracker } from "@/ui/application-tracker/application-tracker";
import { BLOCK_COMPONENTS } from "@/ui/partners/lander/blocks";
import { LanderHero } from "@/ui/partners/lander/lander-hero";
import { LanderRewards } from "@/ui/partners/lander/lander-rewards";
import { notFound, redirect } from "next/navigation";
import { CSSProperties } from "react";
import { ApplyButton } from "./apply-button";
import { ApplyHeader } from "./header";
export default async function ApplyPage(props: {
params: Promise<{ programSlug: string; groupSlug?: string }>;
}) {
const { programSlug, groupSlug } = await props.params;
const partnerGroupSlug = groupSlug ?? DEFAULT_PARTNER_GROUP.slug;
const program = await getProgram({
slug: programSlug,
groupSlug: partnerGroupSlug,
});
if (
!program ||
!program.group ||
!program.group.landerData ||
!program.group.landerPublishedAt
) {
// throw 404 if it's the default group, else redirect to the default group page
if (partnerGroupSlug === DEFAULT_PARTNER_GROUP.slug) {
notFound();
} else {
redirect(`/${programSlug}`);
}
}
const landerData = programLanderSchema.parse(program.group.landerData || {});
return (
<div
className="relative"
style={
{
"--brand": program.group.brandColor || "#000000",
"--brand-ring": "rgb(from var(--brand) r g b / 0.2)",
} as CSSProperties
}
>
<ApplicationTracker />
<ApplyHeader group={program.group} />
<div className="p-6">
<LanderHero program={program} landerData={landerData} />
{/* Program details grid */}
<LanderRewards
className="mt-4"
rewards={program.rewards}
discount={program.discount}
/>
{/* Buttons */}
<div className="animate-scale-in-fade mt-10 flex flex-col gap-2 [animation-delay:400ms] [animation-fill-mode:both]">
<ApplyButton programSlug={programSlug} groupSlug={partnerGroupSlug} />
</div>
{/* Content blocks */}
<div className="mt-16 grid grid-cols-1 gap-10">
{landerData.blocks.map((block, idx) => {
const Component = BLOCK_COMPONENTS[block.type];
return Component ? (
<Component key={idx} block={block} group={program.group} />
) : null;
})}
</div>
</div>
</div>
);
}