import React, { useState } from 'react'; import { ChevronDown, ChevronUp, Paperclip, X } from 'lucide-react'; import { Input } from '@/components/ui/input'; import { Button } from '@/components/ui/button'; import { Label } from '@/components/ui/label'; import { Textarea } from '@/components/ui/textarea'; interface ComposeEmailFormProps { to: string; setTo: (value: string) => void; cc: string; setCc: (value: string) => void; bcc: string; setBcc: (value: string) => void; subject: string; setSubject: (value: string) => void; emailContent: string; setEmailContent: (value: string) => void; showCc: boolean; setShowCc: (value: boolean) => void; showBcc: boolean; setShowBcc: (value: boolean) => void; attachments: Array<{ name: string; content: string; type: string; }>; onAttachmentAdd: (files: FileList) => void; onAttachmentRemove: (index: number) => void; } export default function ComposeEmailForm({ to, setTo, cc, setCc, bcc, setBcc, subject, setSubject, emailContent, setEmailContent, showCc, setShowCc, showBcc, setShowBcc, attachments, onAttachmentAdd, onAttachmentRemove }: ComposeEmailFormProps) { const fileInputRef = React.useRef(null); const handleAttachmentClick = () => { fileInputRef.current?.click(); }; const handleFileSelection = (e: React.ChangeEvent) => { if (e.target.files && e.target.files.length > 0) { onAttachmentAdd(e.target.files); } // Reset the input value so the same file can be selected again if (fileInputRef.current) { fileInputRef.current.value = ''; } }; return (
{/* To field */}
setTo(e.target.value)} placeholder="Email address..." className="flex-grow" />
{/* CC field - conditionally shown */} {showCc && (
setCc(e.target.value)} placeholder="CC address..." className="flex-grow" />
)} {/* BCC field - conditionally shown */} {showBcc && (
setBcc(e.target.value)} placeholder="BCC address..." className="flex-grow" />
)} {/* CC/BCC toggle buttons */}
{!showCc && ( )} {!showBcc && ( )} {showCc && ( )} {showBcc && ( )}
{/* Subject field */}
setSubject(e.target.value)} placeholder="Email subject..." className="flex-grow" />
{/* Email content */}