class AdminRouteModel {
  final String id;
  final String? name;
  final int? truckId;
  final String? turno;
  final String status;
  final int currentPositionId;

  const AdminRouteModel({
    required this.id,
    this.name,
    this.truckId,
    this.turno,
    this.status = 'pendiente',
    this.currentPositionId = 1,
  });

  factory AdminRouteModel.fromJson(Map<String, dynamic> json) =>
      AdminRouteModel(
        id: json['id'].toString(),
        name: json['name'] as String?,
        truckId: (json['truck_id'] as num?)?.toInt(),
        turno: json['turno'] as String?,
        status: (json['status'] as String?) ?? 'pendiente',
        currentPositionId: (json['current_position_id'] as num?)?.toInt() ?? 1,
      );

  String get displayName => name == null || name!.trim().isEmpty ? id : name!;
}
