57 lines
1.5 KiB
Dart
57 lines
1.5 KiB
Dart
class UnitOption {
|
|
final int id;
|
|
final String? plate;
|
|
final String? status;
|
|
const UnitOption({required this.id, this.plate, this.status});
|
|
|
|
factory UnitOption.fromJson(Map<String, dynamic> json) => UnitOption(
|
|
id: json['id'] as int,
|
|
plate: json['plate'] as String?,
|
|
status: json['status'] as String?,
|
|
);
|
|
|
|
String get label =>
|
|
plate != null && plate!.isNotEmpty ? 'Unidad $id · $plate' : 'Unidad $id';
|
|
}
|
|
|
|
class IncidentReport {
|
|
final int id;
|
|
final String userId;
|
|
final int? unitId;
|
|
final String category;
|
|
final String description;
|
|
final String? photoUrl;
|
|
final String status;
|
|
final String? createdAt;
|
|
|
|
const IncidentReport({
|
|
required this.id,
|
|
required this.userId,
|
|
this.unitId,
|
|
required this.category,
|
|
required this.description,
|
|
this.photoUrl,
|
|
required this.status,
|
|
this.createdAt,
|
|
});
|
|
|
|
factory IncidentReport.fromJson(Map<String, dynamic> json) => IncidentReport(
|
|
id: json['id'] as int,
|
|
userId: json['user_id'] as String,
|
|
unitId: json['unit_id'] as int?,
|
|
category: json['category'] as String,
|
|
description: json['description'] as String,
|
|
photoUrl: json['photo_url'] as String?,
|
|
status: (json['status'] as String?) ?? 'open',
|
|
createdAt: json['created_at'] as String?,
|
|
);
|
|
}
|
|
|
|
const incidentCategories = <String, String>{
|
|
'derrame': 'Derrame de residuos',
|
|
'dano_propiedad': 'Daño a propiedad',
|
|
'conducta': 'Conducta inadecuada',
|
|
'no_recoleccion': 'No pasó el camión',
|
|
'otro': 'Otro',
|
|
};
|