import { useSendTelemetryEvent } from '~/lib/telemetry' import Link from 'next/link' import { useState } from 'react' import { Button, Input, Label } from 'ui' const isValidEmail = (email: string): boolean => { const emailPattern = /^[\w-\.+]+@([\w-]+\.)+[\w-]{2,8}$/ return emailPattern.test(email) } /** * Subscribe form for subprocessor update notifications. * Mirrors components/SecurityNewsletterForm.tsx, posting to the * /api-v2/submit-form-subprocessor-updates route (Customer.io "Subprocessor Alerts", topic_4). */ const SubprocessorUpdatesForm = () => { const [firstName, setFirstName] = useState('') const [lastName, setLastName] = useState('') const [email, setEmail] = useState('') const [status, setStatus] = useState<'idle' | 'loading' | 'success' | 'error'>('idle') const [errorMessage, setErrorMessage] = useState('') const sendTelemetryEvent = useSendTelemetryEvent() const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setErrorMessage('') if (!firstName || !lastName || !email) { setErrorMessage('All fields are required.') return } if (!isValidEmail(email)) { setErrorMessage('Please enter a valid email address.') return } setStatus('loading') try { const res = await fetch('/api-v2/submit-form-subprocessor-updates', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ firstName, lastName, email }), }) if (!res.ok) { const data = await res.json() throw new Error(data.message || 'Something went wrong') } setStatus('success') sendTelemetryEvent({ action: 'www_subprocessor_updates_subscribed' }) } catch (err: any) { setStatus('error') setErrorMessage(err.message || 'Something went wrong. Please try again.') } } return (
Subscribe to updates. Receive an email notification when Supabase updates its sub-processors. By submitting this form, you acknowledge and agree that Supabase will process your personal information in accordance with our{' '} Privacy Policy .
{status === 'success' ? (Thanks for subscribing! You'll receive an email when Supabase updates its sub-processors.
) : ( )}