import React from 'react' import { Type, HeartHandshake, Info, MoreHorizontal, Smile } from 'lucide-react' import { GhostButton } from './settings-ui' import { Separator } from './separator' import { Popover, PopoverContent, PopoverTrigger } from './popover' import { WhatsAppEditor } from './whatsapp-editor' import { EmojiPickerButton, FormattingHelpButton } from './whatsapp-toolbar' import { WhatsAppSpamChecker, WhatsAppQAResults } from './whatsapp-qa-diagnostic' import { cn } from "@/lib/utils" interface Rule { [key: string]: unknown; trigger_key?: string; } interface WhatsAppEditorSectionProps { rule: Rule; updateRule: (updates: Partial) => void; isAdmin: boolean; isCampaign: boolean; isMeta: boolean; messageField: string; finalEditorId: string; placeholders?: Record; onOpenPersonalization: (editorId: string) => void; onKeyDown?: (e: React.KeyboardEvent) => void; } export function WhatsAppEditorSection({ rule, updateRule, isAdmin, isCampaign, isMeta, messageField, finalEditorId, placeholders, onOpenPersonalization, onKeyDown, }: WhatsAppEditorSectionProps) { const [isQAOpen, setQAOpen] = React.useState(false); const activeContent = String(rule[messageField] || ''); const handleContentChange = (val: string) => { updateRule({ [messageField]: val }); }; const greetings = [ { label: 'اهلا', value: 'اهلا {{user_login}}' }, { label: 'مرحبا', value: 'مرحبا بك يا {{user_login}}' }, { label: 'السلام عليكم', value: 'السلام عليكم ورحمة الله وبركاته' }, { label: 'تحية طيبة', value: 'تحية طيبة وبعد،' }, { label: 'عزيزي', value: 'عزيزي {{user_login}}،' }, { label: 'Hi (Eng)', value: 'Hi {{user_login}} 👋' }, { label: 'Welcome', value: 'Welcome to {{site_name}}!' } ]; const [visibleTools, setVisibleTools] = React.useState(['greetings', 'personalize', 'emoji']); const ALL_TOOLS = [ { id: 'greetings', label: 'Greetings', icon: HeartHandshake }, { id: 'personalize', label: 'Personalize', icon: Type }, { id: 'emoji', label: 'Emoji', icon: Smile }, { id: 'formatting', label: 'Help', icon: Info }, ]; const handleToolSelect = (toolId: string) => { if (!visibleTools.includes(toolId)) { const newVisible = [...visibleTools]; newVisible[2] = toolId; // Swap the last one setVisibleTools(newVisible); } }; const renderTool = (toolId: string) => { switch (toolId) { case 'greetings': return ( Greetings
Smart Greetings
{greetings.map((g, i) => ( ))}
); case 'personalize': return ( onOpenPersonalization(finalEditorId)} icon={Type} > Personalize ); case 'emoji': return ; case 'formatting': return ; default: return null; } }; return (
{visibleTools.map(renderTool)} {null}
All Tools
{ALL_TOOLS.map((tool) => ( ))}
setQAOpen(!isQAOpen)} /> {activeContent.length} CHARS
{/* Integrated QA Diagnostic Panel - Tied to this side */}
); }