Co-authored-by: eddgranados12 <eddgranados12@users.noreply.github.com>
Co-authored-by: MENDOZA BALLARDO GAEL RICARDO <gael-meb123@users.noreply.github.com> Co-authored-by: Azareth-Tr <Azareth-Tr@users.noreply.github.com> modificacion de vistas panel admin, login, animaciones y implementacion de mascota
This commit is contained in:
31
recolecta_app/lib/features/admin/models/admin_driver.dart
Normal file
31
recolecta_app/lib/features/admin/models/admin_driver.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
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!;
|
||||
}
|
||||
29
recolecta_app/lib/features/admin/models/admin_route.dart
Normal file
29
recolecta_app/lib/features/admin/models/admin_route.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
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!;
|
||||
}
|
||||
16
recolecta_app/lib/features/admin/models/admin_unit.dart
Normal file
16
recolecta_app/lib/features/admin/models/admin_unit.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
class AdminUnitModel {
|
||||
final int id;
|
||||
final String? plate;
|
||||
final String status;
|
||||
|
||||
const AdminUnitModel({required this.id, this.plate, this.status = 'active'});
|
||||
|
||||
factory AdminUnitModel.fromJson(Map<String, dynamic> json) => AdminUnitModel(
|
||||
id: (json['id'] as num).toInt(),
|
||||
plate: json['plate'] as String?,
|
||||
status: (json['status'] as String?) ?? 'active',
|
||||
);
|
||||
|
||||
String get displayPlate =>
|
||||
plate == null || plate!.trim().isEmpty ? '#$id' : plate!;
|
||||
}
|
||||
34
recolecta_app/lib/features/admin/models/admin_user.dart
Normal file
34
recolecta_app/lib/features/admin/models/admin_user.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
class AdminUserModel {
|
||||
final String id;
|
||||
final String? name;
|
||||
final String? email;
|
||||
final String? phone;
|
||||
final String role;
|
||||
|
||||
const AdminUserModel({
|
||||
required this.id,
|
||||
this.name,
|
||||
this.email,
|
||||
this.phone,
|
||||
this.role = 'citizen',
|
||||
});
|
||||
|
||||
String get displayName =>
|
||||
(name == null || name!.trim().isEmpty) ? (email ?? phone ?? id) : name!;
|
||||
|
||||
String get initials {
|
||||
final source = displayName.trim();
|
||||
if (source.isEmpty) return '?';
|
||||
final parts = source.split(RegExp(r'\s+'));
|
||||
if (parts.length == 1) return parts.first.substring(0, 1).toUpperCase();
|
||||
return (parts[0].substring(0, 1) + parts[1].substring(0, 1)).toUpperCase();
|
||||
}
|
||||
|
||||
factory AdminUserModel.fromJson(Map<String, dynamic> json) => AdminUserModel(
|
||||
id: json['id'].toString(),
|
||||
name: json['name'] as String?,
|
||||
email: json['email'] as String?,
|
||||
phone: json['phone'] as String?,
|
||||
role: (json['role'] as String?) ?? 'citizen',
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user