add attachment in reply

This commit is contained in:
hamid zarghami
2025-11-29 16:38:32 +03:30
parent dbe28c3b5f
commit a0ea1e1fb5
2 changed files with 16 additions and 1 deletions
+10
View File
@@ -5,6 +5,7 @@ import AvatarImage from '@/assets/images/avatar.svg'
import AnswerIcon from '@/assets/images/answer.svg' import AnswerIcon from '@/assets/images/answer.svg'
import EmailEditor from './EmailEditor' import EmailEditor from './EmailEditor'
import EmailFormActions from './EmailFormActions' import EmailFormActions from './EmailFormActions'
import EmailAttachments from './EmailAttachments'
import { useReply } from './hooks/useReply' import { useReply } from './hooks/useReply'
import { MessageDetail } from '@/pages/received/types/Types' import { MessageDetail } from '@/pages/received/types/Types'
import { toast } from '@/components/Toast' import { toast } from '@/components/Toast'
@@ -30,7 +31,9 @@ const Reply: FC<ReplyProps> = ({
content, content,
isExpanded, isExpanded,
isSending, isSending,
attachments,
setContent, setContent,
setAttachments,
expandReply, expandReply,
collapseReply, collapseReply,
handleSendReply, handleSendReply,
@@ -137,6 +140,13 @@ const Reply: FC<ReplyProps> = ({
/> />
</div> </div>
<div className='mb-4'>
<EmailAttachments
attachments={attachments}
onAttachmentsChange={setAttachments}
/>
</div>
<EmailFormActions <EmailFormActions
onSend={handleSend} onSend={handleSend}
onClose={handleClose} onClose={handleClose}
+6 -1
View File
@@ -1,7 +1,7 @@
import { useState } from "react"; import { useState } from "react";
import { useAuthStore } from "@/pages/auth/store/AuthStore"; import { useAuthStore } from "@/pages/auth/store/AuthStore";
import { useSendEmail } from "@/pages/received/hooks/useEmailData"; import { useSendEmail } from "@/pages/received/hooks/useEmailData";
import { SendEmailDto } from "@/pages/received/types/Types"; import { SendEmailDto, EmailAttachmentDto } from "@/pages/received/types/Types";
import { MessageDetail } from "@/pages/received/types/Types"; import { MessageDetail } from "@/pages/received/types/Types";
import { toast } from "@/components/Toast"; import { toast } from "@/components/Toast";
@@ -19,12 +19,14 @@ export const useReply = ({
const { email: userEmail } = useAuthStore(); const { email: userEmail } = useAuthStore();
const [content, setContent] = useState<string>(""); const [content, setContent] = useState<string>("");
const [isExpanded, setIsExpanded] = useState<boolean>(false); const [isExpanded, setIsExpanded] = useState<boolean>(false);
const [attachments, setAttachments] = useState<EmailAttachmentDto[]>([]);
const sendEmailMutation = useSendEmail(); const sendEmailMutation = useSendEmail();
const resetForm = () => { const resetForm = () => {
setContent(""); setContent("");
setIsExpanded(false); setIsExpanded(false);
setAttachments([]);
}; };
const handleSendReply = async (html: string) => { const handleSendReply = async (html: string) => {
@@ -97,6 +99,7 @@ ${
originalMessage.html?.join("").replace(/<[^>]*>/g, "") || originalMessage.html?.join("").replace(/<[^>]*>/g, "") ||
"" ""
}`, }`,
attachments: attachments.length > 0 ? attachments : undefined,
}; };
try { try {
@@ -144,8 +147,10 @@ ${
content, content,
isExpanded, isExpanded,
isSending: sendEmailMutation.isPending, isSending: sendEmailMutation.isPending,
attachments,
setContent, setContent,
setAttachments,
expandReply, expandReply,
collapseReply, collapseReply,
handleSendReply, handleSendReply,