Understanding the rating system
Rating structure
Ratings in BarberApp consist of:Score
- Required field
- 1 to 5 stars
- Integer values only
- Visual star selection interface
Comment
- Optional field
- Maximum 145 characters
- Private feedback
- Not visible to specialists
When ratings are available
Clients can rate an appointment when: ✅ Conditions met:- Appointment status is “completed”
- Client is viewing their own appointment
- Appointment has not been rated yet
- Appointment is still pending
- Appointment was canceled
- Appointment already has a rating
- Viewing as a specialist
Rating an appointment
Accessing the rating dialog
Click 'Calificar Atención'
Click the yellow “Calificar Atención” (Rate Service) button.
This button only appears for completed appointments that haven’t been rated yet.
RateAppointmentComponent (appointment-rate.component.ts:47)
The rating dialog
The dialog displays: Header section:- Icon: Star icon in colored background
- Title: “Calificar Atención” (Rate Service)
- Message: “Valoramos tu sinceridad. Esta información no será visible para el especialista.”
- Star rating selector (required)
- Comment text area (optional)
- “Cancelar” (Cancel) - Close without saving
- “Confirmar” (Confirm) - Submit rating (disabled until valid)
Selecting a star rating
Interactive star selector
The rating interface includes 5 interactive stars:Hover over stars
- Stars light up in yellow (
text-yellow-400) as you hover - All stars up to the hovered position highlight
- Provides visual feedback before selection
hoverStar() (appointment-rate.component.ts:106-109)Click to select
- Click a star to lock in your rating
- Selected stars remain filled
- Unselected stars remain outlined
- Updates form value immediately
selectStar() (appointment-rate.component.ts:100-104)Star display logic
The stars use conditional rendering (appointment-rate.component.html:44-48):starFill- Solid filled star (when selected)star- Outlined star (when not selected)
- Yellow (
text-yellow-400) - Hovered or selected - Gray (
text-gray-300) - Not hovered or selected
Responsive star sizes
Stars adapt to screen size:- Desktop (
xs:block): 56px icons - Mobile (
xs:hidden): 40px icons
Adding a comment
Comment field details
Comentario (Comment)
- Label: “Comentario (Opcional)” (Comment - Optional)
- Placeholder: “Contanos tu experiencia.” (Tell us about your experience)
- Maximum length: 145 characters
- Character counter displayed
- Rows: 2 (auto-expands with
field-sizing-content) - Not required for submission
Character counter
A real-time counter shows character usage (appointment-rate.component.html:81-83):Form validation
Validation rules
The rating form validates:- Required: Must select a star rating
- Range: 1-5 (integer values)
- Validators:
Validators.required,Validators.min(1),Validators.max(5)
- Optional: Can be left empty
- Max length: 145 characters (enforced by textarea
maxLengthattribute) - Processing: Empty comments are stored as
undefined
Submit button behavior
The “Confirmar” (Confirm) button is: ✅ Enabled when:- A star rating has been selected (1-5)
- Form is valid
- No star rating selected
- Form validation fails
Submitting a rating
Submission process
Data processing
Empty comment field is converted to Code: appointment-rate.component.ts:92
undefined:Dialog closes
- Dialog plays closing animation (85ms)
- Form data is emitted to parent component
- Parent saves rating to appointment
Where ratings appear
In appointment details
Once rated, appointments display the rating in the Appointment Info component: Display format:- Label: “Calificación de la Atención” (Service Rating)
- Visual: Star icons (filled/unfilled based on score)
- Text: Score out of 5 (e.g., “(4/5)”)
Star rendering in details
The appointment info shows:- 5 stars total (stars array:
[1, 2, 3, 4, 5]) - Filled stars: Based on rating score (e.g., 4 filled for 4/5 rating)
- Size: 20px per star (smaller than rating dialog)
- Color: Yellow (
text-yellow-400)
Rating visibility
- Visible to clients
- Visible to specialists
- Visible to admins
- Own ratings on their appointment details
- Stars and score display
- Comment is stored but not displayed in UI
Rating data storage
Ratings are stored as part of the Appointment model: Data structure (appointment.model.ts:19):- Initially
undefinedfor new appointments - Set once when client submits rating
- Immutable after submission (no editing)
- Persisted in Firebase with appointment record
Dialog lifecycle
Opening animation
When the rating dialog opens (appointment-rate.component.ts:69-78):- Dialog element is shown via
showModal() - Close event listener is attached
- Layout is forced (
offsetHeightread) showingclass added viarequestAnimationFrame- CSS transitions animate the dialog in
Closing animation
When closing (appointment-rate.component.ts:85-98):closingclass is added- 85ms timeout allows CSS animation
- Dialog closes programmatically
- Result is emitted (rating data or
null)
Cleanup
On component destruction (appointment-rate.component.ts:81-83):Best practices
For clients
- Rate appointments after service completion
- Provide honest, constructive feedback
- Use comments to elaborate on your experience
- Remember: specialists cannot see your rating
For developers
- Always check
appointment.ratingexistence before displaying - Validate rating score is within 1-5 range
- Handle optional comment field properly
- Respect privacy settings (no specialist access)
Common scenarios
Can I edit a rating after submission?
Can I edit a rating after submission?
No, ratings are immutable once submitted. This ensures data integrity and prevents manipulation. If you want to change your rating, contact BarberApp support.
What if I close the dialog without rating?
What if I close the dialog without rating?
No rating is saved. The “Calificar Atención” button remains available, and you can rate the appointment later.
Can specialists see who rated them poorly?
Can specialists see who rated them poorly?
No. All ratings are anonymous from the specialist’s perspective. They cannot see individual ratings or comments.
Do ratings affect specialist ranking?
Do ratings affect specialist ranking?
Currently, ratings are collected but not used for public ranking. Future features may include aggregated statistics visible to specialists.
Can I rate an old appointment?
Can I rate an old appointment?
Yes, as long as the appointment is completed and hasn’t been rated yet. There’s no time limit for submitting ratings.
Technical implementation details
Component architecture
The rating system uses:- Dialog component:
RateAppointmentComponent(Angular standalone component) - Form management: Angular Reactive Forms with
FormBuilder - State management: Angular signals for
hoveredStarandselectedStar - Change detection:
OnPushstrategy for performance - Dialog service: Centralized dialog management
Event flow
- Button click →
rateAppointmentHandler()called - Dialog opens →
RateAppointmentComponentinstantiated - User interacts → Star selection and comment input
- Form submit → Validation and data processing
- Dialog closes →
closedEventEmitter fires - Parent receives →
rateAppointmentEventEmitter in parent - Data persists → Rating saved to appointment in Firebase
Related topics
- Medical records - Where completed appointments are stored
- Appointments - Full appointment lifecycle
- Specialist dashboard - How specialists mark appointments complete