"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import type { CommunicationSettings } from "@/actions/communications/settings"; import { upsertCommunicationSettings } from "@/actions/communications/settings"; import { AdminButton } from "@/components/admin/design-system"; import { AdminInput, AdminTextInput, AdminTextarea } from "@/components/admin/design-system/AdminFormElements"; // Mail icon for the header const MailIcon = ({ className }: { className?: string }) => ( ); // Check icon for success const CheckIcon = () => ( ); // Warning icon for provider notice const WarningIcon = () => ( ); 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 (
Configure the default sender identity for this brand's email campaigns
Email Provider
Provider (Resend) is configured via environment variables — no credentials stored here.
Unsubscribe: link
"} />{error}
)} {success && (