courrier refactor rebuild 2

This commit is contained in:
alma 2025-04-27 12:15:39 +02:00
parent c92f593caa
commit 021df6b169

View File

@ -16,6 +16,7 @@ import ComposeEmailHeader from './ComposeEmailHeader';
import ComposeEmailForm from './ComposeEmailForm';
import ComposeEmailFooter from './ComposeEmailFooter';
import RichEmailEditor from './RichEmailEditor';
import QuotedEmailContent from './QuotedEmailContent';
// Import ONLY from the centralized formatter
import {
@ -99,6 +100,38 @@ function isLegacyProps(
return 'showCompose' in props;
}
// Helper function to adapt EmailMessage to QuotedEmailContent props format
function EmailMessageToQuotedContentAdapter({
email,
type
}: {
email: EmailMessage,
type: 'reply' | 'reply-all' | 'forward'
}) {
// Get the email content
const content = email.content || email.html || email.text || '';
// Get the sender
const sender = email.from && email.from.length > 0
? {
name: email.from[0].name,
email: email.from[0].address
}
: { email: 'unknown@example.com' };
// Map the type to what QuotedEmailContent expects
const mappedType = type === 'reply-all' ? 'reply' : type;
return (
<QuotedEmailContent
content={content}
sender={sender}
date={email.date}
type={mappedType}
/>
);
}
export default function ComposeEmail(props: ComposeEmailAllProps) {
// Handle legacy props by adapting them to new component
if (isLegacyProps(props)) {