class AdminDriverModel {
  final String id;
  final String userId;
  final String? userName;
  final String? userEmail;
  final int? unitId;
  final String? plate;

  const AdminDriverModel({
    required this.id,
    required this.userId,
    this.userName,
    this.userEmail,
    this.unitId,
    this.plate,
  });

  factory AdminDriverModel.fromJson(Map<String, dynamic> json) =>
      AdminDriverModel(
        id: json['id'].toString(),
        userId: json['user_id'].toString(),
        userName: json['user_name'] as String?,
        userEmail: json['user_email'] as String?,
        unitId: (json['unit_id'] as num?)?.toInt(),
        plate: json['plate'] as String?,
      );

  String get displayName => userName == null || userName!.trim().isEmpty
      ? (userEmail ?? userId)
      : userName!;
}
