'use client' import { useState } from 'react' export default function Signup() { const [email, setEmail] = useState('') const [whatsapp, setWhatsapp] = useState('') const [loading, setLoading] = useState(false) const [showPopup, setShowPopup] = useState(false) const [error, setError] = useState('') const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setError('') // Validate that at least one field is filled if (!email.trim() && !whatsapp.trim()) { setError('Please enter at least an email or phone number') return } setLoading(true) try { const response = await fetch('/api/notifications/subscribe', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ email: email.trim(), phone: whatsapp.trim(), }), }) const data = await response.json() if (!response.ok) { throw new Error(data.error || 'Failed to subscribe') } // Show success popup setShowPopup(true) // Clear form setEmail('') setWhatsapp('') // Hide popup after 5 seconds setTimeout(() => { setShowPopup(false) }, 5000) } catch (err) { setError(err instanceof Error ? err.message : 'An error occurred') } finally { setLoading(false) } } return ( <>
Receive updates about new drops via email or WhatsApp.
You will receive a notification as soon as a new drop drops.