today coverage ready
This commit is contained in:
@@ -17,8 +17,44 @@ class HomeRepositoryImpl implements HomeRepositoryInterface {
|
||||
HomeRepositoryImpl(this._mock, this._dataConnect);
|
||||
|
||||
@override
|
||||
Future<HomeDashboardData> getDashboardData() {
|
||||
return _mock.getDashboardData();
|
||||
Future<HomeDashboardData> getDashboardData() async {
|
||||
final HomeDashboardData baseData = await _mock.getDashboardData();
|
||||
final String? businessId = ClientSessionStore.instance.session?.business?.id;
|
||||
if (businessId == null || businessId.isEmpty) {
|
||||
return baseData;
|
||||
}
|
||||
|
||||
final DateTime now = DateTime.now();
|
||||
final DateTime start = DateTime(now.year, now.month, now.day);
|
||||
final DateTime end = DateTime(now.year, now.month, now.day, 23, 59, 59, 999);
|
||||
|
||||
final fdc.QueryResult<
|
||||
ListShiftRolesByBusinessAndDateRangeData,
|
||||
ListShiftRolesByBusinessAndDateRangeVariables> result =
|
||||
await _dataConnect
|
||||
.listShiftRolesByBusinessAndDateRange(
|
||||
businessId: businessId,
|
||||
start: _toTimestamp(start),
|
||||
end: _toTimestamp(end),
|
||||
)
|
||||
.execute();
|
||||
|
||||
int totalNeeded = 0;
|
||||
int totalFilled = 0;
|
||||
for (final ListShiftRolesByBusinessAndDateRangeShiftRoles shiftRole
|
||||
in result.data.shiftRoles) {
|
||||
totalNeeded += shiftRole.count;
|
||||
totalFilled += shiftRole.assigned ?? 0;
|
||||
}
|
||||
|
||||
return HomeDashboardData(
|
||||
weeklySpending: baseData.weeklySpending,
|
||||
next7DaysSpending: baseData.next7DaysSpending,
|
||||
weeklyShifts: baseData.weeklyShifts,
|
||||
next7DaysScheduled: baseData.next7DaysScheduled,
|
||||
totalNeeded: totalNeeded,
|
||||
totalFilled: totalFilled,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -21,10 +21,16 @@ class ClientHomeState extends Equatable {
|
||||
this.widgetOrder = const <String>[
|
||||
'actions',
|
||||
'reorder',
|
||||
'coverage',
|
||||
'spending',
|
||||
'liveActivity',
|
||||
],
|
||||
this.widgetVisibility = const <String, bool>{
|
||||
'actions': true,
|
||||
'reorder': true,
|
||||
'coverage': true,
|
||||
'spending': true,
|
||||
'liveActivity': true,
|
||||
},
|
||||
this.isEditMode = false,
|
||||
this.errorMessage,
|
||||
|
||||
Reference in New Issue
Block a user