import { FC } from 'react' import { useTranslation } from 'react-i18next' import { ArrowDown2, CloseSquare } from 'iconsax-react' import AvatarImage from '@/assets/images/avatar.svg' import AnswerIcon from '@/assets/images/answer.svg' import EmailEditor from './EmailEditor' import EmailFormActions from './EmailFormActions' import { useReply } from './hooks/useReply' import { MessageDetail } from '@/pages/received/types/Types' import { toast } from '@/components/Toast' interface ReplyProps { originalMessage: MessageDetail onClose?: () => void onExpand?: () => void className?: string showInitialButton?: boolean } const Reply: FC = ({ originalMessage, onClose, onExpand, className = '', showInitialButton = true }) => { const { t } = useTranslation() const { content, isExpanded, isSending, setContent, expandReply, collapseReply, handleSendReply, handleSaveDraft } = useReply({ originalMessage, onSuccess: () => { onClose?.() } }) const handleExpand = () => { expandReply() onExpand?.() } const handleClose = async () => { if (content.trim()) { await handleSaveDraft() toast('پیش‌نویس ذخیره شد', 'success') } collapseReply() onClose?.() } if (showInitialButton && !isExpanded) { return (
{t('mail.answer')}
) } const handleSend = () => { handleSendReply(originalMessage?.html[0]) collapseReply() } return (
پاسخ به {originalMessage.from.name || originalMessage.from.address}
به: {originalMessage.from.address}
موضوع: {originalMessage.subject.startsWith('Re:') ? originalMessage.subject : `Re: ${originalMessage.subject}`}
) } export default Reply