// 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 (
Help us improve NoteVerse by sharing your thoughts
Your feedback helps us make NoteVerse better for everyone.