compose mime
This commit is contained in:
parent
9a762927fc
commit
b025baa6c1
@ -1216,15 +1216,11 @@ export default function CourrierPage() {
|
|||||||
</nav>
|
</nav>
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add back the handleReply function
|
// Update handleReply function
|
||||||
const handleReply = async (type: 'reply' | 'reply-all' | 'forward') => {
|
const handleReply = async (type: 'reply' | 'reply-all' | 'forward') => {
|
||||||
if (!selectedEmail) return;
|
if (!selectedEmail) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Get the decoded content first
|
|
||||||
const decoded = await decodeEmail(selectedEmail.body);
|
|
||||||
|
|
||||||
// Set up the reply details
|
|
||||||
const getReplyTo = () => {
|
const getReplyTo = () => {
|
||||||
if (type === 'forward') return '';
|
if (type === 'forward') return '';
|
||||||
return selectedEmail.from;
|
return selectedEmail.from;
|
||||||
@ -1243,45 +1239,14 @@ export default function CourrierPage() {
|
|||||||
return subject.startsWith('Re:') ? subject : `Re: ${subject}`;
|
return subject.startsWith('Re:') ? subject : `Re: ${subject}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create the appropriate email content based on type
|
// Set the appropriate flags
|
||||||
let formattedContent = '';
|
setIsReplying(type === 'reply' || type === 'reply-all');
|
||||||
if (type === 'forward') {
|
setIsForwarding(type === 'forward');
|
||||||
formattedContent = `
|
|
||||||
<div style="min-height: 100px;">
|
|
||||||
<br/>
|
|
||||||
<div style="border-top: 1px solid #e5e7eb; margin-top: 20px; padding-top: 10px; color: #666;">
|
|
||||||
---------- Forwarded message ---------<br/>
|
|
||||||
From: ${selectedEmail.from}<br/>
|
|
||||||
Date: ${new Date(selectedEmail.date).toLocaleString()}<br/>
|
|
||||||
Subject: ${selectedEmail.subject}<br/>
|
|
||||||
To: ${selectedEmail.to}<br/>
|
|
||||||
${selectedEmail.cc ? `Cc: ${selectedEmail.cc}<br/>` : ''}
|
|
||||||
<br/>
|
|
||||||
<div style="margin-top: 10px;">
|
|
||||||
${decoded.html || decoded.text || ''}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
} else {
|
|
||||||
// For reply and reply-all
|
|
||||||
formattedContent = `
|
|
||||||
<div style="min-height: 100px;">
|
|
||||||
<br/>
|
|
||||||
<div style="border-left: 2px solid #e5e7eb; margin: 10px 0; padding-left: 10px; color: #666;">
|
|
||||||
On ${new Date(selectedEmail.date).toLocaleString()}, ${selectedEmail.from} wrote:<br/>
|
|
||||||
<br/>
|
|
||||||
${decoded.html || decoded.text || ''}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the compose form
|
// Update the compose form
|
||||||
setComposeTo(getReplyTo());
|
setComposeTo(getReplyTo());
|
||||||
setComposeCc(getReplyCc());
|
setComposeCc(getReplyCc());
|
||||||
setComposeSubject(getReplySubject());
|
setComposeSubject(getReplySubject());
|
||||||
setComposeBody(formattedContent);
|
|
||||||
setComposeBcc('');
|
setComposeBcc('');
|
||||||
setShowCompose(true);
|
setShowCompose(true);
|
||||||
setShowCc(type === 'reply-all');
|
setShowCc(type === 'reply-all');
|
||||||
@ -1523,9 +1488,13 @@ export default function CourrierPage() {
|
|||||||
attachments={attachments}
|
attachments={attachments}
|
||||||
setAttachments={setAttachments}
|
setAttachments={setAttachments}
|
||||||
handleSend={handleSend}
|
handleSend={handleSend}
|
||||||
|
replyTo={isReplying ? selectedEmail : null}
|
||||||
|
forwardFrom={isForwarding ? selectedEmail : null}
|
||||||
onSend={(email) => {
|
onSend={(email) => {
|
||||||
console.log('Email sent:', email);
|
console.log('Email sent:', email);
|
||||||
setShowCompose(false);
|
setShowCompose(false);
|
||||||
|
setIsReplying(false);
|
||||||
|
setIsForwarding(false);
|
||||||
}}
|
}}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
setShowCompose(false);
|
setShowCompose(false);
|
||||||
@ -1537,6 +1506,8 @@ export default function CourrierPage() {
|
|||||||
setShowCc(false);
|
setShowCc(false);
|
||||||
setShowBcc(false);
|
setShowBcc(false);
|
||||||
setAttachments([]);
|
setAttachments([]);
|
||||||
|
setIsReplying(false);
|
||||||
|
setIsForwarding(false);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{renderDeleteConfirmDialog()}
|
{renderDeleteConfirmDialog()}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user