import { useState } from "react" import { Mail, Paintbrush } from "lucide-react" import { Label } from "@/components/ui/label" import { Input } from "@/components/ui/input" import { Switch } from "@/components/ui/switch" import { Button } from "@/components/ui/button" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { EmailCustomizer } from "@/components/email-customizer" import type { EmailContentSettings, PlaceholderCategoryLabel, PlaceholderConfig, ProductCardConfig } from "@/components/email-customizer/sections" import { AbandonedCartSettings, EmailSequenceItem } from "../../types" interface BasicEmailTabProps { settings: AbandonedCartSettings updateSettings: (updates: Partial) => void updateEmail: (index: number, updates: Partial) => void } const placeholders: PlaceholderConfig[] = [ { tag: "{customer_name}", description: "Customer first name or “there” for guests", example: "John", category: "customer" }, { tag: "{customer_email}", description: "Customer email address", example: "john@example.com", category: "customer" }, { tag: "{cart_total}", description: "Cart total with currency", example: "$149.99", category: "cart" }, { tag: "{recovery_link}", description: "Unique cart recovery URL", example: "https://store.com/?recover=abc123", category: "cart" }, { tag: "{unsubscribe_link}", description: "Recovery-email opt-out URL", example: "https://store.com/?unsubscribe=abc123", category: "site" }, { tag: "{site_name}", description: "Website name", example: "My Store", category: "site" }, { tag: "{site_url}", description: "Website URL", example: "https://store.com", category: "site" }, ] const categoryLabels: Record = { customer: { label: "Customer", color: "bg-green-100 text-green-700" }, cart: { label: "Cart", color: "bg-blue-100 text-blue-700" }, site: { label: "Site", color: "bg-orange-100 text-orange-700" }, } const sampleProduct = { name: "Premium Wireless Headphones", price: "$79.99", imageUrl: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Crect fill='%23f3f4f6' width='200' height='200'/%3E%3Cpath d='M70 130l30-50 30 50' fill='none' stroke='%23d1d5db' stroke-width='4'/%3E%3C/svg%3E", productUrl: "#", } export function BasicEmailTab({ settings, updateSettings, updateEmail }: BasicEmailTabProps) { const [showCustomizer, setShowCustomizer] = useState(false) const email = settings.emails[0] const content: EmailContentSettings = { subject: email?.subject || "You left something in your cart!", heading: settings.emailHeading || "Your cart is waiting!", body: settings.emailBodyText || "Hi {customer_name},\n\nIt looks like you left some items in your cart at {site_name}. Your cart is saved and ready for you.", additionalContent: "", preheaderText: "", } const productCard: ProductCardConfig = { showImage: settings.emailShowImage ?? true, showTitle: settings.emailShowTitle ?? true, showPrice: settings.emailShowPrice ?? true, buttonText: settings.emailButtonText || "Complete Your Order", sample: sampleProduct, } if (!email) return null return ( <> {showCustomizer && ( setShowCustomizer(false)} emailType={{ id: "abandoned_cart_reminder", label: "Cart Recovery Email", defaultContent: content, }} initialContent={content} onSaveContent={(nextContent) => { updateSettings({ emailHeading: nextContent.heading, emailBodyText: nextContent.body }) updateEmail(0, { subject: nextContent.subject }) }} productCard={productCard} onSaveProductCard={(card) => updateSettings({ emailShowImage: card.showImage, emailShowTitle: card.showTitle, emailShowPrice: card.showPrice, emailButtonText: card.buttonText, })} placeholders={placeholders} placeholderCategories={categoryLabels} subjectPlaceholderHint="Available: {customer_name}, {site_name}, {cart_total}" /> )}
Recovery Email Configure the reminder sent after a cart becomes abandoned.
updateEmail(0, { enabled: checked })} />
{email.enabled && (
updateEmail(0, { subject: event.target.value })} />
updateEmail(0, { delay: parseInt(event.target.value) || 1 })} />
)}
Email Template Customize the message and product-card presentation.

Cart Recovery Email

Content, product details, and call-to-action

) }