45 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| class EventOption {
 | |
|   final String id;
 | |
|   final String code; // Nouveau champ code
 | |
|   final String name;
 | |
|   final String details;
 | |
|   final double valMin;
 | |
|   final double valMax;
 | |
|   final List<String> eventTypes; // Changé de List<DocumentReference> à List<String>
 | |
| 
 | |
|   EventOption({
 | |
|     required this.id,
 | |
|     required this.code,
 | |
|     required this.name,
 | |
|     required this.details,
 | |
|     required this.valMin,
 | |
|     required this.valMax,
 | |
|     required this.eventTypes,
 | |
|   });
 | |
| 
 | |
|   factory EventOption.fromMap(Map<String, dynamic> map, String id) {
 | |
|     return EventOption(
 | |
|       id: id,
 | |
|       code: map['code'] ?? id, // Utilise le code ou l'ID en fallback
 | |
|       name: map['name'] ?? '',
 | |
|       details: map['details'] ?? '',
 | |
|       valMin: (map['valMin'] ?? 0.0).toDouble(),
 | |
|       valMax: (map['valMax'] ?? 0.0).toDouble(),
 | |
|       eventTypes: (map['eventTypes'] as List<dynamic>? ?? [])
 | |
|           .map((e) => e.toString()) // Convertit en String (supporte IDs et références)
 | |
|           .toList(),
 | |
|     );
 | |
|   }
 | |
| 
 | |
|   Map<String, dynamic> toMap() {
 | |
|     return {
 | |
|       'code': code,
 | |
|       'name': name,
 | |
|       'details': details,
 | |
|       'valMin': valMin,
 | |
|       'valMax': valMax,
 | |
|       'eventTypes': eventTypes,
 | |
|     };
 | |
|   }
 | |
| }
 | 
