// lib/core/models/notification_model.dart
import 'package:cloud_firestore/cloud_firestore.dart';

class NotificationModel {
  final String id;
  final String title;
  final String body;
  final String tanggal;
  final String status; // 'read' atau 'unread'
  final String? type; // violation, attendance, academic, info

  NotificationModel({
    required this.id,
    required this.title,
    required this.body,
    required this.tanggal,
    required this.status,
    this.type,
  });

  factory NotificationModel.fromFirestore(DocumentSnapshot doc) {
    Map<String, dynamic> data = doc.data() as Map<String, dynamic>;
    return NotificationModel(
      id: doc.id,
      title: data['title'] ?? '',
      body: data['body'] ?? '',
      tanggal: data['tanggal'] ?? '',
      status: data['status'] ?? 'unread',
      // Logika penentuan tipe berdasarkan isi body (sebagai fallback)
      type: data['status_absensi'] != null ? 'attendance' : 'info',
    );
  }
}