refactor: Remove HomeConnectorRepository abstraction, moving its data processing logic directly into HomeRepositoryImpl.
This commit is contained in:
@@ -6,7 +6,6 @@
|
|||||||
/// They will implement interfaces defined in feature packages once those are created.
|
/// They will implement interfaces defined in feature packages once those are created.
|
||||||
library;
|
library;
|
||||||
|
|
||||||
|
|
||||||
export 'src/data_connect_module.dart';
|
export 'src/data_connect_module.dart';
|
||||||
export 'src/session/client_session_store.dart';
|
export 'src/session/client_session_store.dart';
|
||||||
|
|
||||||
@@ -45,10 +44,6 @@ export 'src/connectors/hubs/data/repositories/hubs_connector_repository_impl.dar
|
|||||||
export 'src/connectors/billing/domain/repositories/billing_connector_repository.dart';
|
export 'src/connectors/billing/domain/repositories/billing_connector_repository.dart';
|
||||||
export 'src/connectors/billing/data/repositories/billing_connector_repository_impl.dart';
|
export 'src/connectors/billing/data/repositories/billing_connector_repository_impl.dart';
|
||||||
|
|
||||||
// Export Home Connector
|
|
||||||
export 'src/connectors/home/domain/repositories/home_connector_repository.dart';
|
|
||||||
export 'src/connectors/home/data/repositories/home_connector_repository_impl.dart';
|
|
||||||
|
|
||||||
// Export Coverage Connector
|
// Export Coverage Connector
|
||||||
export 'src/connectors/coverage/domain/repositories/coverage_connector_repository.dart';
|
export 'src/connectors/coverage/domain/repositories/coverage_connector_repository.dart';
|
||||||
export 'src/connectors/coverage/data/repositories/coverage_connector_repository_impl.dart';
|
export 'src/connectors/coverage/data/repositories/coverage_connector_repository_impl.dart';
|
||||||
|
|||||||
@@ -1,113 +0,0 @@
|
|||||||
// ignore_for_file: always_specify_types, depend_on_referenced_packages, dead_code, dead_null_aware_expression, unused_local_variable, unused_import, sort_constructors_first, prefer_final_fields, prefer_const_constructors, deprecated_member_use, implicit_call_tearoffs
|
|
||||||
import 'package:firebase_data_connect/src/core/ref.dart';
|
|
||||||
import 'package:krow_data_connect/krow_data_connect.dart' as dc;
|
|
||||||
import 'package:krow_domain/krow_domain.dart';
|
|
||||||
import '../../domain/repositories/home_connector_repository.dart';
|
|
||||||
|
|
||||||
/// Implementation of [HomeConnectorRepository].
|
|
||||||
class HomeConnectorRepositoryImpl implements HomeConnectorRepository {
|
|
||||||
HomeConnectorRepositoryImpl({
|
|
||||||
dc.DataConnectService? service,
|
|
||||||
}) : _service = service ?? dc.DataConnectService.instance;
|
|
||||||
|
|
||||||
final dc.DataConnectService _service;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<HomeDashboardData> getDashboardData({required String businessId}) async {
|
|
||||||
return _service.run(() async {
|
|
||||||
final DateTime now = DateTime.now();
|
|
||||||
final int daysFromMonday = now.weekday - DateTime.monday;
|
|
||||||
final DateTime monday = DateTime(now.year, now.month, now.day).subtract(Duration(days: daysFromMonday));
|
|
||||||
final DateTime weekRangeStart = monday;
|
|
||||||
final DateTime weekRangeEnd = monday.add(const Duration(days: 13, hours: 23, minutes: 59, seconds: 59));
|
|
||||||
|
|
||||||
final QueryResult<dc.GetCompletedShiftsByBusinessIdData, dc.GetCompletedShiftsByBusinessIdVariables> completedResult = await _service.connector
|
|
||||||
.getCompletedShiftsByBusinessId(
|
|
||||||
businessId: businessId,
|
|
||||||
dateFrom: _service.toTimestamp(weekRangeStart),
|
|
||||||
dateTo: _service.toTimestamp(weekRangeEnd),
|
|
||||||
)
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
double weeklySpending = 0.0;
|
|
||||||
double next7DaysSpending = 0.0;
|
|
||||||
int weeklyShifts = 0;
|
|
||||||
int next7DaysScheduled = 0;
|
|
||||||
|
|
||||||
for (final dc.GetCompletedShiftsByBusinessIdShifts shift in completedResult.data.shifts) {
|
|
||||||
final DateTime? shiftDate = _service.toDateTime(shift.date);
|
|
||||||
if (shiftDate == null) continue;
|
|
||||||
|
|
||||||
final int offset = shiftDate.difference(weekRangeStart).inDays;
|
|
||||||
if (offset < 0 || offset > 13) continue;
|
|
||||||
|
|
||||||
final double cost = shift.cost ?? 0.0;
|
|
||||||
if (offset <= 6) {
|
|
||||||
weeklySpending += cost;
|
|
||||||
weeklyShifts += 1;
|
|
||||||
} else {
|
|
||||||
next7DaysSpending += cost;
|
|
||||||
next7DaysScheduled += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final DateTime start = DateTime(now.year, now.month, now.day);
|
|
||||||
final DateTime end = start.add(const Duration(hours: 23, minutes: 59, seconds: 59));
|
|
||||||
|
|
||||||
final QueryResult<dc.ListShiftRolesByBusinessAndDateRangeData, dc.ListShiftRolesByBusinessAndDateRangeVariables> result = await _service.connector
|
|
||||||
.listShiftRolesByBusinessAndDateRange(
|
|
||||||
businessId: businessId,
|
|
||||||
start: _service.toTimestamp(start),
|
|
||||||
end: _service.toTimestamp(end),
|
|
||||||
)
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
int totalNeeded = 0;
|
|
||||||
int totalFilled = 0;
|
|
||||||
for (final dc.ListShiftRolesByBusinessAndDateRangeShiftRoles shiftRole in result.data.shiftRoles) {
|
|
||||||
totalNeeded += shiftRole.count;
|
|
||||||
totalFilled += shiftRole.assigned ?? 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return HomeDashboardData(
|
|
||||||
weeklySpending: weeklySpending,
|
|
||||||
next7DaysSpending: next7DaysSpending,
|
|
||||||
weeklyShifts: weeklyShifts,
|
|
||||||
next7DaysScheduled: next7DaysScheduled,
|
|
||||||
totalNeeded: totalNeeded,
|
|
||||||
totalFilled: totalFilled,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<ReorderItem>> getRecentReorders({required String businessId}) async {
|
|
||||||
return _service.run(() async {
|
|
||||||
final DateTime now = DateTime.now();
|
|
||||||
final DateTime start = now.subtract(const Duration(days: 30));
|
|
||||||
|
|
||||||
final QueryResult<dc.ListShiftRolesByBusinessDateRangeCompletedOrdersData, dc.ListShiftRolesByBusinessDateRangeCompletedOrdersVariables> result = await _service.connector
|
|
||||||
.listShiftRolesByBusinessDateRangeCompletedOrders(
|
|
||||||
businessId: businessId,
|
|
||||||
start: _service.toTimestamp(start),
|
|
||||||
end: _service.toTimestamp(now),
|
|
||||||
)
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
return result.data.shiftRoles.map((dc.ListShiftRolesByBusinessDateRangeCompletedOrdersShiftRoles shiftRole) {
|
|
||||||
final String location = shiftRole.shift.location ?? shiftRole.shift.locationAddress ?? '';
|
|
||||||
final String type = shiftRole.shift.order.orderType.stringValue;
|
|
||||||
return ReorderItem(
|
|
||||||
orderId: shiftRole.shift.order.id,
|
|
||||||
title: '${shiftRole.role.name} - ${shiftRole.shift.title}',
|
|
||||||
location: location,
|
|
||||||
hourlyRate: shiftRole.role.costPerHour,
|
|
||||||
hours: shiftRole.hours ?? 0,
|
|
||||||
workers: shiftRole.count,
|
|
||||||
type: type,
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import 'package:krow_domain/krow_domain.dart';
|
|
||||||
|
|
||||||
/// Repository interface for home connector operations.
|
|
||||||
///
|
|
||||||
/// This acts as a buffer layer between the domain repository and the Data Connect SDK.
|
|
||||||
abstract interface class HomeConnectorRepository {
|
|
||||||
/// Fetches dashboard data for a business.
|
|
||||||
Future<HomeDashboardData> getDashboardData({required String businessId});
|
|
||||||
|
|
||||||
/// Fetches recent reorder items for a business.
|
|
||||||
Future<List<ReorderItem>> getRecentReorders({required String businessId});
|
|
||||||
}
|
|
||||||
@@ -7,8 +7,6 @@ import 'connectors/hubs/domain/repositories/hubs_connector_repository.dart';
|
|||||||
import 'connectors/hubs/data/repositories/hubs_connector_repository_impl.dart';
|
import 'connectors/hubs/data/repositories/hubs_connector_repository_impl.dart';
|
||||||
import 'connectors/billing/domain/repositories/billing_connector_repository.dart';
|
import 'connectors/billing/domain/repositories/billing_connector_repository.dart';
|
||||||
import 'connectors/billing/data/repositories/billing_connector_repository_impl.dart';
|
import 'connectors/billing/data/repositories/billing_connector_repository_impl.dart';
|
||||||
import 'connectors/home/domain/repositories/home_connector_repository.dart';
|
|
||||||
import 'connectors/home/data/repositories/home_connector_repository_impl.dart';
|
|
||||||
import 'connectors/coverage/domain/repositories/coverage_connector_repository.dart';
|
import 'connectors/coverage/domain/repositories/coverage_connector_repository.dart';
|
||||||
import 'connectors/coverage/data/repositories/coverage_connector_repository_impl.dart';
|
import 'connectors/coverage/data/repositories/coverage_connector_repository_impl.dart';
|
||||||
import 'services/data_connect_service.dart';
|
import 'services/data_connect_service.dart';
|
||||||
@@ -32,9 +30,6 @@ class DataConnectModule extends Module {
|
|||||||
i.addLazySingleton<BillingConnectorRepository>(
|
i.addLazySingleton<BillingConnectorRepository>(
|
||||||
BillingConnectorRepositoryImpl.new,
|
BillingConnectorRepositoryImpl.new,
|
||||||
);
|
);
|
||||||
i.addLazySingleton<HomeConnectorRepository>(
|
|
||||||
HomeConnectorRepositoryImpl.new,
|
|
||||||
);
|
|
||||||
i.addLazySingleton<CoverageConnectorRepository>(
|
i.addLazySingleton<CoverageConnectorRepository>(
|
||||||
CoverageConnectorRepositoryImpl.new,
|
CoverageConnectorRepositoryImpl.new,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ import '../connectors/hubs/domain/repositories/hubs_connector_repository.dart';
|
|||||||
import '../connectors/hubs/data/repositories/hubs_connector_repository_impl.dart';
|
import '../connectors/hubs/data/repositories/hubs_connector_repository_impl.dart';
|
||||||
import '../connectors/billing/domain/repositories/billing_connector_repository.dart';
|
import '../connectors/billing/domain/repositories/billing_connector_repository.dart';
|
||||||
import '../connectors/billing/data/repositories/billing_connector_repository_impl.dart';
|
import '../connectors/billing/data/repositories/billing_connector_repository_impl.dart';
|
||||||
import '../connectors/home/domain/repositories/home_connector_repository.dart';
|
|
||||||
import '../connectors/home/data/repositories/home_connector_repository_impl.dart';
|
|
||||||
import '../connectors/coverage/domain/repositories/coverage_connector_repository.dart';
|
import '../connectors/coverage/domain/repositories/coverage_connector_repository.dart';
|
||||||
import '../connectors/coverage/data/repositories/coverage_connector_repository_impl.dart';
|
import '../connectors/coverage/data/repositories/coverage_connector_repository_impl.dart';
|
||||||
import '../connectors/staff/domain/repositories/staff_connector_repository.dart';
|
import '../connectors/staff/domain/repositories/staff_connector_repository.dart';
|
||||||
@@ -39,7 +37,6 @@ class DataConnectService with DataErrorHandler, SessionHandlerMixin {
|
|||||||
ShiftsConnectorRepository? _shiftsRepository;
|
ShiftsConnectorRepository? _shiftsRepository;
|
||||||
HubsConnectorRepository? _hubsRepository;
|
HubsConnectorRepository? _hubsRepository;
|
||||||
BillingConnectorRepository? _billingRepository;
|
BillingConnectorRepository? _billingRepository;
|
||||||
HomeConnectorRepository? _homeRepository;
|
|
||||||
CoverageConnectorRepository? _coverageRepository;
|
CoverageConnectorRepository? _coverageRepository;
|
||||||
StaffConnectorRepository? _staffRepository;
|
StaffConnectorRepository? _staffRepository;
|
||||||
|
|
||||||
@@ -63,14 +60,11 @@ class DataConnectService with DataErrorHandler, SessionHandlerMixin {
|
|||||||
return _billingRepository ??= BillingConnectorRepositoryImpl(service: this);
|
return _billingRepository ??= BillingConnectorRepositoryImpl(service: this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the home connector repository.
|
|
||||||
HomeConnectorRepository getHomeRepository() {
|
|
||||||
return _homeRepository ??= HomeConnectorRepositoryImpl(service: this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the coverage connector repository.
|
/// Gets the coverage connector repository.
|
||||||
CoverageConnectorRepository getCoverageRepository() {
|
CoverageConnectorRepository getCoverageRepository() {
|
||||||
return _coverageRepository ??= CoverageConnectorRepositoryImpl(service: this);
|
return _coverageRepository ??= CoverageConnectorRepositoryImpl(
|
||||||
|
service: this,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the staff connector repository.
|
/// Gets the staff connector repository.
|
||||||
@@ -85,7 +79,7 @@ class DataConnectService with DataErrorHandler, SessionHandlerMixin {
|
|||||||
/// Helper to get the current staff ID from the session.
|
/// Helper to get the current staff ID from the session.
|
||||||
Future<String> getStaffId() async {
|
Future<String> getStaffId() async {
|
||||||
String? staffId = dc.StaffSessionStore.instance.session?.ownerId;
|
String? staffId = dc.StaffSessionStore.instance.session?.ownerId;
|
||||||
|
|
||||||
if (staffId == null || staffId.isEmpty) {
|
if (staffId == null || staffId.isEmpty) {
|
||||||
// Attempt to recover session if user is signed in
|
// Attempt to recover session if user is signed in
|
||||||
final user = auth.currentUser;
|
final user = auth.currentUser;
|
||||||
@@ -128,7 +122,9 @@ class DataConnectService with DataErrorHandler, SessionHandlerMixin {
|
|||||||
|
|
||||||
// Load Staff Session if applicable
|
// Load Staff Session if applicable
|
||||||
if (role == 'STAFF' || role == 'BOTH') {
|
if (role == 'STAFF' || role == 'BOTH') {
|
||||||
final response = await connector.getStaffByUserId(userId: userId).execute();
|
final response = await connector
|
||||||
|
.getStaffByUserId(userId: userId)
|
||||||
|
.execute();
|
||||||
if (response.data.staffs.isNotEmpty) {
|
if (response.data.staffs.isNotEmpty) {
|
||||||
final s = response.data.staffs.first;
|
final s = response.data.staffs.first;
|
||||||
dc.StaffSessionStore.instance.setSession(
|
dc.StaffSessionStore.instance.setSession(
|
||||||
@@ -151,7 +147,9 @@ class DataConnectService with DataErrorHandler, SessionHandlerMixin {
|
|||||||
|
|
||||||
// Load Client Session if applicable
|
// Load Client Session if applicable
|
||||||
if (role == 'BUSINESS' || role == 'BOTH') {
|
if (role == 'BUSINESS' || role == 'BOTH') {
|
||||||
final response = await connector.getBusinessesByUserId(userId: userId).execute();
|
final response = await connector
|
||||||
|
.getBusinessesByUserId(userId: userId)
|
||||||
|
.execute();
|
||||||
if (response.data.businesses.isNotEmpty) {
|
if (response.data.businesses.isNotEmpty) {
|
||||||
final b = response.data.businesses.first;
|
final b = response.data.businesses.first;
|
||||||
dc.ClientSessionStore.instance.setSession(
|
dc.ClientSessionStore.instance.setSession(
|
||||||
@@ -225,7 +223,6 @@ class DataConnectService with DataErrorHandler, SessionHandlerMixin {
|
|||||||
_shiftsRepository = null;
|
_shiftsRepository = null;
|
||||||
_hubsRepository = null;
|
_hubsRepository = null;
|
||||||
_billingRepository = null;
|
_billingRepository = null;
|
||||||
_homeRepository = null;
|
|
||||||
_coverageRepository = null;
|
_coverageRepository = null;
|
||||||
_staffRepository = null;
|
_staffRepository = null;
|
||||||
|
|
||||||
|
|||||||
@@ -3,25 +3,98 @@ import 'package:krow_data_connect/krow_data_connect.dart' as dc;
|
|||||||
import 'package:krow_domain/krow_domain.dart';
|
import 'package:krow_domain/krow_domain.dart';
|
||||||
import '../../domain/repositories/home_repository_interface.dart';
|
import '../../domain/repositories/home_repository_interface.dart';
|
||||||
|
|
||||||
/// Implementation of [HomeRepositoryInterface] that delegates to [dc.HomeConnectorRepository].
|
/// Implementation of [HomeRepositoryInterface] that directly interacts with the Data Connect SDK.
|
||||||
///
|
|
||||||
/// This implementation follows the "Buffer Layer" pattern by using a dedicated
|
|
||||||
/// connector repository from the data_connect package.
|
|
||||||
class HomeRepositoryImpl implements HomeRepositoryInterface {
|
class HomeRepositoryImpl implements HomeRepositoryInterface {
|
||||||
HomeRepositoryImpl({
|
HomeRepositoryImpl({dc.DataConnectService? service})
|
||||||
dc.HomeConnectorRepository? connectorRepository,
|
: _service = service ?? dc.DataConnectService.instance;
|
||||||
dc.DataConnectService? service,
|
|
||||||
}) : _connectorRepository =
|
|
||||||
connectorRepository ??
|
|
||||||
dc.DataConnectService.instance.getHomeRepository(),
|
|
||||||
_service = service ?? dc.DataConnectService.instance;
|
|
||||||
final dc.HomeConnectorRepository _connectorRepository;
|
|
||||||
final dc.DataConnectService _service;
|
final dc.DataConnectService _service;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<HomeDashboardData> getDashboardData() async {
|
Future<HomeDashboardData> getDashboardData() async {
|
||||||
final String businessId = await _service.getBusinessId();
|
return _service.run(() async {
|
||||||
return _connectorRepository.getDashboardData(businessId: businessId);
|
final String businessId = await _service.getBusinessId();
|
||||||
|
final DateTime now = DateTime.now();
|
||||||
|
final int daysFromMonday = now.weekday - DateTime.monday;
|
||||||
|
final DateTime monday = DateTime(
|
||||||
|
now.year,
|
||||||
|
now.month,
|
||||||
|
now.day,
|
||||||
|
).subtract(Duration(days: daysFromMonday));
|
||||||
|
final DateTime weekRangeStart = monday;
|
||||||
|
final DateTime weekRangeEnd = monday.add(
|
||||||
|
const Duration(days: 13, hours: 23, minutes: 59, seconds: 59),
|
||||||
|
);
|
||||||
|
|
||||||
|
final QueryResult<
|
||||||
|
dc.GetCompletedShiftsByBusinessIdData,
|
||||||
|
dc.GetCompletedShiftsByBusinessIdVariables
|
||||||
|
>
|
||||||
|
completedResult = await _service.connector
|
||||||
|
.getCompletedShiftsByBusinessId(
|
||||||
|
businessId: businessId,
|
||||||
|
dateFrom: _service.toTimestamp(weekRangeStart),
|
||||||
|
dateTo: _service.toTimestamp(weekRangeEnd),
|
||||||
|
)
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
double weeklySpending = 0.0;
|
||||||
|
double next7DaysSpending = 0.0;
|
||||||
|
int weeklyShifts = 0;
|
||||||
|
int next7DaysScheduled = 0;
|
||||||
|
|
||||||
|
for (final dc.GetCompletedShiftsByBusinessIdShifts shift
|
||||||
|
in completedResult.data.shifts) {
|
||||||
|
final DateTime? shiftDate = _service.toDateTime(shift.date);
|
||||||
|
if (shiftDate == null) continue;
|
||||||
|
|
||||||
|
final int offset = shiftDate.difference(weekRangeStart).inDays;
|
||||||
|
if (offset < 0 || offset > 13) continue;
|
||||||
|
|
||||||
|
final double cost = shift.cost ?? 0.0;
|
||||||
|
if (offset <= 6) {
|
||||||
|
weeklySpending += cost;
|
||||||
|
weeklyShifts += 1;
|
||||||
|
} else {
|
||||||
|
next7DaysSpending += cost;
|
||||||
|
next7DaysScheduled += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final DateTime start = DateTime(now.year, now.month, now.day);
|
||||||
|
final DateTime end = start.add(
|
||||||
|
const Duration(hours: 23, minutes: 59, seconds: 59),
|
||||||
|
);
|
||||||
|
|
||||||
|
final QueryResult<
|
||||||
|
dc.ListShiftRolesByBusinessAndDateRangeData,
|
||||||
|
dc.ListShiftRolesByBusinessAndDateRangeVariables
|
||||||
|
>
|
||||||
|
result = await _service.connector
|
||||||
|
.listShiftRolesByBusinessAndDateRange(
|
||||||
|
businessId: businessId,
|
||||||
|
start: _service.toTimestamp(start),
|
||||||
|
end: _service.toTimestamp(end),
|
||||||
|
)
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
int totalNeeded = 0;
|
||||||
|
int totalFilled = 0;
|
||||||
|
for (final dc.ListShiftRolesByBusinessAndDateRangeShiftRoles shiftRole
|
||||||
|
in result.data.shiftRoles) {
|
||||||
|
totalNeeded += shiftRole.count;
|
||||||
|
totalFilled += shiftRole.assigned ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return HomeDashboardData(
|
||||||
|
weeklySpending: weeklySpending,
|
||||||
|
next7DaysSpending: next7DaysSpending,
|
||||||
|
weeklyShifts: weeklyShifts,
|
||||||
|
next7DaysScheduled: next7DaysScheduled,
|
||||||
|
totalNeeded: totalNeeded,
|
||||||
|
totalFilled: totalFilled,
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -69,7 +142,39 @@ class HomeRepositoryImpl implements HomeRepositoryInterface {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<ReorderItem>> getRecentReorders() async {
|
Future<List<ReorderItem>> getRecentReorders() async {
|
||||||
final String businessId = await _service.getBusinessId();
|
return _service.run(() async {
|
||||||
return _connectorRepository.getRecentReorders(businessId: businessId);
|
final String businessId = await _service.getBusinessId();
|
||||||
|
final DateTime now = DateTime.now();
|
||||||
|
final DateTime start = now.subtract(const Duration(days: 30));
|
||||||
|
|
||||||
|
final QueryResult<
|
||||||
|
dc.ListShiftRolesByBusinessDateRangeCompletedOrdersData,
|
||||||
|
dc.ListShiftRolesByBusinessDateRangeCompletedOrdersVariables
|
||||||
|
>
|
||||||
|
result = await _service.connector
|
||||||
|
.listShiftRolesByBusinessDateRangeCompletedOrders(
|
||||||
|
businessId: businessId,
|
||||||
|
start: _service.toTimestamp(start),
|
||||||
|
end: _service.toTimestamp(now),
|
||||||
|
)
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
return result.data.shiftRoles.map((
|
||||||
|
dc.ListShiftRolesByBusinessDateRangeCompletedOrdersShiftRoles shiftRole,
|
||||||
|
) {
|
||||||
|
final String location =
|
||||||
|
shiftRole.shift.location ?? shiftRole.shift.locationAddress ?? '';
|
||||||
|
final String type = shiftRole.shift.order.orderType.stringValue;
|
||||||
|
return ReorderItem(
|
||||||
|
orderId: shiftRole.shift.order.id,
|
||||||
|
title: '${shiftRole.role.name} - ${shiftRole.shift.title}',
|
||||||
|
location: location,
|
||||||
|
hourlyRate: shiftRole.role.costPerHour,
|
||||||
|
hours: shiftRole.hours ?? 0,
|
||||||
|
workers: shiftRole.count,
|
||||||
|
type: type,
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user