// lib/data/models/comment_model.dart

import 'package:equatable/equatable.dart';

class CommentModel extends Equatable {
  final String id;
  final String userName;
  final double rating;
  final String comment;
  final DateTime publishedAt;
  final List<String> uploadedImageUrls;

  const CommentModel({
    required this.id,
    required this.userName,
    required this.rating,
    required this.comment,
    required this.publishedAt,
    this.uploadedImageUrls = const [],
  });

  @override
  List<Object?> get props => [id, userName, rating, comment, publishedAt, uploadedImageUrls];

  factory CommentModel.fromJson(Map<String, dynamic> json) {
    return CommentModel(
      id: json['id'],
      userName: json['userName'],
      rating: (json['rating'] as num).toDouble(),
      comment: json['comment'],
      publishedAt: DateTime.parse(json['publishedAt']),
      uploadedImageUrls: List<String>.from(json['uploadedImageUrls'] ?? []),
    );
  }
}