diff --git a/components/newsletter-signup.tsx b/components/newsletter-signup.tsx new file mode 100644 index 0000000..b113db4 --- /dev/null +++ b/components/newsletter-signup.tsx @@ -0,0 +1,95 @@ +"use client" + +import { useState } from "react" +import { Button } from "@/components/ui/button" + +const NEWSLETTER_API = "https://newsletter.jeffemmett.com/api/subscribe" +const LIST_UUID = "0a4810a2-13c7-4ba9-a65b-bc2251283298" // Post-Appitalism list + +export function NewsletterSignup() { + const [email, setEmail] = useState("") + const [status, setStatus] = useState<"idle" | "loading" | "success" | "error">("idle") + const [message, setMessage] = useState("") + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault() + + if (!email) return + + setStatus("loading") + + try { + const response = await fetch(`${NEWSLETTER_API}/subscribe`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + email: email, + list_uuid: LIST_UUID, + }), + }) + + if (response.ok) { + setStatus("success") + setMessage("Welcome to the post-app era. Big things loading...") + setEmail("") + } else { + throw new Error("Subscription failed") + } + } catch { + setStatus("error") + setMessage("Something went wrong. Please try again.") + } + } + + return ( +
+
+
+
+

+ Join the Post-Appitalism Movement +

+

+ Subscribe for updates on building post-capitalist applications + and regenerative digital infrastructure. +

+
+ + {status === "success" ? ( +
+ {message} +
+ ) : ( +
+ setEmail(e.target.value)} + required + className="flex-1 px-4 py-2 rounded-lg border bg-background focus:outline-none focus:ring-2 focus:ring-primary/50" + /> + +
+ )} + + {status === "error" && ( +

{message}

+ )} + +

+ No spam, unsubscribe anytime. We respect your privacy. +

+
+
+
+ ) +}