From 6b0e0334b05df19bd17c434cf275c0f31ebef02d Mon Sep 17 00:00:00 2001 From: Sean Date: Mon, 8 Dec 2025 11:41:01 -0500 Subject: [PATCH] working brevo on homepage --- .env-local | 1 - app/api/beta-signup/route.ts | 61 ++++++++++++++++++++++++++++ app/layout.tsx | 8 +++- app/public/battl/battl-logo-mark.svg | 36 ++++++++++++++++ lib/api/beta-signup/route.ts | 38 ----------------- 5 files changed, 104 insertions(+), 40 deletions(-) delete mode 100644 .env-local create mode 100644 app/api/beta-signup/route.ts create mode 100644 app/public/battl/battl-logo-mark.svg delete mode 100644 lib/api/beta-signup/route.ts diff --git a/.env-local b/.env-local deleted file mode 100644 index 96b67ff..0000000 --- a/.env-local +++ /dev/null @@ -1 +0,0 @@ -NEXT_PUBLIC_API_BASE_URL=http://localhost:8080 \ No newline at end of file diff --git a/app/api/beta-signup/route.ts b/app/api/beta-signup/route.ts new file mode 100644 index 0000000..2ba279e --- /dev/null +++ b/app/api/beta-signup/route.ts @@ -0,0 +1,61 @@ +import { NextResponse } from "next/server"; + +const BREVO_API_KEY = process.env.BREVO_API_KEY; +const BREVO_LIST_ID = process.env.BREVO_LIST_ID; // optional + +export async function POST(req: Request) { + if (!BREVO_API_KEY) { + console.error("BREVO_API_KEY is not set"); + return NextResponse.json( + { error: "Server not configured" }, + { status: 500 } + ); + } + + try { + const { email } = await req.json(); + + if (!email || typeof email !== "string") { + return NextResponse.json( + { error: "Valid email is required" }, + { status: 400 } + ); + } + + // Brevo contacts API + const res = await fetch("https://api.brevo.com/v3/contacts", { + method: "POST", + headers: { + "Content-Type": "application/json", + "api-key": BREVO_API_KEY, + }, + body: JSON.stringify({ + email, + updateEnabled: true, // update if already exists + ...(BREVO_LIST_ID + ? { listIds: [Number(BREVO_LIST_ID)] } + : {}), + attributes: { + SOURCE: "Battl Builders Beta", + }, + }), + }); + + if (!res.ok) { + const text = await res.text(); + console.error("Brevo error:", res.status, text); + return NextResponse.json( + { error: "Failed to subscribe" }, + { status: 500 } + ); + } + + return NextResponse.json({ ok: true }); + } catch (err) { + console.error(err); + return NextResponse.json( + { error: "Something went wrong" }, + { status: 500 } + ); + } +} \ No newline at end of file diff --git a/app/layout.tsx b/app/layout.tsx index 2b9ba81..b7992de 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -4,8 +4,14 @@ import type { ReactNode } from "react"; import { AuthProvider } from "@/context/AuthContext"; import { Banner } from "@/components/Banner"; -import { TopNav } from "@/components/TopNav"; +export const metadata = { + title: { + default: "Battl Builders", + template: "%s — Battl Builders", + }, + description: "Build rifles smarter, not harder.", +}; export default function RootLayout({ children }: { children: ReactNode }) { return ( diff --git a/app/public/battl/battl-logo-mark.svg b/app/public/battl/battl-logo-mark.svg new file mode 100644 index 0000000..dea15e0 --- /dev/null +++ b/app/public/battl/battl-logo-mark.svg @@ -0,0 +1,36 @@ + + + + + + + BATTLBUILDERS + + + \ No newline at end of file diff --git a/lib/api/beta-signup/route.ts b/lib/api/beta-signup/route.ts deleted file mode 100644 index 857a6fc..0000000 --- a/lib/api/beta-signup/route.ts +++ /dev/null @@ -1,38 +0,0 @@ -// app/api/beta-signup/route.ts -import { NextResponse } from "next/server"; - -export async function POST(request: Request) { - try { - const { email, useCase } = await request.json(); - - if (!email || typeof email !== "string") { - return NextResponse.json({ error: "Email is required" }, { status: 400 }); - } - - // TODO: Wire this to Brevo - // - Either call Brevo's API directly from here - // - Or POST to your Spring backend which then talks to Brevo - // - // Example (pseudo): - // await fetch("https://api.brevo.com/v3/contacts", { - // method: "POST", - // headers: { - // "Content-Type": "application/json", - // "api-key": process.env.BREVO_API_KEY!, - // }, - // body: JSON.stringify({ - // email, - // attributes: { USE_CASE: useCase }, - // listIds: [123], // your Brevo list ID - // updateEnabled: true, - // }), - // }); - - console.log("New beta signup:", { email, useCase }); - - return NextResponse.json({ ok: true }); - } catch (err) { - console.error(err); - return NextResponse.json({ error: "Server error" }, { status: 500 }); - } -} \ No newline at end of file