71 lines
2.3 KiB
Dart
71 lines
2.3 KiB
Dart
// transit_admin_models.dart — نماذج بيانات مواصلاتي (لوحة إدارة تريبز)
|
|
|
|
class TransitOrgSummary {
|
|
final int id;
|
|
final String type;
|
|
final String country;
|
|
final String city;
|
|
final String nameAr;
|
|
final String nameEn;
|
|
final String? logoUrl;
|
|
final String contractStatus;
|
|
final String? trialEndsAt;
|
|
final int driversCount;
|
|
final int vehiclesCount;
|
|
final int activeRoutes;
|
|
final int activeEnrollments;
|
|
|
|
TransitOrgSummary({
|
|
required this.id,
|
|
required this.type,
|
|
required this.country,
|
|
required this.city,
|
|
required this.nameAr,
|
|
required this.nameEn,
|
|
required this.contractStatus,
|
|
this.logoUrl,
|
|
this.trialEndsAt,
|
|
this.driversCount = 0,
|
|
this.vehiclesCount = 0,
|
|
this.activeRoutes = 0,
|
|
this.activeEnrollments = 0,
|
|
});
|
|
|
|
factory TransitOrgSummary.fromJson(Map<String, dynamic> j) => TransitOrgSummary(
|
|
id: int.tryParse(j['id'].toString()) ?? 0,
|
|
type: j['type']?.toString() ?? '',
|
|
country: j['country']?.toString() ?? '',
|
|
city: j['city']?.toString() ?? '',
|
|
nameAr: j['name_ar']?.toString() ?? '',
|
|
nameEn: j['name_en']?.toString() ?? '',
|
|
logoUrl: j['logo_url']?.toString(),
|
|
contractStatus: j['contract_status']?.toString() ?? '',
|
|
trialEndsAt: j['trial_ends_at']?.toString(),
|
|
driversCount: int.tryParse(j['drivers_count']?.toString() ?? '0') ?? 0,
|
|
vehiclesCount: int.tryParse(j['vehicles_count']?.toString() ?? '0') ?? 0,
|
|
activeRoutes: int.tryParse(j['active_routes']?.toString() ?? '0') ?? 0,
|
|
activeEnrollments: int.tryParse(j['active_enrollments']?.toString() ?? '0') ?? 0,
|
|
);
|
|
}
|
|
|
|
class TransitOrgDetails {
|
|
final Map<String, dynamic> org;
|
|
final Map<String, dynamic> counts;
|
|
final Map<String, dynamic> trips;
|
|
final List<dynamic> routes;
|
|
|
|
TransitOrgDetails({
|
|
required this.org,
|
|
required this.counts,
|
|
required this.trips,
|
|
required this.routes,
|
|
});
|
|
|
|
factory TransitOrgDetails.fromJson(Map<String, dynamic> j) => TransitOrgDetails(
|
|
org: Map<String, dynamic>.from(j['org'] ?? {}),
|
|
counts: Map<String, dynamic>.from(j['counts'] ?? {}),
|
|
trips: Map<String, dynamic>.from(j['trips'] ?? {}),
|
|
routes: (j['routes'] is List) ? List<dynamic>.from(j['routes']) : [],
|
|
);
|
|
}
|