// lib/core/models/violation_history_model.dart

class ViolationHistory {
  final String date;        // Mapping: 'tgl'
  final String description; // Mapping: 'detail'
  final int point;          // Mapping: 'poin'
  final String category;    // Mapping: 'kategori'
  final String className;   // Mapping: 'kelas'

  ViolationHistory({
    required this.date,
    required this.description,
    required this.point,
    required this.category,
    required this.className,
  });

  // Factory untuk memetakan data langsung dari dokumen Firestore
  factory ViolationHistory.fromFirestore(Map<String, dynamic> data) {
    return ViolationHistory(
      date: data['tgl'] ?? '-',
      description: data['detail'] ?? '-',
      point: (data['poin'] as num?)?.toInt() ?? 0,
      category: data['kategori'] ?? '-',
      className: data['kelas'] ?? '-',
    );
  }
}