({ type, onSubmit, onClose })
| 1 | import React, { useState } from 'react'; |
| 2 | |
| 3 | export default function FeedbackModal({ type, onSubmit, onClose }) { |
| 4 | const [text, setText] = useState(''); |
| 5 | const [error, setError] = useState(''); |
| 6 | |
| 7 | const handleSubmit = () => { |
| 8 | if (text.length < 10) { |
| 9 | setError('Please provide at least 10 characters of feedback.'); |
| 10 | return; |
| 11 | } |
| 12 | onSubmit(text); |
| 13 | }; |
| 14 | |
| 15 | return ( |
| 16 | <div className="modal-overlay" onClick={onClose}> |
| 17 | <div className="modal-content" onClick={(e) => e.stopPropagation()}> |
| 18 | <h3> |
| 19 | {type === 'positive' ? '👍' : '👎'} Provide Feedback |
| 20 | </h3> |
| 21 | {error && <div className="alert alert-error">{error}</div>} |
| 22 | <textarea |
| 23 | placeholder="Tell us more about why this response was helpful or not..." |
| 24 | value={text} |
| 25 | onChange={(e) => { setText(e.target.value); setError(''); }} |
| 26 | autoFocus |
| 27 | /> |
| 28 | <div className="modal-actions"> |
| 29 | <button className="btn btn-secondary" onClick={onClose}> |
| 30 | Cancel |
| 31 | </button> |
| 32 | <button className="btn btn-primary" onClick={handleSubmit}> |
| 33 | Submit Feedback |
| 34 | </button> |
| 35 | </div> |
| 36 | </div> |
| 37 | </div> |
| 38 | ); |
| 39 | } |
nothing calls this directly
no outgoing calls
no test coverage detected