From 773c7759c4b97ead6371528ab491bb46f8debe7e Mon Sep 17 00:00:00 2001 From: alma Date: Sat, 26 Apr 2025 21:12:48 +0200 Subject: [PATCH] courrier clean 2$ --- components/ComposeEmail.tsx | 429 ------------------------------------ 1 file changed, 429 deletions(-) delete mode 100644 components/ComposeEmail.tsx diff --git a/components/ComposeEmail.tsx b/components/ComposeEmail.tsx deleted file mode 100644 index d02800ad..00000000 --- a/components/ComposeEmail.tsx +++ /dev/null @@ -1,429 +0,0 @@ -'use client'; - -import React, { useEffect, useState, useRef } from 'react'; -import { X, Paperclip, ChevronDown, ChevronUp, SendHorizontal, Loader2 } from 'lucide-react'; -import { Button } from '@/components/ui/button'; -import { Input } from '@/components/ui/input'; -import { Textarea } from '@/components/ui/textarea'; -import { Label } from '@/components/ui/label'; -import { sanitizeHtml } from '@/lib/utils/email-formatter'; - -// Simple CSS for email styling - leverages our centralized sanitization for text direction -const emailStyles = ` -.email-content { - font-family: Arial, sans-serif; -} -.quoted-content { - margin-top: 20px; - border-top: 1px solid #e2e2e2; - padding-top: 10px; - color: #555; -} -.user-message { - margin-bottom: 20px; -} -`; - -// Nous simplifions l'interface car nous n'utilisons plus ces props -interface EmailObject { - id?: string; - from?: string; - fromName?: string; - to?: string; - subject?: string; - content?: string; - html?: string; - text?: string; - body?: string; - date?: string; - read?: boolean; - starred?: boolean; - attachments?: { name: string; url: string }[]; - folder?: string; - cc?: string; - bcc?: string; -} - -interface ComposeEmailProps { - showCompose: boolean; - setShowCompose: (show: boolean) => void; - composeTo: string; - setComposeTo: (to: string) => void; - composeCc: string; - setComposeCc: (cc: string) => void; - composeBcc: string; - setComposeBcc: (bcc: string) => void; - composeSubject: string; - setComposeSubject: (subject: string) => void; - composeBody: string; - setComposeBody: (body: string) => void; - showCc: boolean; - setShowCc: (show: boolean) => void; - showBcc: boolean; - setShowBcc: (show: boolean) => void; - attachments: any[]; - setAttachments: (attachments: any[]) => void; - handleSend: () => Promise; - originalEmail?: { - content: string; - type: 'reply' | 'reply-all' | 'forward'; - }; - onSend: (email: any) => Promise; - onCancel: () => void; - // Nous laissons ces props pour la rétrocompatibilité mais nous ne les utilisons plus - replyTo?: EmailObject | null; - forwardFrom?: EmailObject | null; -} - -export default function ComposeEmail({ - showCompose, - setShowCompose, - composeTo, - setComposeTo, - composeCc, - setComposeCc, - composeBcc, - setComposeBcc, - composeSubject, - setComposeSubject, - composeBody, - setComposeBody, - showCc, - setShowCc, - showBcc, - setShowBcc, - attachments, - setAttachments, - handleSend, - originalEmail, - // replyTo et forwardFrom ne sont plus utilisés - replyTo, - forwardFrom, - onSend, - onCancel -}: ComposeEmailProps) { - const [isSending, setIsSending] = useState(false); - const fileInputRef = useRef(null); - const contentEditableRef = useRef(null); - // Si nous avons un contenu préformaté, nous utilisons toujours l'éditeur riche - const [useRichEditor, setUseRichEditor] = useState(!!composeBody); - const [userMessage, setUserMessage] = useState(''); - // Nous extrarons la partie de contenu citée du corps de l'email préformaté - const [quotedContent, setQuotedContent] = useState(''); - const [hasStartedTyping, setHasStartedTyping] = useState(false); - - useEffect(() => { - // Utiliser l'éditeur riche si nous avons du contenu HTML - if (composeBody && composeBody.includes('<')) { - setUseRichEditor(true); - - // Séparer le contenu de l'utilisateur (vide) et le contenu cité (préformaté) - setUserMessage(''); - setQuotedContent(composeBody); - } - }, [composeBody]); - - // Nous n'avons plus besoin de ces effets qui initialisaient replyTo et forwardFrom - // useEffect(() => { - // if (replyTo) { - // initializeReplyEmail(replyTo); - // } - // }, [replyTo, setComposeTo, setComposeSubject, setComposeBody]); - // - // useEffect(() => { - // if (forwardFrom) { - // initializeForwardedEmail(forwardFrom); - // } - // }, [forwardFrom]); - - // Nous n'avons plus besoin de ces fonctions qui initialisaient le contenu - // via formatEmailForReply et formatEmailForForward - // const initializeForwardedEmail = async (email: any) => {...}; - // const initializeReplyEmail = async (email: any, replyType: 'reply' | 'replyAll' = 'reply') => {...}; - - // Handle file attachment selection - const handleFileAttachment = (e: React.ChangeEvent) => { - if (e.target.files) { - const newFiles = Array.from(e.target.files); - setAttachments([...attachments, ...newFiles]); - } - }; - - // Handle contentEditable input changes - const handleUserMessageChange = () => { - if (contentEditableRef.current) { - let content = contentEditableRef.current.innerHTML; - - // Check if this is the initial state or if the user has actually typed something - if (content && content !== '

Write your message here...

') { - setHasStartedTyping(true); - } - - // Sanitize the user's message using our centralized sanitizer - content = sanitizeHtml(content); - setUserMessage(content); - - // Combine user message with quoted content for the full email body - const combined = `${content}${quotedContent ? `
${quotedContent}
` : ''}`; - setComposeBody(combined); - } - }; - - // Handle sending email with combined content - const handleSendWithCombinedContent = async () => { - if (isSending) return; - - try { - setIsSending(true); - - // For rich editor, combine user message with quoted content - if (useRichEditor) { - // Wrap the content with appropriate styling - const userContent = userMessage ? `
${userMessage}
` : ''; - const quotedWithStyles = quotedContent ? `
${quotedContent}
` : ''; - - // Use our centralized sanitizer to ensure proper direction - const combinedContent = sanitizeHtml(`${userContent}${quotedWithStyles}`); - - setComposeBody(combinedContent); - - // Wait for state update to complete - await new Promise(resolve => setTimeout(resolve, 0)); - } - - // Call the provided onSend function - await onSend({ - to: composeTo, - cc: composeCc, - bcc: composeBcc, - subject: composeSubject, - body: composeBody, - attachments: attachments - }); - - // Reset the compose state - setShowCompose(false); - setComposeTo(''); - setComposeCc(''); - setComposeBcc(''); - setComposeSubject(''); - setComposeBody(''); - setShowCc(false); - setShowBcc(false); - setAttachments([]); - setUserMessage(''); - setQuotedContent(''); - - } catch (error) { - console.error('Failed to send email:', error); - } finally { - setIsSending(false); - } - }; - - return ( - <> - {/* Compose Email Modal */} - {showCompose && ( -
- {/* Add global styles for email direction */} -