diff --git a/web/src/components/ReviewModal.tsx b/web/src/components/ReviewModal.tsx new file mode 100644 index 0000000..6332226 --- /dev/null +++ b/web/src/components/ReviewModal.tsx @@ -0,0 +1,112 @@ +/** + * @file ReviewModal.tsx + * @description Modal de avaliação pós-atendimento com estrelas interativas. + */ +import { useState } from 'react' +import { Star, X, Send } from 'lucide-react' +import { Button } from './ui/button' + +interface ReviewModalProps { + shopName: string + appointmentId: string + onSubmit: (rating: number, comment: string) => Promise + onClose: () => void +} + +export function ReviewModal({ shopName, appointmentId, onSubmit, onClose }: ReviewModalProps) { + const [rating, setRating] = useState(0) + const [hovered, setHovered] = useState(0) + const [comment, setComment] = useState('') + const [submitting, setSubmitting] = useState(false) + const [submitted, setSubmitted] = useState(false) + + const handleSubmit = async () => { + if (rating === 0) return + setSubmitting(true) + try { + await onSubmit(rating, comment) + setSubmitted(true) + setTimeout(onClose, 1800) + } catch { + alert('Erro ao enviar avaliação. Tente novamente.') + } finally { + setSubmitting(false) + } + } + + const labels = ['', 'Muito mau', 'Mau', 'Razoável', 'Bom', 'Excelente!'] + + return ( +
+
+ {/* Close */} + + + {submitted ? ( +
+
🎉
+

Obrigado pela avaliação!

+

O seu feedback ajuda outros clientes.

+
+ ) : ( + <> +
+
+ +
+

Avaliar atendimento

+

{shopName}

+
+ + {/* Stars */} +
+ {[1, 2, 3, 4, 5].map((star) => ( + + ))} +
+

+ {labels[hovered || rating]} +

+ + {/* Comment */} +