import { X, Trash2, AlertCircle, Flag } from 'lucide-react' import { useState } from 'react' import { createPortal } from 'react-dom' import { reportPost } from '../utils/api' import { hapticFeedback, showConfirm } from '../utils/telegram' import './PostMenu.css' export default function PostMenu({ post, currentUser, onClose, onDelete }) { const [showReportModal, setShowReportModal] = useState(false) const [reportReason, setReportReason] = useState('') const [submitting, setSubmitting] = useState(false) const isOwnPost = post.author._id === currentUser.id const isModerator = currentUser.role === 'moderator' || currentUser.role === 'admin' const handleReport = async () => { if (!reportReason.trim()) { alert('Укажите причину жалобы') return } try { setSubmitting(true) hapticFeedback('light') await reportPost(post._id, reportReason) hapticFeedback('success') alert('Жалоба отправлена') onClose() } catch (error) { console.error('Ошибка отправки жалобы:', error) hapticFeedback('error') alert('Ошибка отправки жалобы') } finally { setSubmitting(false) } } if (showReportModal) { const handleReportOverlayClick = (e) => { if (e.target === e.currentTarget) { setShowReportModal(false) } } return createPortal(
e.stopPropagation()} onTouchStart={(e) => e.stopPropagation()} onClick={handleReportOverlayClick} >
e.stopPropagation()}>

Пожаловаться

e.stopPropagation()}>