mail page fix design
This commit is contained in:
parent
adb1117f56
commit
3da88387c5
@ -399,7 +399,7 @@ function getReplyBody(email: Email, type: 'reply' | 'reply-all' | 'forward' = 'r
|
|||||||
// Clean and sanitize HTML content
|
// Clean and sanitize HTML content
|
||||||
content = cleanHtml(content);
|
content = cleanHtml(content);
|
||||||
|
|
||||||
// Format the reply/forward content
|
// Format the reply/forward content with proper structure
|
||||||
let formattedContent = '';
|
let formattedContent = '';
|
||||||
if (type === 'forward') {
|
if (type === 'forward') {
|
||||||
formattedContent = `
|
formattedContent = `
|
||||||
@ -410,7 +410,7 @@ function getReplyBody(email: Email, type: 'reply' | 'reply-all' | 'forward' = 'r
|
|||||||
<p class="text-sm text-gray-600 mb-2">Subject: ${email.subject}</p>
|
<p class="text-sm text-gray-600 mb-2">Subject: ${email.subject}</p>
|
||||||
<p class="text-sm text-gray-600 mb-2">To: ${email.to}</p>
|
<p class="text-sm text-gray-600 mb-2">To: ${email.to}</p>
|
||||||
${email.cc ? `<p class="text-sm text-gray-600 mb-2">Cc: ${email.cc}</p>` : ''}
|
${email.cc ? `<p class="text-sm text-gray-600 mb-2">Cc: ${email.cc}</p>` : ''}
|
||||||
<div class="mt-4 prose-sm">${content}</div>
|
<div class="mt-4 prose-sm" dir="auto">${content}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
@ -419,7 +419,7 @@ function getReplyBody(email: Email, type: 'reply' | 'reply-all' | 'forward' = 'r
|
|||||||
<div class="prose max-w-none" dir="ltr">
|
<div class="prose max-w-none" dir="ltr">
|
||||||
<div class="border-l-4 border-gray-300 pl-4 my-4">
|
<div class="border-l-4 border-gray-300 pl-4 my-4">
|
||||||
<p class="text-sm text-gray-600 mb-2">On ${new Date(email.date).toLocaleString()}, ${email.from} wrote:</p>
|
<p class="text-sm text-gray-600 mb-2">On ${new Date(email.date).toLocaleString()}, ${email.from} wrote:</p>
|
||||||
<div class="mt-4 prose-sm">${content}</div>
|
<div class="mt-4 prose-sm" dir="auto">${content}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
@ -514,6 +514,10 @@ export default function CourrierPage() {
|
|||||||
const [isMarkingUnread, setIsMarkingUnread] = useState(false);
|
const [isMarkingUnread, setIsMarkingUnread] = useState(false);
|
||||||
const [isRefreshing, setIsRefreshing] = useState(false);
|
const [isRefreshing, setIsRefreshing] = useState(false);
|
||||||
const composeBodyRef = useRef<HTMLDivElement>(null);
|
const composeBodyRef = useRef<HTMLDivElement>(null);
|
||||||
|
const [originalEmail, setOriginalEmail] = useState<{
|
||||||
|
content: string;
|
||||||
|
type: 'reply' | 'reply-all' | 'forward';
|
||||||
|
} | null>(null);
|
||||||
|
|
||||||
// Debug logging for email distribution
|
// Debug logging for email distribution
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -1389,9 +1393,13 @@ export default function CourrierPage() {
|
|||||||
const handleReply = (type: 'reply' | 'reply-all' | 'forward') => {
|
const handleReply = (type: 'reply' | 'reply-all' | 'forward') => {
|
||||||
if (!selectedEmail) return;
|
if (!selectedEmail) return;
|
||||||
|
|
||||||
|
// Phase 1: Format the original email content
|
||||||
|
const originalContent = getReplyBody(selectedEmail, type);
|
||||||
|
|
||||||
|
// Phase 2: Set up the composition interface
|
||||||
const getReplyTo = () => {
|
const getReplyTo = () => {
|
||||||
if (type === 'forward') return '';
|
if (type === 'forward') return '';
|
||||||
return selectedEmail.from;
|
return selectedEmail.from;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getReplyCc = () => {
|
const getReplyCc = () => {
|
||||||
@ -1401,25 +1409,17 @@ export default function CourrierPage() {
|
|||||||
|
|
||||||
const getReplySubject = () => {
|
const getReplySubject = () => {
|
||||||
const subject = selectedEmail.subject || '';
|
const subject = selectedEmail.subject || '';
|
||||||
if (type === 'forward') {
|
if (type === 'forward') {
|
||||||
return subject.startsWith('Fwd:') ? subject : `Fwd: ${subject}`;
|
return subject.startsWith('Fwd:') ? subject : `Fwd: ${subject}`;
|
||||||
}
|
}
|
||||||
return subject.startsWith('Re:') ? subject : `Re: ${subject}`;
|
return subject.startsWith('Re:') ? subject : `Re: ${subject}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the reply email
|
|
||||||
const replyEmail = {
|
|
||||||
to: getReplyTo(),
|
|
||||||
cc: getReplyCc(),
|
|
||||||
subject: getReplySubject(),
|
|
||||||
body: getReplyBody(selectedEmail, type)
|
|
||||||
};
|
|
||||||
|
|
||||||
// Update the compose form with the reply content
|
// Update the compose form with the reply content
|
||||||
setComposeTo(replyEmail.to);
|
setComposeTo(getReplyTo());
|
||||||
setComposeCc(replyEmail.cc);
|
setComposeCc(getReplyCc());
|
||||||
setComposeSubject(replyEmail.subject);
|
setComposeSubject(getReplySubject());
|
||||||
setComposeBody(replyEmail.body);
|
setComposeBody(''); // Start with empty body for new content
|
||||||
setComposeBcc('');
|
setComposeBcc('');
|
||||||
|
|
||||||
// Show the compose form and CC field for Reply All
|
// Show the compose form and CC field for Reply All
|
||||||
@ -1427,6 +1427,12 @@ export default function CourrierPage() {
|
|||||||
setShowCc(type === 'reply-all');
|
setShowCc(type === 'reply-all');
|
||||||
setShowBcc(false);
|
setShowBcc(false);
|
||||||
setAttachments([]);
|
setAttachments([]);
|
||||||
|
|
||||||
|
// Pass the formatted original email content to the compose modal
|
||||||
|
setOriginalEmail({
|
||||||
|
content: originalContent,
|
||||||
|
type
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add the confirmation dialog component
|
// Add the confirmation dialog component
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useRef, useEffect } from 'react';
|
import { useRef, useEffect, useState } from 'react';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
@ -28,6 +28,10 @@ interface ComposeEmailProps {
|
|||||||
attachments: any[];
|
attachments: any[];
|
||||||
setAttachments: (attachments: any[]) => void;
|
setAttachments: (attachments: any[]) => void;
|
||||||
handleSend: () => Promise<void>;
|
handleSend: () => Promise<void>;
|
||||||
|
originalEmail?: {
|
||||||
|
content: string;
|
||||||
|
type: 'reply' | 'reply-all' | 'forward';
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ComposeEmail({
|
export default function ComposeEmail({
|
||||||
@ -49,9 +53,11 @@ export default function ComposeEmail({
|
|||||||
setShowBcc,
|
setShowBcc,
|
||||||
attachments,
|
attachments,
|
||||||
setAttachments,
|
setAttachments,
|
||||||
handleSend
|
handleSend,
|
||||||
|
originalEmail
|
||||||
}: ComposeEmailProps) {
|
}: ComposeEmailProps) {
|
||||||
const composeBodyRef = useRef<HTMLDivElement>(null);
|
const composeBodyRef = useRef<HTMLDivElement>(null);
|
||||||
|
const [showOriginalContent, setShowOriginalContent] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (composeBodyRef.current) {
|
if (composeBodyRef.current) {
|
||||||
@ -214,6 +220,29 @@ export default function ComposeEmail({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Original Email Content Preview */}
|
||||||
|
{originalEmail && showOriginalContent && (
|
||||||
|
<div className="border rounded-md p-4 bg-gray-50">
|
||||||
|
<div className="flex items-center justify-between mb-2">
|
||||||
|
<h4 className="text-sm font-medium text-gray-700">
|
||||||
|
{originalEmail.type === 'forward' ? 'Forwarded Message' : 'Original Message'}
|
||||||
|
</h4>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => setShowOriginalContent(false)}
|
||||||
|
className="text-gray-500 hover:text-gray-700"
|
||||||
|
>
|
||||||
|
<X className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="prose max-w-none text-sm text-gray-600"
|
||||||
|
dangerouslySetInnerHTML={{ __html: originalEmail.content }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Message Body */}
|
{/* Message Body */}
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<Label htmlFor="message" className="block text-sm font-medium text-gray-700">Message</Label>
|
<Label htmlFor="message" className="block text-sm font-medium text-gray-700">Message</Label>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user