adding pendind and solving problem with status of shifts
This commit is contained in:
@@ -42,11 +42,6 @@ class ViewOrdersRepositoryImpl implements IViewOrdersRepository {
|
||||
'Your Company';
|
||||
|
||||
return result.data.shiftRoles.map((dc.ListShiftRolesByBusinessAndDateRangeShiftRoles shiftRole) {
|
||||
print(
|
||||
'ViewOrders shiftRole: shiftId=${shiftRole.shiftId} roleId=${shiftRole.roleId} '
|
||||
'startTime=${shiftRole.startTime?.toJson()} endTime=${shiftRole.endTime?.toJson()} '
|
||||
'hours=${shiftRole.hours} totalValue=${shiftRole.totalValue}',
|
||||
);
|
||||
final DateTime? shiftDate = shiftRole.shift.date?.toDateTime();
|
||||
final String dateStr = shiftDate == null
|
||||
? ''
|
||||
@@ -58,7 +53,14 @@ class ViewOrdersRepositoryImpl implements IViewOrdersRepository {
|
||||
final double hours = shiftRole.hours ?? 0;
|
||||
final double totalValue = shiftRole.totalValue ?? 0;
|
||||
final double hourlyRate = _hourlyRate(shiftRole.totalValue, shiftRole.hours);
|
||||
final String status = filled >= workersNeeded ? 'filled' : 'open';
|
||||
// final String status = filled >= workersNeeded ? 'filled' : 'open';
|
||||
final String status = shiftRole.shift.status?.stringValue ?? 'OPEN';
|
||||
|
||||
print(
|
||||
'ViewOrders item: date=$dateStr status=$status shiftId=${shiftRole.shiftId} '
|
||||
'roleId=${shiftRole.roleId} start=${shiftRole.startTime?.toJson()} '
|
||||
'end=${shiftRole.endTime?.toJson()} hours=$hours totalValue=$totalValue',
|
||||
);
|
||||
|
||||
return domain.OrderItem(
|
||||
id: _shiftRoleKey(shiftRole.shiftId, shiftRole.roleId),
|
||||
|
||||
@@ -192,16 +192,18 @@ class ViewOrdersCubit extends Cubit<ViewOrdersState> {
|
||||
return ordersOnDate
|
||||
.where(
|
||||
(OrderItem s) =>
|
||||
<String>['open', 'filled', 'confirmed'].contains(s.status),
|
||||
// TODO(orders): move PENDING to its own tab once available.
|
||||
<String>['OPEN', 'FILLED', 'CONFIRMED', 'PENDING']
|
||||
.contains(s.status),
|
||||
)
|
||||
.toList();
|
||||
} else if (state.filterTab == 'active') {
|
||||
return ordersOnDate
|
||||
.where((OrderItem s) => s.status == 'in_progress')
|
||||
.where((OrderItem s) => s.status == 'IN_PROGRESS')
|
||||
.toList();
|
||||
} else if (state.filterTab == 'completed') {
|
||||
return ordersOnDate
|
||||
.where((OrderItem s) => s.status == 'completed')
|
||||
.where((OrderItem s) => s.status == 'COMPLETED')
|
||||
.toList();
|
||||
}
|
||||
return <OrderItem>[];
|
||||
@@ -218,11 +220,11 @@ class ViewOrdersCubit extends Cubit<ViewOrdersState> {
|
||||
|
||||
if (category == 'active') {
|
||||
return ordersOnDate
|
||||
.where((OrderItem s) => s.status == 'in_progress')
|
||||
.where((OrderItem s) => s.status == 'IN_PROGRESS')
|
||||
.length;
|
||||
} else if (category == 'completed') {
|
||||
return ordersOnDate
|
||||
.where((OrderItem s) => s.status == 'completed')
|
||||
.where((OrderItem s) => s.status == 'COMPLETED')
|
||||
.length;
|
||||
}
|
||||
return 0;
|
||||
@@ -239,7 +241,9 @@ class ViewOrdersCubit extends Cubit<ViewOrdersState> {
|
||||
return ordersOnDate
|
||||
.where(
|
||||
(OrderItem s) =>
|
||||
<String>['open', 'filled', 'confirmed'].contains(s.status),
|
||||
// TODO(orders): move PENDING to its own tab once available.
|
||||
<String>['OPEN', 'FILLED', 'CONFIRMED', 'PENDING']
|
||||
.contains(s.status),
|
||||
)
|
||||
.length;
|
||||
}
|
||||
|
||||
@@ -37,16 +37,16 @@ class _ViewOrderCardState extends State<ViewOrderCard> {
|
||||
/// Returns the semantic color for the given status.
|
||||
Color _getStatusColor({required String status}) {
|
||||
switch (status) {
|
||||
case 'open':
|
||||
case 'OPEN':
|
||||
return UiColors.primary;
|
||||
case 'filled':
|
||||
case 'confirmed':
|
||||
case 'FILLED':
|
||||
case 'CONFIRMED':
|
||||
return UiColors.textSuccess;
|
||||
case 'in_progress':
|
||||
case 'IN_PROGRESS':
|
||||
return UiColors.textWarning;
|
||||
case 'completed':
|
||||
case 'COMPLETED':
|
||||
return UiColors.primary;
|
||||
case 'cancelled':
|
||||
case 'CANCELED':
|
||||
return UiColors.destructive;
|
||||
default:
|
||||
return UiColors.textSecondary;
|
||||
@@ -56,17 +56,17 @@ class _ViewOrderCardState extends State<ViewOrderCard> {
|
||||
/// Returns the localized label for the given status.
|
||||
String _getStatusLabel({required String status}) {
|
||||
switch (status) {
|
||||
case 'open':
|
||||
case 'OPEN':
|
||||
return t.client_view_orders.card.open;
|
||||
case 'filled':
|
||||
case 'FILLED':
|
||||
return t.client_view_orders.card.filled;
|
||||
case 'confirmed':
|
||||
case 'CONFIRMED':
|
||||
return t.client_view_orders.card.confirmed;
|
||||
case 'in_progress':
|
||||
case 'IN_PROGRESS':
|
||||
return t.client_view_orders.card.in_progress;
|
||||
case 'completed':
|
||||
case 'COMPLETED':
|
||||
return t.client_view_orders.card.completed;
|
||||
case 'cancelled':
|
||||
case 'CANCELED':
|
||||
return t.client_view_orders.card.cancelled;
|
||||
default:
|
||||
return status.toUpperCase();
|
||||
|
||||
Reference in New Issue
Block a user