Modifications des permissions, ajout Presta OK, vue calendrier ok
This commit is contained in:
@ -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');
|
||||
|
Reference in New Issue
Block a user