6c86f0f571
- integrated request-module into module registry - moved backend into modules/request-module - added manifest.json and module.py - implemented dynamic router mounting - implemented dynamic static mounting - removed direct dependencies from platform core - verified startup with request-module - verified startup without request-module - added implementation_report_003.md
513 lines
26 KiB
TypeScript
513 lines
26 KiB
TypeScript
import { useState, useEffect } from 'react'
|
||
import { useParams, useNavigate } from 'react-router-dom'
|
||
import { ticketsApi, referenceApi, usersApi } from '../api/client'
|
||
import { Ticket, Status, Priority, Category, Comment, EmailMessage, User } from '../types'
|
||
import { ArrowLeft, Save, Trash2, Send, MessageSquare, Mail, Reply, Forward, Paperclip, Bell } from 'lucide-react'
|
||
import ReactQuill from 'react-quill'
|
||
import 'react-quill/dist/quill.snow.css'
|
||
import Modal from '../components/Modal'
|
||
|
||
const quillModules = {
|
||
toolbar: [
|
||
[{ 'header': [1, 2, 3, false] }],
|
||
['bold', 'italic', 'underline', 'strike'],
|
||
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
|
||
['link', 'image'],
|
||
['clean']
|
||
]
|
||
}
|
||
|
||
const quillFormats = [
|
||
'header', 'bold', 'italic', 'underline', 'strike',
|
||
'list', 'bullet', 'link', 'image'
|
||
]
|
||
|
||
export default function TicketDetail() {
|
||
const { id } = useParams<{ id: string }>()
|
||
const navigate = useNavigate()
|
||
const [ticket, setTicket] = useState<Ticket | null>(null)
|
||
const [statuses, setStatuses] = useState<Status[]>([])
|
||
const [priorities, setPriorities] = useState<Priority[]>([])
|
||
const [categories, setCategories] = useState<Category[]>([])
|
||
const [comments, setComments] = useState<Comment[]>([])
|
||
const [emails, setEmails] = useState<EmailMessage[]>([])
|
||
const [events, setEvents] = useState<{ id: number; event_type: string; message: string; user_id: number; created_at: string }[]>([])
|
||
const [specialists, setSpecialists] = useState<User[]>([])
|
||
const [newComment, setNewComment] = useState('')
|
||
const [loading, setLoading] = useState(true)
|
||
const [saving, setSaving] = useState(false)
|
||
const [sendingComment, setSendingComment] = useState(false)
|
||
const [activeTab, setActiveTab] = useState<'emails' | 'comments' | 'events'>('emails')
|
||
|
||
// Modal states
|
||
const [showReplyModal, setShowReplyModal] = useState(false)
|
||
const [showForwardModal, setShowForwardModal] = useState(false)
|
||
const [replyTo, setReplyTo] = useState<EmailMessage | null>(null)
|
||
const [replyData, setReplyData] = useState({ to: '', cc: '', subject: '', body: '' })
|
||
const [sendingReply, setSendingReply] = useState(false)
|
||
const [forwardEmail, setForwardEmail] = useState<EmailMessage | null>(null)
|
||
const [forwardData, setForwardData] = useState({ to: '', cc: '', message: '' })
|
||
const [sendingForward, setSendingForward] = useState(false)
|
||
const [expandedEmailId, setExpandedEmailId] = useState<number | null>(null)
|
||
|
||
useEffect(() => {
|
||
if (!id) return
|
||
Promise.all([
|
||
ticketsApi.get(Number(id)),
|
||
referenceApi.getStatuses(),
|
||
referenceApi.getPriorities(),
|
||
referenceApi.getCategories(),
|
||
ticketsApi.getComments(Number(id)),
|
||
ticketsApi.getEmails(Number(id)),
|
||
ticketsApi.getEvents(Number(id)),
|
||
usersApi.getSpecialists()
|
||
]).then(([ticketRes, statusesRes, prioritiesRes, categoriesRes, commentsRes, emailsRes, eventsRes, specialistsRes]) => {
|
||
setTicket(ticketRes.data)
|
||
setStatuses(statusesRes.data)
|
||
setPriorities(prioritiesRes.data)
|
||
setCategories(categoriesRes.data)
|
||
setComments(commentsRes.data)
|
||
setEmails(emailsRes.data)
|
||
setEvents(eventsRes.data)
|
||
setSpecialists(specialistsRes.data)
|
||
}).finally(() => setLoading(false))
|
||
}, [id])
|
||
|
||
const handleSave = async () => {
|
||
if (!ticket || !id) return
|
||
setSaving(true)
|
||
try {
|
||
await ticketsApi.update(Number(id), {
|
||
subject: ticket.subject,
|
||
description: ticket.description,
|
||
status_id: ticket.status_id,
|
||
priority_id: ticket.priority_id,
|
||
category_id: ticket.category_id,
|
||
assigned_to_id: ticket.assigned_to_id
|
||
})
|
||
navigate('/tickets')
|
||
} catch (err) {
|
||
alert('Ошибка сохранения')
|
||
} finally {
|
||
setSaving(false)
|
||
}
|
||
}
|
||
|
||
const handleDelete = async () => {
|
||
if (!id || !confirm('Вы уверены, что хотите удалить эту заявку?')) return
|
||
try {
|
||
await ticketsApi.delete(Number(id))
|
||
navigate('/tickets')
|
||
} catch (err) {
|
||
alert('Ошибка удаления')
|
||
}
|
||
}
|
||
|
||
const handleReply = (email: EmailMessage) => {
|
||
setReplyTo(email)
|
||
setReplyData({
|
||
to: email.from_address,
|
||
cc: '',
|
||
subject: email.subject?.startsWith('Re:') ? email.subject : `Re: ${email.subject}`,
|
||
body: ''
|
||
})
|
||
setShowReplyModal(true)
|
||
}
|
||
|
||
const handleForward = (email: EmailMessage) => {
|
||
setForwardEmail(email)
|
||
setForwardData({ to: '', cc: '', message: '' })
|
||
setShowForwardModal(true)
|
||
}
|
||
|
||
const handleSendReply = async () => {
|
||
if (!id || !replyTo) return
|
||
setSendingReply(true)
|
||
try {
|
||
const res = await ticketsApi.sendReply(Number(id), {
|
||
to_addresses: replyData.to,
|
||
subject: replyData.subject,
|
||
body_text: replyData.body,
|
||
body_html: replyData.body,
|
||
in_reply_to: replyTo.message_id,
|
||
cc_addresses: replyData.cc || undefined
|
||
})
|
||
setEmails([...emails, res.data])
|
||
setShowReplyModal(false)
|
||
setReplyData({ to: '', cc: '', subject: '', body: '' })
|
||
} catch (err) {
|
||
alert('Ошибка отправки')
|
||
} finally {
|
||
setSendingReply(false)
|
||
}
|
||
}
|
||
|
||
const handleSendForward = async () => {
|
||
if (!id || !forwardEmail) return
|
||
setSendingForward(true)
|
||
try {
|
||
const res = await ticketsApi.forwardEmail(Number(id), forwardEmail.id, {
|
||
to_addresses: forwardData.to,
|
||
cc_addresses: forwardData.cc || undefined,
|
||
add_message: forwardData.message || undefined
|
||
})
|
||
setEmails([...emails, res.data])
|
||
setShowForwardModal(false)
|
||
setForwardData({ to: '', cc: '', message: '' })
|
||
} catch (err) {
|
||
alert('Ошибка пересылки')
|
||
} finally {
|
||
setSendingForward(false)
|
||
}
|
||
}
|
||
|
||
const getUserName = (userId: number) => {
|
||
const user = specialists.find(u => u.id === userId)
|
||
return user ? `${user.first_name} ${user.last_name}` : `Пользователь #${userId}`
|
||
}
|
||
|
||
const formatDate = (dateStr?: string) => {
|
||
if (!dateStr) return ''
|
||
return new Date(dateStr).toLocaleString('ru-RU')
|
||
}
|
||
|
||
const getEmailBody = (email: EmailMessage) => {
|
||
if (email.body_html) return email.body_html
|
||
if (email.body_text) return email.body_text.replace(/\n/g, '<br>')
|
||
return '<p class="text-gray-400 italic">(пустое письмо)</p>'
|
||
}
|
||
|
||
const createMarkup = (html: string) => ({ __html: html })
|
||
|
||
if (loading) return <div className="text-center py-8">Загрузка...</div>
|
||
if (!ticket) return <div className="text-center py-8">Заявка не найдена</div>
|
||
|
||
return (
|
||
<div>
|
||
<div className="flex items-center justify-between mb-6">
|
||
<button onClick={() => navigate('/tickets')} className="flex items-center text-gray-600 hover:text-gray-900">
|
||
<ArrowLeft className="w-4 h-4 mr-2" />
|
||
Назад к заявкам
|
||
</button>
|
||
<div className="flex gap-2">
|
||
<button onClick={handleSave} disabled={saving} className="flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50">
|
||
<Save className="w-4 h-4 mr-2" />
|
||
{saving ? 'Сохранение...' : 'Сохранить'}
|
||
</button>
|
||
<button onClick={handleDelete} className="flex items-center px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700">
|
||
<Trash2 className="w-4 h-4 mr-2" />
|
||
Удалить
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div className="grid grid-cols-3 gap-6">
|
||
<div className="col-span-2 space-y-6">
|
||
{/* Ticket details */}
|
||
<div className="bg-white rounded-lg shadow p-6">
|
||
<div className="mb-4">
|
||
<label className="block text-sm font-medium text-gray-700 mb-1">Заявка #{ticket.id}</label>
|
||
</div>
|
||
<div className="space-y-4">
|
||
<div>
|
||
<label className="block text-sm font-medium text-gray-700 mb-1">Тема</label>
|
||
<input type="text" value={ticket.subject} onChange={(e) => setTicket({ ...ticket, subject: e.target.value })}
|
||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" />
|
||
</div>
|
||
<div>
|
||
<label className="block text-sm font-medium text-gray-700 mb-1">Описание</label>
|
||
<div className="prose prose-sm max-w-none border rounded-lg p-4 bg-gray-50 overflow-auto max-h-96"
|
||
dangerouslySetInnerHTML={createMarkup(ticket.description || '<p class="text-gray-400">Нет описания</p>')} />
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
{/* Tabs */}
|
||
<div className="bg-white rounded-lg shadow">
|
||
<div className="border-b">
|
||
<nav className="flex">
|
||
<button onClick={() => setActiveTab('emails')}
|
||
className={`px-6 py-3 text-sm font-medium border-b-2 flex items-center ${activeTab === 'emails' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500 hover:text-gray-700'}`}>
|
||
<Mail className="w-4 h-4 mr-2" /> Письма ({emails.length})
|
||
</button>
|
||
<button onClick={() => setActiveTab('comments')}
|
||
className={`px-6 py-3 text-sm font-medium border-b-2 flex items-center ${activeTab === 'comments' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500 hover:text-gray-700'}`}>
|
||
<MessageSquare className="w-4 h-4 mr-2" /> Комментарии ({comments.length})
|
||
</button>
|
||
<button onClick={() => setActiveTab('events')}
|
||
className={`px-6 py-3 text-sm font-medium border-b-2 flex items-center ${activeTab === 'events' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500 hover:text-gray-700'}`}>
|
||
<Bell className="w-4 h-4 mr-2" /> Системные ({events.length})
|
||
</button>
|
||
</nav>
|
||
</div>
|
||
|
||
{/* Email thread */}
|
||
{activeTab === 'emails' && (
|
||
<div className="p-4 space-y-4 max-h-[600px] overflow-y-auto">
|
||
{emails.length === 0 ? (
|
||
<p className="text-gray-500 text-center py-8">Нет писем</p>
|
||
) : (
|
||
emails.map((email) => (
|
||
<div key={email.id} className={`border rounded-lg ${email.direction === 'incoming' ? 'bg-blue-50/30' : 'bg-gray-50/30'}`}>
|
||
<div className="px-4 py-3 border-b flex items-center justify-between cursor-pointer hover:bg-gray-100/50"
|
||
onClick={() => setExpandedEmailId(expandedEmailId === email.id ? null : email.id)}>
|
||
<div className="flex items-center">
|
||
<div className={`w-8 h-8 rounded-full flex items-center justify-center text-white text-sm ${email.direction === 'incoming' ? 'bg-blue-500' : 'bg-green-500'}`}>
|
||
{email.direction === 'incoming' ? '↓' : '↑'}
|
||
</div>
|
||
<div className="ml-3">
|
||
<p className="text-sm font-medium">{email.direction === 'incoming' ? email.from_address : `Вы → ${email.to_addresses}`}</p>
|
||
<p className="text-xs text-gray-500">{formatDate(email.received_at || email.sent_at || email.created_at)}</p>
|
||
</div>
|
||
</div>
|
||
<div className="flex items-center gap-2">
|
||
{email.attachments && email.attachments.length > 0 && (
|
||
<span className="flex items-center text-xs text-gray-500"><Paperclip className="w-3 h-3 mr-1" />{email.attachments.length}</span>
|
||
)}
|
||
<button onClick={(e) => { e.stopPropagation(); handleReply(email); }} className="p-1 text-gray-500 hover:text-blue-600" title="Ответить">
|
||
<Reply className="w-4 h-4" />
|
||
</button>
|
||
<button onClick={(e) => { e.stopPropagation(); handleForward(email); }} className="p-1 text-gray-500 hover:text-blue-600" title="Переслать">
|
||
<Forward className="w-4 h-4" />
|
||
</button>
|
||
</div>
|
||
</div>
|
||
{expandedEmailId === email.id && (
|
||
<div className="px-4 py-3">
|
||
<p className="text-sm font-medium mb-3 text-gray-700">{email.subject}</p>
|
||
<div className="prose prose-sm max-w-none bg-white p-4 rounded border overflow-auto max-h-[400px]"
|
||
dangerouslySetInnerHTML={createMarkup(getEmailBody(email))} />
|
||
{email.attachments && email.attachments.length > 0 && (
|
||
<div className="mt-4 pt-3 border-t">
|
||
<p className="text-xs text-gray-500 mb-2 font-medium">Вложения:</p>
|
||
<div className="flex flex-wrap gap-2">
|
||
{email.attachments.map((att) => (
|
||
<span key={att.id} className="flex items-center text-xs bg-white px-3 py-2 rounded border hover:bg-gray-50 cursor-pointer">
|
||
<Paperclip className="w-3 h-3 mr-1 text-gray-400" />{att.filename}
|
||
</span>
|
||
))}
|
||
</div>
|
||
</div>
|
||
)}
|
||
</div>
|
||
)}
|
||
</div>
|
||
))
|
||
)}
|
||
</div>
|
||
)}
|
||
|
||
{/* Comments */}
|
||
{activeTab === 'comments' && (
|
||
<div>
|
||
<div className="p-4 space-y-4 max-h-96 overflow-y-auto">
|
||
{comments.length === 0 ? (
|
||
<p className="text-gray-500 text-center py-4">Нет комментариев</p>
|
||
) : (
|
||
comments.map((comment) => (
|
||
<div key={comment.id} className="border rounded-lg p-4">
|
||
<div className="flex items-center justify-between mb-2">
|
||
<span className="font-medium text-sm">{getUserName(comment.created_by)}</span>
|
||
<span className="text-xs text-gray-500">{formatDate(comment.created_at)}</span>
|
||
</div>
|
||
<p className="text-gray-700 whitespace-pre-wrap">{comment.comment_text}</p>
|
||
</div>
|
||
))
|
||
)}
|
||
</div>
|
||
<div className="px-4 py-4 border-t space-y-3">
|
||
<ReactQuill
|
||
theme="snow"
|
||
value={newComment}
|
||
onChange={setNewComment}
|
||
modules={quillModules}
|
||
formats={quillFormats}
|
||
placeholder="Напишите ответ..."
|
||
className="bg-white rounded-lg"
|
||
style={{ minHeight: '150px' }}
|
||
/>
|
||
<div className="flex items-center justify-between pt-2">
|
||
<label className="flex items-center gap-2 text-sm text-gray-700 cursor-pointer select-none">
|
||
<input type="checkbox" id="sendEmail" className="h-4 w-4 text-blue-600 rounded" />
|
||
<Mail className="w-4 h-4 text-gray-500" />
|
||
Отправить также на email инициатора
|
||
</label>
|
||
<button
|
||
onClick={async () => {
|
||
if (!newComment.trim() || !id) return
|
||
setSendingComment(true)
|
||
try {
|
||
const sendEmail = (document.getElementById('sendEmail') as HTMLInputElement)?.checked || false
|
||
await ticketsApi.reply(Number(id), { message: newComment, send_email: sendEmail })
|
||
const updatedComments = await ticketsApi.getComments(Number(id))
|
||
setComments(updatedComments.data)
|
||
if (sendEmail) {
|
||
const updatedEmails = await ticketsApi.getEmails(Number(id))
|
||
setEmails(updatedEmails.data)
|
||
}
|
||
setNewComment('')
|
||
} catch (err) {
|
||
alert('Ошибка отправки')
|
||
} finally {
|
||
setSendingComment(false)
|
||
}
|
||
}}
|
||
disabled={sendingComment || !newComment.trim()}
|
||
className="flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50">
|
||
<Send className="w-4 h-4 mr-1" />
|
||
{sendingComment ? 'Отправка...' : 'Ответить'}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
)}
|
||
|
||
{/* System Events */}
|
||
{activeTab === 'events' && (
|
||
<div className="p-4 space-y-3 max-h-[600px] overflow-y-auto">
|
||
{events.length === 0 ? (
|
||
<p className="text-gray-500 text-center py-8">Нет событий</p>
|
||
) : (
|
||
events.map((event) => (
|
||
<div key={event.id} className="flex items-start gap-3 p-3 bg-gray-50 rounded-lg">
|
||
<div className={`w-2 h-2 mt-2 rounded-full flex-shrink-0 ${
|
||
event.event_type === 'created' ? 'bg-green-500' :
|
||
event.event_type === 'email_queued' ? 'bg-blue-500' :
|
||
event.event_type === 'email_sent' ? 'bg-purple-500' :
|
||
'bg-gray-400'
|
||
}`} />
|
||
<div className="flex-1 min-w-0">
|
||
<p className="text-sm text-gray-900">{event.message}</p>
|
||
<p className="text-xs text-gray-500 mt-1">
|
||
{event.created_at ? new Date(event.created_at).toLocaleString('ru-RU') : ''}
|
||
{event.user_id ? ` · пользователь #${event.user_id}` : ''}
|
||
</p>
|
||
</div>
|
||
<span className={`px-2 py-0.5 text-xs rounded-full flex-shrink-0 ${
|
||
event.event_type === 'created' ? 'bg-green-100 text-green-700' :
|
||
event.event_type === 'email_queued' ? 'bg-blue-100 text-blue-700' :
|
||
'bg-gray-100 text-gray-600'
|
||
}`}>
|
||
{event.event_type === 'created' ? 'Создан' :
|
||
event.event_type === 'email_queued' ? 'Письмо' :
|
||
event.event_type}
|
||
</span>
|
||
</div>
|
||
))
|
||
)}
|
||
</div>
|
||
)}
|
||
</div>
|
||
</div>
|
||
|
||
{/* Sidebar */}
|
||
<div className="space-y-6">
|
||
<div className="bg-white rounded-lg shadow p-6 space-y-4">
|
||
<div>
|
||
<label className="block text-sm font-medium text-gray-700 mb-1">Статус</label>
|
||
<select value={ticket.status_id} onChange={(e) => setTicket({ ...ticket, status_id: Number(e.target.value) })}
|
||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||
{statuses.map(s => <option key={s.id} value={s.id}>{s.name}</option>)}
|
||
</select>
|
||
</div>
|
||
<div>
|
||
<label className="block text-sm font-medium text-gray-700 mb-1">Приоритет</label>
|
||
<select value={ticket.priority_id} onChange={(e) => setTicket({ ...ticket, priority_id: Number(e.target.value) })}
|
||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||
{priorities.map(p => <option key={p.id} value={p.id}>{p.name}</option>)}
|
||
</select>
|
||
</div>
|
||
<div>
|
||
<label className="block text-sm font-medium text-gray-700 mb-1">Категория</label>
|
||
<select value={ticket.category_id} onChange={(e) => setTicket({ ...ticket, category_id: Number(e.target.value) })}
|
||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||
{categories.map(c => <option key={c.id} value={c.id}>{c.name}</option>)}
|
||
</select>
|
||
</div>
|
||
<div>
|
||
<label className="block text-sm font-medium text-gray-700 mb-1">Ответственный (специалист)</label>
|
||
<select value={ticket.assigned_to_id || ''} onChange={(e) => setTicket({ ...ticket, assigned_to_id: e.target.value ? Number(e.target.value) : undefined })}
|
||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||
<option value="">Не назначен</option>
|
||
{specialists.map(u => <option key={u.id} value={u.id}>{u.first_name} {u.last_name}</option>)}
|
||
</select>
|
||
</div>
|
||
<hr />
|
||
<div>
|
||
<label className="block text-sm font-medium text-gray-700 mb-1">Источник</label>
|
||
<input type="text" value={ticket.source} disabled className="w-full px-3 py-2 border border-gray-300 rounded-lg bg-gray-50" />
|
||
</div>
|
||
<div>
|
||
<label className="block text-sm font-medium text-gray-700 mb-1">Создана</label>
|
||
<input type="text" value={formatDate(ticket.created_at)} disabled className="w-full px-3 py-2 border border-gray-300 rounded-lg bg-gray-50" />
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
{/* Reply Modal */}
|
||
<Modal isOpen={showReplyModal} onClose={() => setShowReplyModal(false)} title={`Ответить: ${replyTo?.subject}`} size="xl">
|
||
<div className="space-y-4">
|
||
<div>
|
||
<label className="block text-sm font-medium text-gray-700 mb-1">Кому</label>
|
||
<input type="text" value={replyData.to} onChange={(e) => setReplyData({ ...replyData, to: e.target.value })}
|
||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" />
|
||
</div>
|
||
<div>
|
||
<label className="block text-sm font-medium text-gray-700 mb-1">Копия</label>
|
||
<input type="text" value={replyData.cc} onChange={(e) => setReplyData({ ...replyData, cc: e.target.value })}
|
||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Необязательно" />
|
||
</div>
|
||
<div>
|
||
<label className="block text-sm font-medium text-gray-700 mb-1">Тема</label>
|
||
<input type="text" value={replyData.subject} onChange={(e) => setReplyData({ ...replyData, subject: e.target.value })}
|
||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" />
|
||
</div>
|
||
<div>
|
||
<label className="block text-sm font-medium text-gray-700 mb-1">Текст</label>
|
||
<ReactQuill theme="snow" value={replyData.body} onChange={(value) => setReplyData({ ...replyData, body: value })}
|
||
modules={quillModules} formats={quillFormats} className="bg-white rounded-lg" style={{ minHeight: '200px' }} />
|
||
</div>
|
||
<div className="flex justify-end gap-2 pt-4 border-t">
|
||
<button onClick={() => setShowReplyModal(false)} className="px-4 py-2 border rounded-lg hover:bg-gray-100">Отмена</button>
|
||
<button onClick={handleSendReply} disabled={sendingReply || !replyData.to || !replyData.body}
|
||
className="flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50">
|
||
<Send className="w-4 h-4 mr-2" />
|
||
{sendingReply ? 'Отправка...' : 'Отправить'}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</Modal>
|
||
|
||
{/* Forward Modal */}
|
||
<Modal isOpen={showForwardModal} onClose={() => setShowForwardModal(false)} title={`Переслать: ${forwardEmail?.subject}`} size="lg">
|
||
<div className="space-y-4">
|
||
<div>
|
||
<label className="block text-sm font-medium text-gray-700 mb-1">Кому</label>
|
||
<input type="text" value={forwardData.to} onChange={(e) => setForwardData({ ...forwardData, to: e.target.value })}
|
||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="email@example.com" />
|
||
</div>
|
||
<div>
|
||
<label className="block text-sm font-medium text-gray-700 mb-1">Копия</label>
|
||
<input type="text" value={forwardData.cc} onChange={(e) => setForwardData({ ...forwardData, cc: e.target.value })}
|
||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Необязательно" />
|
||
</div>
|
||
<div>
|
||
<label className="block text-sm font-medium text-gray-700 mb-1">Комментарий</label>
|
||
<ReactQuill theme="snow" value={forwardData.message} onChange={(value) => setForwardData({ ...forwardData, message: value })}
|
||
modules={quillModules} formats={quillFormats} className="bg-white rounded-lg" style={{ minHeight: '150px' }} />
|
||
</div>
|
||
<div className="flex justify-end gap-2 pt-4 border-t">
|
||
<button onClick={() => setShowForwardModal(false)} className="px-4 py-2 border rounded-lg hover:bg-gray-100">Отмена</button>
|
||
<button onClick={handleSendForward} disabled={sendingForward || !forwardData.to}
|
||
className="flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50">
|
||
<Forward className="w-4 h-4 mr-2" />
|
||
{sendingForward ? 'Отправка...' : 'Переслать'}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</Modal>
|
||
</div>
|
||
)
|
||
}
|