V1 calendrier

This commit is contained in:
ElPoyo
2025-10-10 14:58:05 +02:00
parent 080fb7d077
commit aae68f8ab7
26 changed files with 1328 additions and 847 deletions

View File

@@ -1,5 +1,4 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:latlong2/latlong.dart';
enum EventStatus {
confirmed,
@@ -41,6 +40,7 @@ class EventModel {
final int installationTime;
final int disassemblyTime;
final String eventTypeId;
final DocumentReference? eventTypeRef;
final String customerId;
final String address;
final double latitude;
@@ -60,6 +60,7 @@ class EventModel {
required this.installationTime,
required this.disassemblyTime,
required this.eventTypeId,
this.eventTypeRef,
required this.customerId,
required this.address,
required this.latitude,
@@ -79,7 +80,7 @@ class EventModel {
final docs = docsRaw is List
? docsRaw.map<Map<String, String>>((e) {
if (e is Map) {
return Map<String, String>.from(e as Map);
return Map<String, String>.from(e);
} else if (e is String) {
final fileName = Uri.decodeComponent(
e.split('/').last.split('?').first,
@@ -94,7 +95,7 @@ class EventModel {
final options = optionsRaw is List
? optionsRaw.map<Map<String, dynamic>>((e) {
if (e is Map) {
return Map<String, dynamic>.from(e as Map);
return Map<String, dynamic>.from(e);
} else {
return {};
}
@@ -112,7 +113,10 @@ class EventModel {
disassemblyTime: map['DisassemblyTime'] ?? 0,
eventTypeId: map['EventType'] is DocumentReference
? (map['EventType'] as DocumentReference).id
: '',
: map['EventType'] ?? '',
eventTypeRef: map['EventType'] is DocumentReference
? map['EventType'] as DocumentReference
: null,
customerId: map['customer'] is DocumentReference
? (map['customer'] as DocumentReference).id
: '',
@@ -135,8 +139,8 @@ class EventModel {
'BasePrice': basePrice,
'InstallationTime': installationTime,
'DisassemblyTime': disassemblyTime,
'EventType': eventTypeId,
'customer': customerId,
'EventType': eventTypeId.isNotEmpty ? FirebaseFirestore.instance.collection('eventTypes').doc(eventTypeId) : null,
'customer': customerId.isNotEmpty ? FirebaseFirestore.instance.collection('customers').doc(customerId) : null,
'Address': address,
'Position': GeoPoint(latitude, longitude),
'Latitude': latitude,

View File

@@ -0,0 +1,32 @@
import 'package:cloud_firestore/cloud_firestore.dart';
class EventType {
final String id;
final String name;
final double defaultPrice;
EventType({
required this.id,
required this.name,
required this.defaultPrice,
});
factory EventType.fromFirestore(DocumentSnapshot doc) {
Map<String, dynamic> data = doc.data() as Map<String, dynamic>;
double price = 0.0;
final priceData = data['defaultPrice'];
if (priceData is num) {
price = priceData.toDouble();
} else if (priceData is String) {
price = double.tryParse(priceData.replaceAll(',', '.')) ?? 0.0;
}
return EventType(
id: doc.id,
name: data['name'] ?? '',
defaultPrice: price,
);
}
}

View File

@@ -1,4 +1,3 @@
import 'package:cloud_firestore/cloud_firestore.dart';
class RoleModel {
final String id;