feat: sales range date
This commit is contained in:
@@ -21,19 +21,26 @@ class SalesLoaderBloc extends Bloc<SalesLoaderEvent, SalesLoaderState> {
|
||||
Future<void> _onSalesLoaderEvent(
|
||||
SalesLoaderEvent event,
|
||||
Emitter<SalesLoaderState> emit,
|
||||
) async {
|
||||
emit(state.copyWith(isFetching: true, failureOptionSales: none()));
|
||||
) {
|
||||
return event.map(
|
||||
rangeDateChanged: (e) async {
|
||||
emit(state.copyWith(dateFrom: e.dateFrom, dateTo: e.dateTo));
|
||||
},
|
||||
fectched: (e) async {
|
||||
emit(state.copyWith(isFetching: true, failureOptionSales: none()));
|
||||
|
||||
final result = await _analyticRepository.getSales(
|
||||
dateFrom: DateTime.now().subtract(const Duration(days: 30)),
|
||||
dateTo: DateTime.now(),
|
||||
final result = await _analyticRepository.getSales(
|
||||
dateFrom: state.dateFrom,
|
||||
dateTo: state.dateTo,
|
||||
);
|
||||
|
||||
var data = result.fold(
|
||||
(f) => state.copyWith(failureOptionSales: optionOf(f)),
|
||||
(sales) => state.copyWith(sales: sales),
|
||||
);
|
||||
|
||||
emit(data.copyWith(isFetching: false));
|
||||
},
|
||||
);
|
||||
|
||||
var data = result.fold(
|
||||
(f) => state.copyWith(failureOptionSales: optionOf(f)),
|
||||
(sales) => state.copyWith(sales: sales),
|
||||
);
|
||||
|
||||
emit(data.copyWith(isFetching: false));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user