From 67e7e19baee2e2e0a083cc0c314765fe8930c022 Mon Sep 17 00:00:00 2001 From: syc0123 Date: Wed, 1 Apr 2026 15:11:11 +0900 Subject: [PATCH] =?UTF-8?q?[RAPID-micro]=20=EB=A9=94=EC=9D=BC=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20=EB=8B=A4=EC=9D=B4=EC=96=BC=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=97=90=20=EB=B3=B4=EB=82=B4=EB=8A=94=20=EC=82=AC=EB=9E=8C=20?= =?UTF-8?q?=EA=B3=84=EC=A0=95=20=EC=84=A0=ED=83=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 (1M context) --- .../app/(main)/mail/imap/ComposeDialog.tsx | 47 ++++++++++++++++--- frontend/app/(main)/mail/imap/page.tsx | 6 ++- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/frontend/app/(main)/mail/imap/ComposeDialog.tsx b/frontend/app/(main)/mail/imap/ComposeDialog.tsx index 3de386f4..15b3d95c 100644 --- a/frontend/app/(main)/mail/imap/ComposeDialog.tsx +++ b/frontend/app/(main)/mail/imap/ComposeDialog.tsx @@ -1,6 +1,6 @@ "use client"; -import { useEffect } from "react"; +import { useEffect, useState } from "react"; import { useEditor, EditorContent } from "@tiptap/react"; import StarterKit from "@tiptap/starter-kit"; import LinkExtension from "@tiptap/extension-link"; @@ -15,7 +15,15 @@ import { DialogTitle, DialogFooter, } from "@/components/ui/dialog"; -import { sendUserMail } from "@/lib/api/userMail"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; +import { toast } from "sonner"; +import { sendUserMail, UserMailAccount } from "@/lib/api/userMail"; interface ComposeDialogProps { open: boolean; @@ -34,6 +42,7 @@ interface ComposeDialogProps { sending: boolean; setSending: (v: boolean) => void; accountId: number | null; + accounts: UserMailAccount[]; } export default function ComposeDialog({ @@ -43,8 +52,14 @@ export default function ComposeDialog({ initialHtml, setInitialHtml, inReplyTo, references, sending, setSending, - accountId, + accountId, accounts, }: ComposeDialogProps) { + const [fromAccountId, setFromAccountId] = useState(accountId); + + useEffect(() => { + setFromAccountId(accountId ?? (accounts[0]?.id ?? null)); + }, [accountId, accounts, open]); + const editor = useEditor({ extensions: [StarterKit, LinkExtension.configure({ openOnClick: false })], content: initialHtml, @@ -58,11 +73,11 @@ export default function ComposeDialog({ }, [initialHtml, editor]); async function handleSend() { - if (!accountId || !editor) return; + if (!fromAccountId || !editor) return; setSending(true); try { const html = editor.getHTML(); - const result = await sendUserMail(accountId, { + const result = await sendUserMail(fromAccountId, { to, cc: cc || undefined, subject, @@ -74,7 +89,7 @@ export default function ComposeDialog({ onOpenChange(false); setTo(""); setCc(""); setSubject(""); setInitialHtml(""); } else { - alert(result.message); + toast.error(result.message); } } finally { setSending(false); @@ -90,6 +105,24 @@ export default function ComposeDialog({
+
+ + +
setTo(e.target.value)} placeholder="to@example.com" /> @@ -109,7 +142,7 @@ export default function ComposeDialog({
- diff --git a/frontend/app/(main)/mail/imap/page.tsx b/frontend/app/(main)/mail/imap/page.tsx index e67a5c94..8100a1c8 100644 --- a/frontend/app/(main)/mail/imap/page.tsx +++ b/frontend/app/(main)/mail/imap/page.tsx @@ -87,7 +87,8 @@ import { SendMailDto, } from "@/lib/api/userMail"; -const ComposeDialogDynamic = dynamic(() => import("./ComposeDialog"), { ssr: false }); +import type ComposeDialogType from "./ComposeDialog"; +const ComposeDialogDynamic = dynamic(() => import("./ComposeDialog"), { ssr: false }) as typeof ComposeDialogType; const IMAP_PRESETS = [ { label: "직접 입력", value: "custom", host: "", port: 993, useTls: true }, @@ -897,6 +898,7 @@ export default function ImapMailPage() { references={composeReferences} sending={composeSending} setSending={setComposeSending} accountId={selectedAccount?.id ?? null} + accounts={imapAccounts} /> {/* 계정 추가/편집 다이얼로그 */} @@ -937,7 +939,7 @@ export default function ImapMailPage() { - +