From 7fcf4d5ea8fa00fa22a233a939458a0adf524ca9 Mon Sep 17 00:00:00 2001 From: alma Date: Wed, 30 Apr 2025 23:41:10 +0200 Subject: [PATCH] courrier preview --- app/courrier/page.tsx | 1 + components/email/ComposeEmail.tsx | 93 ++++++++++++++++++++---- components/email/ComposeEmailAdapter.tsx | 10 ++- components/email/EmailLayout.tsx | 30 +++++++- components/email/EmailPanel.tsx | 10 ++- 5 files changed, 124 insertions(+), 20 deletions(-) diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index 967e0112..1d894323 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -894,6 +894,7 @@ export default function CourrierPage() { } }} onClose={() => setShowComposeModal(false)} + accounts={accounts} /> diff --git a/components/email/ComposeEmail.tsx b/components/email/ComposeEmail.tsx index 12fe3657..23309c23 100644 --- a/components/email/ComposeEmail.tsx +++ b/components/email/ComposeEmail.tsx @@ -2,11 +2,19 @@ import { useState, useRef, useEffect } from 'react'; import { - X, Paperclip, SendHorizontal, Loader2, Plus + X, Paperclip, SendHorizontal, Loader2, Plus, ChevronDown } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import DOMPurify from 'isomorphic-dompurify'; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; // Import from the centralized utils import { @@ -29,16 +37,22 @@ interface ComposeEmailProps { bcc?: string; subject: string; body: string; + fromAccount?: string; attachments?: Array<{ name: string; content: string; type: string; }>; }) => Promise; + accounts?: Array<{ + id: string; + email: string; + display_name?: string; + }>; } export default function ComposeEmail(props: ComposeEmailProps) { - const { initialEmail, type = 'new', onClose, onSend } = props; + const { initialEmail, type = 'new', onClose, onSend, accounts = [] } = props; // Email form state const [to, setTo] = useState(''); @@ -49,6 +63,11 @@ export default function ComposeEmail(props: ComposeEmailProps) { const [showCc, setShowCc] = useState(false); const [showBcc, setShowBcc] = useState(false); const [sending, setSending] = useState(false); + const [selectedAccount, setSelectedAccount] = useState<{ + id: string; + email: string; + display_name?: string; + } | null>(accounts.length > 0 ? accounts[0] : null); const [attachments, setAttachments] = useState {/* Header */} -
+

{getComposeTitle()}

+ + + Select account + + {accounts.length > 0 ? ( + accounts.map(account => ( + setSelectedAccount(account)} + className="cursor-pointer" + > + {account.display_name ? + `${account.display_name} <${account.email}>` : + account.email} + + )) + ) : ( + No accounts available + )} + + +
+
+ {/* Recipients */} -
-
+
+
To: setTo(e.target.value)} placeholder="recipient@example.com" - className="flex-1 border-0 shadow-none focus-visible:ring-0 px-0 bg-white text-gray-800" + className="flex-1 border-0 shadow-none focus-visible:ring-0 px-0 h-8 bg-white text-gray-800" />
{showCc && ( -
+
Cc: setCc(e.target.value)} placeholder="cc@example.com" - className="flex-1 border-0 shadow-none focus-visible:ring-0 px-0 bg-white text-gray-800" + className="flex-1 border-0 shadow-none focus-visible:ring-0 px-0 h-8 bg-white text-gray-800" />
)} {showBcc && ( -
+
Bcc: setBcc(e.target.value)} placeholder="bcc@example.com" - className="flex-1 border-0 shadow-none focus-visible:ring-0 px-0 bg-white text-gray-800" + className="flex-1 border-0 shadow-none focus-visible:ring-0 px-0 h-8 bg-white text-gray-800" />
)} {/* CC/BCC Toggle Links */} -
+
{!showCc && (