/** * Coupon Display Section * Controls for styling the coupon box in recovery emails. * Uses GlobalColorPicker so colours can sync with Global Styles. */ import { Label } from '@/components/ui/label'; import { Input } from '@/components/ui/input'; import { GlobalColorPicker } from '@/components/ui/global-color-picker'; import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from '@/components/ui/collapsible'; import { ChevronDown, Ticket } from 'lucide-react'; import { useState } from 'react'; export interface CouponDisplayConfig { /** Background color of the coupon box. */ boxBgColor: string; /** Border color of the coupon box. */ boxBorderColor: string; /** Text color inside the coupon box. */ boxTextColor: string; /** Background color of the coupon code highlight. */ codeBgColor: string; /** The message template. Use {coupon_code} for the code placeholder. */ messageText: string; } export const defaultCouponDisplayConfig: CouponDisplayConfig = { boxBgColor: '#f0fdf4', boxBorderColor: '#bbf7d0', boxTextColor: '#166534', codeBgColor: '#dcfce7', messageText: 'Use code {coupon_code} at checkout for a special discount!', }; interface CouponDisplaySectionProps { config: CouponDisplayConfig; onUpdate: (updates: Partial) => void; } export function CouponDisplaySection({ config, onUpdate, }: CouponDisplaySectionProps) { const [isOpen, setIsOpen] = useState(false); return (
Coupon Display

Coupon box styling

{/* Colors */}

Colors

onUpdate({ boxBgColor: value })} featureDefault="#f0fdf4" /> onUpdate({ boxBorderColor: value })} globalTokenId="border" featureDefault="#bbf7d0" /> onUpdate({ boxTextColor: value })} globalTokenId="text" featureDefault="#166534" /> onUpdate({ codeBgColor: value })} featureDefault="#dcfce7" />
{/* Message Text */}
onUpdate({ messageText: e.target.value })} placeholder="Use code {coupon_code} at checkout for a special discount!" />

Use {'{coupon_code}'} where the code should appear.

{/* Live Preview */}

{config.messageText.split('{coupon_code}').map((part, i, arr) => ( {part} {i < arr.length - 1 && ( RECOVER-A1B2C3 )} ))}

); }