courrier clean 2

This commit is contained in:
alma 2025-04-26 12:55:18 +02:00
parent 10b08b5043
commit 2c98417f50

View File

@ -4,12 +4,13 @@ import React from 'react';
import { useState, useEffect, useRef, useCallback, useMemo } from 'react'; import { useState, useEffect, useRef, useCallback, useMemo } from 'react';
import { useRouter } from 'next/navigation'; import { useRouter } from 'next/navigation';
import { import {
ChevronDown, ChevronUp, Search, Inbox, Trash, Star, Menu, X, Send, Mail, Search, Plus as PlusIcon, Trash, Check, Forward, FolderOpen,
Reply, ReplyAll, CornerUpRight, RefreshCw, Check, MoreVertical, Paperclip, MessageSquare, Copy, AlertOctagon, MoreHorizontal, ChevronDown,
Trash2, Archive, Eye, EyeOff, FileDown, FilePlus, Ban, Filter, Mail, ChevronUp, X, RefreshCw, Inbox, Send, Archive, Star, Settings,
MailOpen, AlertCircle, Folder, ChevronLeft, ChevronRight, Edit, Menu, Plus, Loader2, MailX, UserPlus, CheckCircle2, XCircle, Filter,
Forward, FolderOpen, MessageSquare, Copy, AlertOctagon, MoreHorizontal, Reply, ReplyAll, AlertCircle, Folder, Eye, ChevronLeft, ChevronRight,
Plus as PlusIcon Paperclip, Trash2, CornerUpRight, Edit, MoreVertical, EyeOff, FileDown,
FilePlus, Ban, MailOpen
} from 'lucide-react'; } from 'lucide-react';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card'; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card';
@ -53,6 +54,7 @@ import ComposeEmail from '@/components/ComposeEmail';
import { decodeEmail, cleanHtml } from '@/lib/mail-parser-wrapper'; import { decodeEmail, cleanHtml } from '@/lib/mail-parser-wrapper';
import { Attachment as MailParserAttachment } from 'mailparser'; import { Attachment as MailParserAttachment } from 'mailparser';
import { LoadingFix } from './loading-fix'; import { LoadingFix } from './loading-fix';
import { getEmailContent } from '@/lib/services/email-service';
export interface Account { export interface Account {
id: number; id: number;
@ -1583,51 +1585,37 @@ export default function CourrierPage() {
text: content.text || '', text: content.text || '',
contentFetched: true, contentFetched: true,
// Add proper from/to/cc format for client-side formatters // Add proper from/to/cc format for client-side formatters
from: content.from, from: typeof content.from === 'string' ? content.from : content.from[0]?.address || '',
to: content.to, fromName: typeof content.from === 'string' ? '' : content.from[0]?.name || '',
cc: content.cc, to: typeof content.to === 'string' ? content.to : content.to[0]?.address || '',
bcc: content.bcc, cc: typeof content.cc === 'string' ? content.cc : content.cc?.[0]?.address || '',
date: content.date bcc: typeof content.bcc === 'string' ? content.bcc : content.bcc?.[0]?.address || '',
date: typeof content.date === 'string' ? content.date : content.date.toString()
}; };
setSelectedEmail(updatedEmail); setSelectedEmail(updatedEmail);
// For forwarding, we need to set the forwardFrom prop with the updated content // For forwarding, we need to set the isForwarding flag to true
if (type === 'forward') { if (type === 'forward') {
console.log('[DEBUG] Setting forwardFrom with content for forwarding'); console.log('[DEBUG] Setting isForwarding flag for forwarding');
setForwardFrom(updatedEmail); setIsForwarding(true);
} else { } else {
// For replying, we need to set the replyTo prop with the correct reply type // For replying, we need to set isReplying to true
console.log('[DEBUG] Setting replyTo with content for replying'); console.log('[DEBUG] Setting isReplying to true for replying');
setReplyTo({ setIsReplying(true);
...updatedEmail, // Store the reply type in the component state if needed
replyType: type === 'reply-all' ? 'replyAll' : 'reply' // Convert to format expected by formatter setReplyToEmail(updatedEmail);
});
} }
} }
} else { } else {
// Content already loaded, just set the props // Content already loaded, just set the flags
// Make sure the email has the correct format for client-side formatters
const formattedEmail = {
...selectedEmail,
// Ensure we have proper address objects for the formatters
from: selectedEmail.from ?
(Array.isArray(selectedEmail.from) ? selectedEmail.from : [{ address: selectedEmail.from, name: selectedEmail.fromName }]) :
[{ address: selectedEmail.from || '', name: selectedEmail.fromName }],
to: selectedEmail.to ?
(Array.isArray(selectedEmail.to) ? selectedEmail.to : [{ address: selectedEmail.to }]) :
[{ address: selectedEmail.to || '' }]
};
if (type === 'forward') { if (type === 'forward') {
console.log('[DEBUG] Setting forwardFrom for forwarding (content already loaded)'); console.log('[DEBUG] Setting isForwarding flag for forwarding (content already loaded)');
setForwardFrom(formattedEmail); setIsForwarding(true);
} else { } else {
console.log('[DEBUG] Setting replyTo for replying (content already loaded)'); console.log('[DEBUG] Setting isReplying to true (content already loaded)');
setReplyTo({ setIsReplying(true);
...formattedEmail, setReplyToEmail(selectedEmail);
replyType: type === 'reply-all' ? 'replyAll' : 'reply' // Convert to format expected by formatter
});
} }
} }