diff --git a/apps/www/src/app/api/contact/route.ts b/apps/www/src/app/api/contact/route.ts index 6c80bf6f..cdb8484c 100644 --- a/apps/www/src/app/api/contact/route.ts +++ b/apps/www/src/app/api/contact/route.ts @@ -1,10 +1,10 @@ -import { Resend } from 'resend'; -import { NextResponse } from 'next/server'; +import { Resend } from "resend"; +import { NextResponse } from "next/server"; function getResendClient() { const apiKey = process.env.RESEND_API_KEY; if (!apiKey) { - throw new Error('RESEND_API_KEY environment variable is not set'); + throw new Error("RESEND_API_KEY environment variable is not set"); } return new Resend(apiKey); } @@ -17,18 +17,24 @@ interface ContactPayload { lookingFor: string; } -function buildProperties(company?: string, lookingFor?: string): Record | undefined { +function buildProperties( + company?: string, + lookingFor?: string, +): Record | undefined { const properties: Record = {}; if (company) properties.company_name = company; if (lookingFor) properties.looking_for = lookingFor; return Object.keys(properties).length > 0 ? properties : undefined; } -function isDuplicateError(error: { message?: string; statusCode?: number | null }): boolean { - const errorMessage = error.message?.toLowerCase() || ''; +function isDuplicateError(error: { + message?: string; + statusCode?: number | null; +}): boolean { + const errorMessage = error.message?.toLowerCase() || ""; return ( - errorMessage.includes('already exists') || - errorMessage.includes('duplicate') || + errorMessage.includes("already exists") || + errorMessage.includes("duplicate") || error.statusCode === 409 ); } @@ -38,7 +44,7 @@ function createContactPayload( firstName: string, lastName: string, company?: string, - lookingFor?: string + lookingFor?: string, ) { const properties = buildProperties(company, lookingFor); return { @@ -53,50 +59,56 @@ function createContactPayload( export async function POST(req: Request) { try { const body = await req.json(); - const { firstName, lastName, email, company, lookingFor }: ContactPayload = body; + const { firstName, lastName, email, company, lookingFor }: ContactPayload = + body; if (!email || !firstName || !lastName || !lookingFor) { return NextResponse.json( - { error: 'Missing required fields' }, - { status: 400 } + { error: "Missing required fields" }, + { status: 400 }, ); } - const contactPayload = createContactPayload(email, firstName, lastName, company, lookingFor); + const contactPayload = createContactPayload( + email, + firstName, + lastName, + company, + lookingFor, + ); const resend = getResendClient(); const { data, error } = await resend.contacts.create(contactPayload); if (error) { if (isDuplicateError(error)) { - const { data: updateData, error: updateError } = await resend.contacts.update( - contactPayload - ); + const { data: updateData, error: updateError } = + await resend.contacts.update(contactPayload); if (updateError) { - console.error('Resend update error:', updateError); + console.error("Resend update error:", updateError); return NextResponse.json( - { error: updateError.message || 'Failed to update contact' }, - { status: 500 } + { error: updateError.message || "Failed to update contact" }, + { status: 500 }, ); } return NextResponse.json({ success: true, data: updateData }); } - console.error('Resend create error:', error); + console.error("Resend create error:", error); return NextResponse.json( - { error: error.message || 'Failed to create contact' }, - { status: error.statusCode || 500 } + { error: error.message || "Failed to create contact" }, + { status: error.statusCode || 500 }, ); } return NextResponse.json({ success: true, data }); } catch (error) { - console.error('Unexpected error:', error); + console.error("Unexpected error:", error); return NextResponse.json( - { error: error instanceof Error ? error.message : 'Unknown error' }, - { status: 500 } + { error: error instanceof Error ? error.message : "Unknown error" }, + { status: 500 }, ); } } diff --git a/apps/www/src/app/contact/ContactPageClient.tsx b/apps/www/src/app/contact/ContactPageClient.tsx index 4b22a410..45117f98 100644 --- a/apps/www/src/app/contact/ContactPageClient.tsx +++ b/apps/www/src/app/contact/ContactPageClient.tsx @@ -13,10 +13,14 @@ export default function ContactPageClient() { lookingFor: "", message: "", }); - const [status, setStatus] = useState<"idle" | "submitting" | "success" | "error">("idle"); + const [status, setStatus] = useState< + "idle" | "submitting" | "success" | "error" + >("idle"); const [errorMessage, setErrorMessage] = useState(""); - const handleChange = (e: React.ChangeEvent) => { + const handleChange = ( + e: React.ChangeEvent, + ) => { const { name, value } = e.target; setFormData((prev) => ({ ...prev, [name]: value })); }; @@ -50,7 +54,9 @@ export default function ContactPageClient() { }); } catch (error) { setStatus("error"); - setErrorMessage(error instanceof Error ? error.message : "Failed to submit form"); + setErrorMessage( + error instanceof Error ? error.message : "Failed to submit form", + ); } }; @@ -66,7 +72,8 @@ export default function ContactPageClient() {

- Whether you're an enterprise looking for a custom solution or a developer building cool agents, we'd love to hear from you. + Whether you're an enterprise looking for a custom solution or a + developer building cool agents, we'd love to hear from you.

@@ -75,155 +82,214 @@ export default function ContactPageClient() {
- {/* Left Side: Community (Discord) */}
- {/* Background icon */} -
- -
+ {/* Background icon */} +
+ +
-
-
+
+
Community
-

Join Our Discord

-
-

- Connect with other developers, ask questions, share what you're building, and stay updated on the latest features by joining our Discord server. -

-
+

+ Join Our Discord +

+
+

+ Connect with other developers, ask questions, share what + you're building, and stay updated on the latest features by + joining our Discord server. +

+
- +
{/* Right Side: Enterprise Contact */}
- {/* Subtle background pattern */} -
+ {/* Subtle background pattern */} +
- {/* Background icon */} -
- -
+ {/* Background icon */} +
+ +
-
-
- - Enterprise -
-

Contact Us

-
+
+
+ + Enterprise +
+

+ Contact Us +

+
-
- {status === "success" ? ( -
-
- - - -
-
Message Sent!
-

Thank you for reaching out. We'll be in touch shortly.

- +
+ {status === "success" ? ( +
+
+ + +
- ) : ( -
-
-
- - -
-
- - -
-
- +
+ Message Sent! +
+

+ Thank you for reaching out. We'll be in touch shortly. +

+ +
+ ) : ( + +
- - + +
-
- - + +
+
-
- -