add attachment in reply
This commit is contained in:
@@ -5,6 +5,7 @@ import AvatarImage from '@/assets/images/avatar.svg'
|
||||
import AnswerIcon from '@/assets/images/answer.svg'
|
||||
import EmailEditor from './EmailEditor'
|
||||
import EmailFormActions from './EmailFormActions'
|
||||
import EmailAttachments from './EmailAttachments'
|
||||
import { useReply } from './hooks/useReply'
|
||||
import { MessageDetail } from '@/pages/received/types/Types'
|
||||
import { toast } from '@/components/Toast'
|
||||
@@ -30,7 +31,9 @@ const Reply: FC<ReplyProps> = ({
|
||||
content,
|
||||
isExpanded,
|
||||
isSending,
|
||||
attachments,
|
||||
setContent,
|
||||
setAttachments,
|
||||
expandReply,
|
||||
collapseReply,
|
||||
handleSendReply,
|
||||
@@ -137,6 +140,13 @@ const Reply: FC<ReplyProps> = ({
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className='mb-4'>
|
||||
<EmailAttachments
|
||||
attachments={attachments}
|
||||
onAttachmentsChange={setAttachments}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<EmailFormActions
|
||||
onSend={handleSend}
|
||||
onClose={handleClose}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { useAuthStore } from "@/pages/auth/store/AuthStore";
|
||||
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 { toast } from "@/components/Toast";
|
||||
|
||||
@@ -19,12 +19,14 @@ export const useReply = ({
|
||||
const { email: userEmail } = useAuthStore();
|
||||
const [content, setContent] = useState<string>("");
|
||||
const [isExpanded, setIsExpanded] = useState<boolean>(false);
|
||||
const [attachments, setAttachments] = useState<EmailAttachmentDto[]>([]);
|
||||
|
||||
const sendEmailMutation = useSendEmail();
|
||||
|
||||
const resetForm = () => {
|
||||
setContent("");
|
||||
setIsExpanded(false);
|
||||
setAttachments([]);
|
||||
};
|
||||
|
||||
const handleSendReply = async (html: string) => {
|
||||
@@ -97,6 +99,7 @@ ${
|
||||
originalMessage.html?.join("").replace(/<[^>]*>/g, "") ||
|
||||
""
|
||||
}`,
|
||||
attachments: attachments.length > 0 ? attachments : undefined,
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -144,8 +147,10 @@ ${
|
||||
content,
|
||||
isExpanded,
|
||||
isSending: sendEmailMutation.isPending,
|
||||
attachments,
|
||||
|
||||
setContent,
|
||||
setAttachments,
|
||||
expandReply,
|
||||
collapseReply,
|
||||
handleSendReply,
|
||||
|
||||
Reference in New Issue
Block a user