Modifications des permissions, ajout Presta OK, vue calendrier ok

This commit is contained in:
2025-05-24 23:50:07 +02:00
parent 249a6d6074
commit 851b891a8a
18 changed files with 1077 additions and 304 deletions

View File

@ -11,24 +11,29 @@ class EventProvider with ChangeNotifier {
bool get isLoading => _isLoading;
// Récupérer les événements pour un utilisateur spécifique
Future<void> loadUserEvents(String userId) async {
Future<void> loadUserEvents(String userId,
{bool canViewAllEvents = false}) async {
_isLoading = true;
notifyListeners();
try {
print('Loading events for user: $userId');
// Récupérer uniquement les événements où l'utilisateur est dans la workforce
final eventsSnapshot = await _firestore
.collection('events')
.where('workforce', arrayContains: userId)
.get();
print(
'Loading events for user: $userId (canViewAllEvents: $canViewAllEvents)');
QuerySnapshot eventsSnapshot;
if (canViewAllEvents) {
eventsSnapshot = await _firestore.collection('events').get();
} else {
eventsSnapshot = await _firestore
.collection('events')
.where('workforce', arrayContains: userId)
.get();
}
print('Found ${eventsSnapshot.docs.length} events for user');
_events = eventsSnapshot.docs.map((doc) {
print('Event data: ${doc.data()}');
return EventModel.fromMap(doc.data(), doc.id);
return EventModel.fromMap(doc.data() as Map<String, dynamic>, doc.id);
}).toList();
print('Parsed ${_events.length} events');