From d7022fd05ac937f84339bfcaf9a9ceea74c0e1c3 Mon Sep 17 00:00:00 2001 From: Musa Date: Mon, 22 Dec 2025 12:46:06 -0800 Subject: [PATCH] include contact and navbar changes --- apps/www/package.json | 1 + apps/www/src/app/api/contact/route.ts | 88 ++++++++++ apps/www/src/app/contact/page.tsx | 234 ++++++++++++++++++++++++++ package-lock.json | 100 +++++++++++ package.json | 5 +- packages/ui/src/components/Footer.tsx | 2 +- packages/ui/src/components/Navbar.tsx | 1 + 7 files changed, 429 insertions(+), 2 deletions(-) create mode 100644 apps/www/src/app/api/contact/route.ts create mode 100644 apps/www/src/app/contact/page.tsx diff --git a/apps/www/package.json b/apps/www/package.json index 130aa1b1..8492b36f 100644 --- a/apps/www/package.json +++ b/apps/www/package.json @@ -31,6 +31,7 @@ "papaparse": "^5.5.3", "react": "19.2.0", "react-dom": "19.2.0", + "resend": "^6.6.0", "sanity": "^4.18.0", "styled-components": "^6.1.19" }, diff --git a/apps/www/src/app/api/contact/route.ts b/apps/www/src/app/api/contact/route.ts new file mode 100644 index 00000000..dfb5ce8c --- /dev/null +++ b/apps/www/src/app/api/contact/route.ts @@ -0,0 +1,88 @@ +import { Resend } from 'resend'; +import { NextResponse } from 'next/server'; + +const resend = new Resend(process.env.RESEND_API_KEY); + +export async function POST(req: Request) { + try { + const body = await req.json(); + const { firstName, lastName, email, company, lookingFor } = body; + + // Validate required fields + if (!email || !firstName || !lastName || !lookingFor) { + return NextResponse.json( + { error: 'Missing required fields' }, + { status: 400 } + ); + } + + // Create or update the contact + // Note: Contact properties (company_name, looking_for) should be + // created manually in Resend dashboard or via a one-time setup script. + // Attempting to create them on every request causes rate limit issues. + + // Build properties object with custom fields + // Property keys must match exactly what's defined in Resend dashboard + const properties: Record = {}; + if (company) properties.company_name = company; + if (lookingFor) properties.looking_for = lookingFor; + + let { data, error } = await resend.contacts.create({ + email, + firstName, + lastName, + unsubscribed: false, + // Pass custom properties as a Record + ...(Object.keys(properties).length > 0 && { properties }), + }); + + if (error) { + // If contact already exists, update it instead + const errorMessage = error.message?.toLowerCase() || ''; + const isDuplicate = + errorMessage.includes('already exists') || + errorMessage.includes('duplicate') || + error.statusCode === 409; + + if (isDuplicate) { + // Build properties object for update + const updateProperties: Record = {}; + if (company) updateProperties.company_name = company; + if (lookingFor) updateProperties.looking_for = lookingFor; + + const { data: updateData, error: updateError } = await resend.contacts.update({ + email, + firstName, + lastName, + unsubscribed: false, + // Pass custom properties as a Record + ...(Object.keys(updateProperties).length > 0 && { properties: updateProperties }), + }); + + if (updateError) { + console.error('Resend update error:', updateError); + return NextResponse.json( + { error: updateError.message || 'Failed to update contact' }, + { status: 500 } + ); + } + + return NextResponse.json({ success: true, data: updateData }); + } + + console.error('Resend create error:', error); + return NextResponse.json( + { error: error.message || 'Failed to create contact' }, + { status: error.statusCode || 500 } + ); + } + + return NextResponse.json({ success: true, data }); + } catch (error) { + console.error('Unexpected error:', error); + return NextResponse.json( + { error: error instanceof Error ? error.message : 'Unknown error' }, + { status: 500 } + ); + } +} diff --git a/apps/www/src/app/contact/page.tsx b/apps/www/src/app/contact/page.tsx new file mode 100644 index 00000000..140793f9 --- /dev/null +++ b/apps/www/src/app/contact/page.tsx @@ -0,0 +1,234 @@ +"use client"; + +import React, { useState } from "react"; +import { Button } from "@katanemo/ui"; +import Link from "next/link"; +import { ArrowRight, MessageSquare, Building2, MessagesSquare } from "lucide-react"; + +export default function ContactPage() { + const [formData, setFormData] = useState({ + firstName: "", + lastName: "", + email: "", + company: "", + lookingFor: "", + message: "", + }); + const [status, setStatus] = useState<"idle" | "submitting" | "success" | "error">("idle"); + const [errorMessage, setErrorMessage] = useState(""); + + const handleChange = (e: React.ChangeEvent) => { + const { name, value } = e.target; + setFormData((prev) => ({ ...prev, [name]: value })); + }; + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + setStatus("submitting"); + setErrorMessage(""); + + try { + const res = await fetch("/api/contact", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(formData), + }); + + const data = await res.json(); + + if (!res.ok) { + throw new Error(data.error || "Something went wrong"); + } + + setStatus("success"); + setFormData({ + firstName: "", + lastName: "", + email: "", + company: "", + lookingFor: "", + message: "", + }); + } catch (error) { + setStatus("error"); + setErrorMessage(error instanceof Error ? error.message : "Failed to submit form"); + } + }; + + return ( +
+ {/* Hero / Header Section */} +
+
+

+ Let's start a + + conversation + +

+

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

+
+
+ + {/* Main Content - Split Layout */} +
+
+
+ + {/* Left Side: Community (Discord) */} +
+ {/* 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. +

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

Contact Us

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

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

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