feat: Combine logic of count calculations in ViewOrdersCubit and update date handling for order filtering

This commit is contained in:
Achintha Isuru
2026-02-04 09:04:11 -05:00
parent ad48d47ded
commit c63ea40ce9
2 changed files with 9 additions and 2 deletions

View File

@@ -252,13 +252,19 @@ class ViewOrdersCubit extends Cubit<ViewOrdersState> {
}
int _calculateCategoryCount(String category) {
if (state.selectedDate == null) return 0;
final String selectedDateStr = DateFormat(
'yyyy-MM-dd',
).format(state.selectedDate!);
if (category == 'active') {
return state.orders
.where((OrderItem s) => s.status == 'IN_PROGRESS')
.where((OrderItem s) => s.date == selectedDateStr && s.status == 'IN_PROGRESS')
.length;
} else if (category == 'completed') {
return state.orders
.where((OrderItem s) => s.status == 'COMPLETED')
.where((OrderItem s) => s.date == selectedDateStr && s.status == 'COMPLETED')
.length;
}
return 0;