// FeedbackModal Component // Modal for collecting user feedback function FeedbackModal({ t, onClose }) { const [rating, setRating] = useState(0); const [category, setCategory] = useState(''); const [feedbackText, setFeedbackText] = useState(''); const [submitted, setSubmitted] = useState(false); const handleSubmit = async (e) => { e.preventDefault(); try { // Get token from localStorage const token = localStorage.getItem('token'); // Submit to backend const response = await fetch(API_URL + '/feedback/submit', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }, body: JSON.stringify({ rating, category, feedback_text: feedbackText }) }); const data = await response.json(); if (!response.ok) { throw new Error(data.detail || 'Failed to submit feedback'); } console.log('✅ Feedback submitted:', data); setSubmitted(true); setTimeout(() => { onClose(); }, 2000); } catch (error) { console.error('❌ Error submitting feedback:', error); alert('Failed to submit feedback. Please try again.'); } }; const categories = [ { value: 'bug', label: '🐛 Bug Report', icon: '🐛' }, { value: 'feature', label: '✨ Feature Request', icon: '✨' }, { value: 'ui', label: '🎨 UI/UX Feedback', icon: '🎨' }, { value: 'performance', label: '⚡ Performance', icon: '⚡' }, { value: 'other', label: '💬 General', icon: '💬' } ]; return (
e.target === e.currentTarget && onClose()} style={{ position: 'fixed', top: 0, left: 0, right: 0, bottom: 0, background: 'rgba(0, 0, 0, 0.7)', display: 'flex', alignItems: 'center', justifyContent: 'center', zIndex: 9999, padding: '20px' }} >

💬 {t('common.feedback') || 'Share Your Feedback'}

Help us improve NoteVerse by sharing your thoughts

{!submitted ? (
{[1, 2, 3, 4, 5].map(star => ( ))}
{rating > 0 && (
{rating === 5 ? '🎉 Amazing!' : rating === 4 ? '👍 Great!' : rating === 3 ? '😊 Good' : rating === 2 ? '😐 Okay' : '😞 Needs Work'}
)}
{categories.map(cat => ( ))}