Skip to content

Commit

Permalink
plan → proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-tey committed Nov 21, 2024
1 parent 0d032ed commit b1951ac
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type FormData = {
name: string;
email: string;
website?: string;
plan: string;
proposal: string;
comments?: string;
};

Expand Down Expand Up @@ -133,13 +133,13 @@ export function ProgramApplicationForm({
<ReactTextareaAutosize
className={cn(
"mt-2 block max-h-48 min-h-12 w-full rounded-md focus:outline-none sm:text-sm",
errors.plan
errors.proposal
? "border-red-400 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
: "border-gray-300 text-gray-900 placeholder-gray-400 focus:border-gray-500 focus:ring-gray-500",
)}
placeholder=""
minRows={3}
{...register("plan", { required: true })}
{...register("proposal", { required: true })}
/>
</label>

Expand Down
33 changes: 20 additions & 13 deletions apps/web/app/partners.dub.co/(apply)/apply/[programSlug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,12 @@ import { ApplyButton } from "./apply-button";
import { DetailsGrid } from "./details-grid";
import { Header } from "./header";

export default async function ApplyPage({
export async function generateMetadata({
params: { programSlug },
}: {
params: { programSlug: string };
}) {
const program = await prisma.program.findUnique({
select: {
landerData: true,
name: true,
logo: true,
wordmark: true,
brandColor: true,
commissionType: true,
commissionAmount: true,
isLifetimeRecurring: true,
},
where: {
slug: programSlug,
},
Expand All @@ -33,12 +23,29 @@ export default async function ApplyPage({
notFound();
}

const landerData = programLanderSchema.parse(program.landerData);
return {
title: `Apply to the ${program.name} affiliate program`,
description: `Earn ${program.commissionAmount} on any subscriptions generated through your referral.`,
};
}

export default async function ApplyPage({
params: { programSlug },
}: {
params: { programSlug: string };
}) {
const program = await prisma.program.findUnique({
where: {
slug: programSlug,
},
});

if (!landerData) {
if (!program || !program.landerData) {
notFound();
}

const landerData = programLanderSchema.parse(program.landerData);

return (
<div
className="relative"
Expand Down
4 changes: 2 additions & 2 deletions apps/web/lib/actions/partners/create-program-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const createProgramApplicationSchema = z.object({
name: z.string().trim().min(1).max(100),
email: z.string().trim().email().min(1).max(100),
website: z.string().trim().max(100).optional(),
plan: z.string().trim().min(1).max(5000),
proposal: z.string().trim().min(1).max(5000),
comments: z.string().trim().max(5000).optional(),
});

Expand Down Expand Up @@ -167,7 +167,7 @@ async function createApplication({
[...existingApplicationIds, application.id].join(","),
{
httpOnly: true,
expires: addDays(new Date(), 1),
expires: addDays(new Date(), 7), // persist for 7 days
},
);

Expand Down
8 changes: 4 additions & 4 deletions apps/web/prisma/schema/program.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ model ProgramApplication {
partnerId String?
name String
email String
plan String @db.LongText
website String?
proposal String? @db.LongText
website String? @db.Text
comments String? @db.LongText
status ProgramApplicationStatus @default(pending)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
partner Partner? @relation(fields: [partnerId], references: [id])
program Program @relation(fields: [programId], references: [id])
partner Partner? @relation(fields: [partnerId], references: [id])
program Program @relation(fields: [programId], references: [id])
enrollment ProgramEnrollment?
@@index([programId])
Expand Down

0 comments on commit b1951ac

Please sign in to comment.