-
Notifications
You must be signed in to change notification settings - Fork 0
update application form for email onboarding flow #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| HASURA_GRAPHQL_ADMIN_SECRET= | ||
| NEXT_PUBLIC_API_URL= | ||
| NEXT_PUBLIC_API_URL= | ||
| EMAIL_REFERRALS_API_URL= | ||
| FORM_INGEST_API_KEY= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| import { NextRequest, NextResponse } from "next/server"; | ||
| import { z } from "zod"; | ||
|
|
||
| const emailReferralSchema = z.object({ | ||
| email: z.email("Valid email is required"), | ||
| referral: z.string().optional(), | ||
| }); | ||
|
|
||
| export async function POST(request: NextRequest) { | ||
| try { | ||
| const body = await request.json(); | ||
| const validationResult = emailReferralSchema.safeParse(body); | ||
|
|
||
| if (!validationResult.success) { | ||
| const errors = validationResult.error.issues.map((issue) => ({ | ||
| field: issue.path.join("."), | ||
| message: issue.message, | ||
| })); | ||
|
|
||
| return NextResponse.json( | ||
| { | ||
| success: false, | ||
| error: "Validation failed", | ||
| details: errors, | ||
| }, | ||
| { status: 400 } | ||
| ); | ||
| } | ||
|
|
||
| const apiUrl = process.env.EMAIL_REFERRALS_API_URL; | ||
| const apiKey = process.env.FORM_INGEST_API_KEY; | ||
|
|
||
| if (!apiUrl || !apiKey) { | ||
| return NextResponse.json( | ||
| { | ||
| success: false, | ||
| error: "Email referral API is not configured", | ||
| }, | ||
| { status: 500 } | ||
| ); | ||
| } | ||
|
|
||
| const response = await fetch(apiUrl, { | ||
| method: "POST", | ||
| headers: { | ||
| "Content-Type": "application/json", | ||
| "x-form-api-key": apiKey, | ||
| }, | ||
| body: JSON.stringify(validationResult.data), | ||
| }); | ||
|
|
||
| const contentType = response.headers.get("content-type") || ""; | ||
| const responseBody = contentType.includes("application/json") | ||
| ? await response.json() | ||
| : await response.text(); | ||
|
|
||
| if (!response.ok) { | ||
| return NextResponse.json( | ||
| { | ||
| success: false, | ||
| error: | ||
| (typeof responseBody === "object" && | ||
| responseBody && | ||
| "error" in responseBody && | ||
| responseBody.error) || | ||
| responseBody || | ||
| "Failed to submit email referral", | ||
| }, | ||
| { status: response.status } | ||
| ); | ||
| } | ||
|
|
||
| return NextResponse.json( | ||
| { | ||
| success: true, | ||
| data: responseBody || { ok: true }, | ||
| }, | ||
| { status: 200 } | ||
| ); | ||
| } catch (error) { | ||
| console.error("Error submitting email referral:", error); | ||
|
|
||
| return NextResponse.json( | ||
| { | ||
| success: false, | ||
| error: "Failed to submit email referral", | ||
| }, | ||
| { status: 500 } | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| import JoinUs from "./JoinUs"; | ||
|
|
||
| export default function JoinUsSection() { | ||
| return <JoinUs />; | ||
| type JoinUsSectionProps = { | ||
| referral?: string; | ||
| }; | ||
|
|
||
| export default function JoinUsSection({ referral }: JoinUsSectionProps) { | ||
| return <JoinUs referral={referral} />; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid logging emails/results to the console (PII exposure).
Client logs can be captured by monitoring tools or shared devices; redact or remove.
🧹 Proposed fix (remove/redact PII from logs)
Also applies to: 73-85
🤖 Prompt for AI Agents