ajout permssion de voir les prix
This commit is contained in:
@ -25,7 +25,8 @@ class EventProvider with ChangeNotifier {
|
|||||||
} else {
|
} else {
|
||||||
eventsSnapshot = await _firestore
|
eventsSnapshot = await _firestore
|
||||||
.collection('events')
|
.collection('events')
|
||||||
.where('workforce', arrayContains: userId)
|
.where('workforce',
|
||||||
|
arrayContains: _firestore.collection('users').doc(userId))
|
||||||
.get();
|
.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ class EventDetails extends StatelessWidget {
|
|||||||
final currentIndex = sortedEvents.indexWhere((e) => e.id == event.id);
|
final currentIndex = sortedEvents.indexWhere((e) => e.id == event.id);
|
||||||
final localUserProvider = Provider.of<LocalUserProvider>(context);
|
final localUserProvider = Provider.of<LocalUserProvider>(context);
|
||||||
final isAdmin = localUserProvider.hasPermission('view_all_users');
|
final isAdmin = localUserProvider.hasPermission('view_all_users');
|
||||||
|
final canViewPrices = localUserProvider.hasPermission('view_event_prices');
|
||||||
|
|
||||||
return Card(
|
return Card(
|
||||||
margin: const EdgeInsets.all(16),
|
margin: const EdgeInsets.all(16),
|
||||||
@ -139,6 +140,7 @@ class EventDetails extends StatelessWidget {
|
|||||||
'Date de fin',
|
'Date de fin',
|
||||||
dateFormat.format(event.endDateTime),
|
dateFormat.format(event.endDateTime),
|
||||||
),
|
),
|
||||||
|
if (canViewPrices)
|
||||||
_buildInfoRow(
|
_buildInfoRow(
|
||||||
context,
|
context,
|
||||||
Icons.euro,
|
Icons.euro,
|
||||||
@ -166,25 +168,30 @@ class EventDetails extends StatelessWidget {
|
|||||||
title: Text(opt['name'] ?? '',
|
title: Text(opt['name'] ?? '',
|
||||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
subtitle: Text(opt['details'] ?? ''),
|
subtitle: Text(opt['details'] ?? ''),
|
||||||
trailing: Text(
|
trailing: canViewPrices
|
||||||
|
? Text(
|
||||||
(isNegative ? '- ' : '+ ') +
|
(isNegative ? '- ' : '+ ') +
|
||||||
currencyFormat.format(price.abs()),
|
currencyFormat.format(price.abs()),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: isNegative ? Colors.red : AppColors.noir,
|
color: isNegative
|
||||||
|
? Colors.red
|
||||||
|
: AppColors.noir,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
|
: null,
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
dense: true,
|
dense: true,
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
),
|
||||||
|
if (canViewPrices) ...[
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Builder(
|
Builder(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
final total = event.basePrice +
|
final total = event.basePrice +
|
||||||
event.options.fold<num>(
|
event.options.fold<num>(0,
|
||||||
0, (sum, opt) => sum + (opt['price'] ?? 0.0));
|
(sum, opt) => sum + (opt['price'] ?? 0.0));
|
||||||
return Padding(
|
return Padding(
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.only(top: 8.0, bottom: 8.0),
|
const EdgeInsets.only(top: 8.0, bottom: 8.0),
|
||||||
@ -217,6 +224,7 @@ class EventDetails extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
],
|
||||||
_buildInfoRow(
|
_buildInfoRow(
|
||||||
context,
|
context,
|
||||||
Icons.build,
|
Icons.build,
|
||||||
|
Reference in New Issue
Block a user