"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import type { CommunicationSettings } from "@/actions/communications/settings"; import { upsertCommunicationSettings } from "@/actions/communications/settings"; const BRAND_ID = process.env.NEXT_PUBLIC_TUXEDO_BRAND_ID ?? "64294306-5f42-463d-a5e8-2ad6c81a96de"; export default function CommunicationSettingsForm({ settings, brandId, }: { settings: CommunicationSettings | null; brandId: string; }) { const router = useRouter(); const [saving, setSaving] = useState(false); const [senderEmail, setSenderEmail] = useState(settings?.default_sender_email ?? ""); const [senderName, setSenderName] = useState(settings?.default_sender_name ?? ""); const [replyTo, setReplyTo] = useState(settings?.reply_to_email ?? ""); const [footerHtml, setFooterHtml] = useState(settings?.email_footer_html ?? ""); const [error, setError] = useState(""); const [success, setSuccess] = useState(false); const handleSave = async () => { setSaving(true); setError(""); setSuccess(false); const result = await upsertCommunicationSettings({ brand_id: brandId, sender_email: senderEmail, sender_name: senderName, reply_to_email: replyTo, provider: "resend", footer_html: footerHtml, }); setSaving(false); if (!result.success) { setError(result.error ?? "Failed to save"); return; } setSuccess(true); router.refresh(); }; return (

Sender Settings

Configure the default sender identity for this brand's email campaigns. Provider (Resend) is configured via environment variables — no credentials stored here.

{error && (
{error}
)} {success && (
Settings saved successfully.
)}
setSenderEmail(e.target.value)} className="w-full border border-zinc-600 rounded-lg px-3 py-2 text-sm" placeholder="orders@tuxedocorn.com" />
setSenderName(e.target.value)} className="w-full border border-zinc-600 rounded-lg px-3 py-2 text-sm" placeholder="Route Commerce" />
setReplyTo(e.target.value)} className="w-full border border-zinc-600 rounded-lg px-3 py-2 text-sm" placeholder="support@tuxedocorn.com" />