working brevo on homepage

This commit is contained in:
2025-12-08 11:41:01 -05:00
parent 2cd871b529
commit 6b0e0334b0
5 changed files with 104 additions and 40 deletions
+61
View File
@@ -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 }
);
}
}
+7 -1
View File
@@ -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 (
+36
View File
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1001.79 154.88">
<defs>
<style>
.cls-1 {
font-family: AgencyFB-Bold, AgencyFB;
font-size: 134.88px;
font-weight: 700;
}
.cls-1, .cls-2 {
fill: #f0efef;
}
.cls-3 {
letter-spacing: .06em;
}
.cls-4 {
letter-spacing: .05em;
}
.cls-5 {
letter-spacing: .05em;
}
.cls-6 {
letter-spacing: 0em;
}
</style>
</defs>
<g id="Layer_1-2" data-name="Layer 1">
<text class="cls-1" transform="translate(202.12 121.28)"><tspan class="cls-5" x="0" y="0">B</tspan><tspan class="cls-6" x="69.06" y="0">A</tspan><tspan class="cls-3" x="130.83" y="0">T</tspan><tspan class="cls-4" x="191.79" y="0">TLBUILDERS</tspan></text>
<path class="cls-2" d="M155.87,0v108.05l-46.85,46.84H0V46.84L46.85,0h109.02ZM128.96,14.84H62.16v31.53h35.72l31.08-31.53ZM46.39,46.37v-24.11l-24.12,24.11h24.12ZM140.1,92.75V25.97l-31.55,31.07v35.71h31.55ZM46.39,61.21H15.77v66.78l30.62-30.14v-36.63ZM93.71,61.21h-31.55v31.53h31.55v-31.53ZM93.71,108.51h-36.65c-8.09,9.81-21.24,18.92-28.77,28.74-.72.93-1.79,1.17-1.39,2.79h65.41l1.39-1.39v-30.14ZM133.6,108.51h-25.05v24.11c1.62.4,1.85-.67,2.79-1.39,7.57-5.8,15.12-16.08,22.26-22.73Z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB