Compare commits
No commits in common. "d0e1f9a5b67c958d533f17bfab8450ee0048faa4" and "fe92082cebf0363984ef122b4c610f63392bec8e" have entirely different histories.
d0e1f9a5b6
...
fe92082ceb
@ -272,26 +272,18 @@ class OrderRemoteDatasource {
|
|||||||
String status = 'completed',
|
String status = 'completed',
|
||||||
required DateTime dateFrom,
|
required DateTime dateFrom,
|
||||||
required DateTime dateTo,
|
required DateTime dateTo,
|
||||||
String? search,
|
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
final authData = await AuthLocalDataSource().getAuthData();
|
final authData = await AuthLocalDataSource().getAuthData();
|
||||||
|
|
||||||
Map<String, dynamic> params = {
|
|
||||||
'page': page,
|
|
||||||
'limit': limit,
|
|
||||||
'status': status,
|
|
||||||
'date_from': DateFormat('dd-MM-yyyy').format(dateFrom),
|
|
||||||
'date_to': DateFormat('dd-MM-yyyy').format(dateTo),
|
|
||||||
};
|
|
||||||
|
|
||||||
if (search != null && search.isNotEmpty) {
|
|
||||||
params['search'] = search;
|
|
||||||
}
|
|
||||||
|
|
||||||
final response = await dio.get(
|
final response = await dio.get(
|
||||||
'${Variables.baseUrl}/api/v1/orders',
|
'${Variables.baseUrl}/api/v1/orders',
|
||||||
queryParameters: params,
|
queryParameters: {
|
||||||
|
'page': page,
|
||||||
|
'limit': limit,
|
||||||
|
'status': status,
|
||||||
|
'date_from': DateFormat('dd-MM-yyyy').format(dateFrom),
|
||||||
|
'date_to': DateFormat('dd-MM-yyyy').format(dateTo),
|
||||||
|
},
|
||||||
options: Options(
|
options: Options(
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer ${authData.token}',
|
'Authorization': 'Bearer ${authData.token}',
|
||||||
|
|||||||
@ -60,7 +60,6 @@ class OrderLoaderBloc extends Bloc<OrderLoaderEvent, OrderLoaderState> {
|
|||||||
status: event.status,
|
status: event.status,
|
||||||
dateFrom: event.dateFrom,
|
dateFrom: event.dateFrom,
|
||||||
dateTo: event.dateTo,
|
dateTo: event.dateTo,
|
||||||
search: event.search,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
await result.fold(
|
await result.fold(
|
||||||
@ -109,7 +108,6 @@ class OrderLoaderBloc extends Bloc<OrderLoaderEvent, OrderLoaderState> {
|
|||||||
status: event.status,
|
status: event.status,
|
||||||
dateFrom: event.dateFrom,
|
dateFrom: event.dateFrom,
|
||||||
dateTo: event.dateTo,
|
dateTo: event.dateTo,
|
||||||
search: event.search,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
await result.fold(
|
await result.fold(
|
||||||
|
|||||||
@ -18,36 +18,33 @@ final _privateConstructorUsedError = UnsupportedError(
|
|||||||
mixin _$OrderLoaderEvent {
|
mixin _$OrderLoaderEvent {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
required TResult Function(
|
||||||
int? limit, String? search)
|
String status, DateTime dateFrom, DateTime dateTo, int? limit)
|
||||||
getByStatus,
|
getByStatus,
|
||||||
required TResult Function(String id) getById,
|
required TResult Function(String id) getById,
|
||||||
required TResult Function(
|
required TResult Function(String status, DateTime dateFrom, DateTime dateTo)
|
||||||
String status, DateTime dateFrom, DateTime dateTo, String? search)
|
|
||||||
loadMore,
|
loadMore,
|
||||||
required TResult Function(String status) refresh,
|
required TResult Function(String status) refresh,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(String status, DateTime dateFrom, DateTime dateTo,
|
TResult? Function(
|
||||||
int? limit, String? search)?
|
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult? Function(String id)? getById,
|
TResult? Function(String id)? getById,
|
||||||
TResult? Function(
|
TResult? Function(String status, DateTime dateFrom, DateTime dateTo)?
|
||||||
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult? Function(String status)? refresh,
|
TResult? Function(String status)? refresh,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
TResult Function(
|
||||||
int? limit, String? search)?
|
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult Function(String id)? getById,
|
TResult Function(String id)? getById,
|
||||||
TResult Function(
|
TResult Function(String status, DateTime dateFrom, DateTime dateTo)?
|
||||||
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult Function(String status)? refresh,
|
TResult Function(String status)? refresh,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
@ -107,12 +104,7 @@ abstract class _$$GetByStatusImplCopyWith<$Res> {
|
|||||||
_$GetByStatusImpl value, $Res Function(_$GetByStatusImpl) then) =
|
_$GetByStatusImpl value, $Res Function(_$GetByStatusImpl) then) =
|
||||||
__$$GetByStatusImplCopyWithImpl<$Res>;
|
__$$GetByStatusImplCopyWithImpl<$Res>;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call(
|
$Res call({String status, DateTime dateFrom, DateTime dateTo, int? limit});
|
||||||
{String status,
|
|
||||||
DateTime dateFrom,
|
|
||||||
DateTime dateTo,
|
|
||||||
int? limit,
|
|
||||||
String? search});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -132,7 +124,6 @@ class __$$GetByStatusImplCopyWithImpl<$Res>
|
|||||||
Object? dateFrom = null,
|
Object? dateFrom = null,
|
||||||
Object? dateTo = null,
|
Object? dateTo = null,
|
||||||
Object? limit = freezed,
|
Object? limit = freezed,
|
||||||
Object? search = freezed,
|
|
||||||
}) {
|
}) {
|
||||||
return _then(_$GetByStatusImpl(
|
return _then(_$GetByStatusImpl(
|
||||||
null == status
|
null == status
|
||||||
@ -151,10 +142,6 @@ class __$$GetByStatusImplCopyWithImpl<$Res>
|
|||||||
? _value.limit
|
? _value.limit
|
||||||
: limit // ignore: cast_nullable_to_non_nullable
|
: limit // ignore: cast_nullable_to_non_nullable
|
||||||
as int?,
|
as int?,
|
||||||
search: freezed == search
|
|
||||||
? _value.search
|
|
||||||
: search // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String?,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,7 +150,7 @@ class __$$GetByStatusImplCopyWithImpl<$Res>
|
|||||||
|
|
||||||
class _$GetByStatusImpl implements _GetByStatus {
|
class _$GetByStatusImpl implements _GetByStatus {
|
||||||
const _$GetByStatusImpl(this.status,
|
const _$GetByStatusImpl(this.status,
|
||||||
{required this.dateFrom, required this.dateTo, this.limit, this.search});
|
{required this.dateFrom, required this.dateTo, this.limit});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final String status;
|
final String status;
|
||||||
@ -173,12 +160,10 @@ class _$GetByStatusImpl implements _GetByStatus {
|
|||||||
final DateTime dateTo;
|
final DateTime dateTo;
|
||||||
@override
|
@override
|
||||||
final int? limit;
|
final int? limit;
|
||||||
@override
|
|
||||||
final String? search;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OrderLoaderEvent.getByStatus(status: $status, dateFrom: $dateFrom, dateTo: $dateTo, limit: $limit, search: $search)';
|
return 'OrderLoaderEvent.getByStatus(status: $status, dateFrom: $dateFrom, dateTo: $dateTo, limit: $limit)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -190,13 +175,11 @@ class _$GetByStatusImpl implements _GetByStatus {
|
|||||||
(identical(other.dateFrom, dateFrom) ||
|
(identical(other.dateFrom, dateFrom) ||
|
||||||
other.dateFrom == dateFrom) &&
|
other.dateFrom == dateFrom) &&
|
||||||
(identical(other.dateTo, dateTo) || other.dateTo == dateTo) &&
|
(identical(other.dateTo, dateTo) || other.dateTo == dateTo) &&
|
||||||
(identical(other.limit, limit) || other.limit == limit) &&
|
(identical(other.limit, limit) || other.limit == limit));
|
||||||
(identical(other.search, search) || other.search == search));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode =>
|
int get hashCode => Object.hash(runtimeType, status, dateFrom, dateTo, limit);
|
||||||
Object.hash(runtimeType, status, dateFrom, dateTo, limit, search);
|
|
||||||
|
|
||||||
/// Create a copy of OrderLoaderEvent
|
/// Create a copy of OrderLoaderEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@ -209,48 +192,45 @@ class _$GetByStatusImpl implements _GetByStatus {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
required TResult Function(
|
||||||
int? limit, String? search)
|
String status, DateTime dateFrom, DateTime dateTo, int? limit)
|
||||||
getByStatus,
|
getByStatus,
|
||||||
required TResult Function(String id) getById,
|
required TResult Function(String id) getById,
|
||||||
required TResult Function(
|
required TResult Function(String status, DateTime dateFrom, DateTime dateTo)
|
||||||
String status, DateTime dateFrom, DateTime dateTo, String? search)
|
|
||||||
loadMore,
|
loadMore,
|
||||||
required TResult Function(String status) refresh,
|
required TResult Function(String status) refresh,
|
||||||
}) {
|
}) {
|
||||||
return getByStatus(status, dateFrom, dateTo, limit, search);
|
return getByStatus(status, dateFrom, dateTo, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(String status, DateTime dateFrom, DateTime dateTo,
|
TResult? Function(
|
||||||
int? limit, String? search)?
|
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult? Function(String id)? getById,
|
TResult? Function(String id)? getById,
|
||||||
TResult? Function(
|
TResult? Function(String status, DateTime dateFrom, DateTime dateTo)?
|
||||||
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult? Function(String status)? refresh,
|
TResult? Function(String status)? refresh,
|
||||||
}) {
|
}) {
|
||||||
return getByStatus?.call(status, dateFrom, dateTo, limit, search);
|
return getByStatus?.call(status, dateFrom, dateTo, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
TResult Function(
|
||||||
int? limit, String? search)?
|
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult Function(String id)? getById,
|
TResult Function(String id)? getById,
|
||||||
TResult Function(
|
TResult Function(String status, DateTime dateFrom, DateTime dateTo)?
|
||||||
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult Function(String status)? refresh,
|
TResult Function(String status)? refresh,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (getByStatus != null) {
|
if (getByStatus != null) {
|
||||||
return getByStatus(status, dateFrom, dateTo, limit, search);
|
return getByStatus(status, dateFrom, dateTo, limit);
|
||||||
}
|
}
|
||||||
return orElse();
|
return orElse();
|
||||||
}
|
}
|
||||||
@ -297,14 +277,12 @@ abstract class _GetByStatus implements OrderLoaderEvent {
|
|||||||
const factory _GetByStatus(final String status,
|
const factory _GetByStatus(final String status,
|
||||||
{required final DateTime dateFrom,
|
{required final DateTime dateFrom,
|
||||||
required final DateTime dateTo,
|
required final DateTime dateTo,
|
||||||
final int? limit,
|
final int? limit}) = _$GetByStatusImpl;
|
||||||
final String? search}) = _$GetByStatusImpl;
|
|
||||||
|
|
||||||
String get status;
|
String get status;
|
||||||
DateTime get dateFrom;
|
DateTime get dateFrom;
|
||||||
DateTime get dateTo;
|
DateTime get dateTo;
|
||||||
int? get limit;
|
int? get limit;
|
||||||
String? get search;
|
|
||||||
|
|
||||||
/// Create a copy of OrderLoaderEvent
|
/// Create a copy of OrderLoaderEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@ -381,12 +359,11 @@ class _$GetByIdImpl implements _GetById {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
required TResult Function(
|
||||||
int? limit, String? search)
|
String status, DateTime dateFrom, DateTime dateTo, int? limit)
|
||||||
getByStatus,
|
getByStatus,
|
||||||
required TResult Function(String id) getById,
|
required TResult Function(String id) getById,
|
||||||
required TResult Function(
|
required TResult Function(String status, DateTime dateFrom, DateTime dateTo)
|
||||||
String status, DateTime dateFrom, DateTime dateTo, String? search)
|
|
||||||
loadMore,
|
loadMore,
|
||||||
required TResult Function(String status) refresh,
|
required TResult Function(String status) refresh,
|
||||||
}) {
|
}) {
|
||||||
@ -396,12 +373,11 @@ class _$GetByIdImpl implements _GetById {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(String status, DateTime dateFrom, DateTime dateTo,
|
TResult? Function(
|
||||||
int? limit, String? search)?
|
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult? Function(String id)? getById,
|
TResult? Function(String id)? getById,
|
||||||
TResult? Function(
|
TResult? Function(String status, DateTime dateFrom, DateTime dateTo)?
|
||||||
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult? Function(String status)? refresh,
|
TResult? Function(String status)? refresh,
|
||||||
}) {
|
}) {
|
||||||
@ -411,12 +387,11 @@ class _$GetByIdImpl implements _GetById {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
TResult Function(
|
||||||
int? limit, String? search)?
|
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult Function(String id)? getById,
|
TResult Function(String id)? getById,
|
||||||
TResult Function(
|
TResult Function(String status, DateTime dateFrom, DateTime dateTo)?
|
||||||
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult Function(String status)? refresh,
|
TResult Function(String status)? refresh,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
@ -483,8 +458,7 @@ abstract class _$$LoadMoreImplCopyWith<$Res> {
|
|||||||
_$LoadMoreImpl value, $Res Function(_$LoadMoreImpl) then) =
|
_$LoadMoreImpl value, $Res Function(_$LoadMoreImpl) then) =
|
||||||
__$$LoadMoreImplCopyWithImpl<$Res>;
|
__$$LoadMoreImplCopyWithImpl<$Res>;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call(
|
$Res call({String status, DateTime dateFrom, DateTime dateTo});
|
||||||
{String status, DateTime dateFrom, DateTime dateTo, String? search});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -503,7 +477,6 @@ class __$$LoadMoreImplCopyWithImpl<$Res>
|
|||||||
Object? status = null,
|
Object? status = null,
|
||||||
Object? dateFrom = null,
|
Object? dateFrom = null,
|
||||||
Object? dateTo = null,
|
Object? dateTo = null,
|
||||||
Object? search = freezed,
|
|
||||||
}) {
|
}) {
|
||||||
return _then(_$LoadMoreImpl(
|
return _then(_$LoadMoreImpl(
|
||||||
null == status
|
null == status
|
||||||
@ -518,10 +491,6 @@ class __$$LoadMoreImplCopyWithImpl<$Res>
|
|||||||
? _value.dateTo
|
? _value.dateTo
|
||||||
: dateTo // ignore: cast_nullable_to_non_nullable
|
: dateTo // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime,
|
as DateTime,
|
||||||
search: freezed == search
|
|
||||||
? _value.search
|
|
||||||
: search // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String?,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -530,7 +499,7 @@ class __$$LoadMoreImplCopyWithImpl<$Res>
|
|||||||
|
|
||||||
class _$LoadMoreImpl implements _LoadMore {
|
class _$LoadMoreImpl implements _LoadMore {
|
||||||
const _$LoadMoreImpl(this.status,
|
const _$LoadMoreImpl(this.status,
|
||||||
{required this.dateFrom, required this.dateTo, this.search});
|
{required this.dateFrom, required this.dateTo});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final String status;
|
final String status;
|
||||||
@ -538,12 +507,10 @@ class _$LoadMoreImpl implements _LoadMore {
|
|||||||
final DateTime dateFrom;
|
final DateTime dateFrom;
|
||||||
@override
|
@override
|
||||||
final DateTime dateTo;
|
final DateTime dateTo;
|
||||||
@override
|
|
||||||
final String? search;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OrderLoaderEvent.loadMore(status: $status, dateFrom: $dateFrom, dateTo: $dateTo, search: $search)';
|
return 'OrderLoaderEvent.loadMore(status: $status, dateFrom: $dateFrom, dateTo: $dateTo)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -554,13 +521,11 @@ class _$LoadMoreImpl implements _LoadMore {
|
|||||||
(identical(other.status, status) || other.status == status) &&
|
(identical(other.status, status) || other.status == status) &&
|
||||||
(identical(other.dateFrom, dateFrom) ||
|
(identical(other.dateFrom, dateFrom) ||
|
||||||
other.dateFrom == dateFrom) &&
|
other.dateFrom == dateFrom) &&
|
||||||
(identical(other.dateTo, dateTo) || other.dateTo == dateTo) &&
|
(identical(other.dateTo, dateTo) || other.dateTo == dateTo));
|
||||||
(identical(other.search, search) || other.search == search));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode =>
|
int get hashCode => Object.hash(runtimeType, status, dateFrom, dateTo);
|
||||||
Object.hash(runtimeType, status, dateFrom, dateTo, search);
|
|
||||||
|
|
||||||
/// Create a copy of OrderLoaderEvent
|
/// Create a copy of OrderLoaderEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@ -573,48 +538,45 @@ class _$LoadMoreImpl implements _LoadMore {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
required TResult Function(
|
||||||
int? limit, String? search)
|
String status, DateTime dateFrom, DateTime dateTo, int? limit)
|
||||||
getByStatus,
|
getByStatus,
|
||||||
required TResult Function(String id) getById,
|
required TResult Function(String id) getById,
|
||||||
required TResult Function(
|
required TResult Function(String status, DateTime dateFrom, DateTime dateTo)
|
||||||
String status, DateTime dateFrom, DateTime dateTo, String? search)
|
|
||||||
loadMore,
|
loadMore,
|
||||||
required TResult Function(String status) refresh,
|
required TResult Function(String status) refresh,
|
||||||
}) {
|
}) {
|
||||||
return loadMore(status, dateFrom, dateTo, search);
|
return loadMore(status, dateFrom, dateTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(String status, DateTime dateFrom, DateTime dateTo,
|
TResult? Function(
|
||||||
int? limit, String? search)?
|
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult? Function(String id)? getById,
|
TResult? Function(String id)? getById,
|
||||||
TResult? Function(
|
TResult? Function(String status, DateTime dateFrom, DateTime dateTo)?
|
||||||
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult? Function(String status)? refresh,
|
TResult? Function(String status)? refresh,
|
||||||
}) {
|
}) {
|
||||||
return loadMore?.call(status, dateFrom, dateTo, search);
|
return loadMore?.call(status, dateFrom, dateTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
TResult Function(
|
||||||
int? limit, String? search)?
|
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult Function(String id)? getById,
|
TResult Function(String id)? getById,
|
||||||
TResult Function(
|
TResult Function(String status, DateTime dateFrom, DateTime dateTo)?
|
||||||
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult Function(String status)? refresh,
|
TResult Function(String status)? refresh,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (loadMore != null) {
|
if (loadMore != null) {
|
||||||
return loadMore(status, dateFrom, dateTo, search);
|
return loadMore(status, dateFrom, dateTo);
|
||||||
}
|
}
|
||||||
return orElse();
|
return orElse();
|
||||||
}
|
}
|
||||||
@ -660,13 +622,11 @@ class _$LoadMoreImpl implements _LoadMore {
|
|||||||
abstract class _LoadMore implements OrderLoaderEvent {
|
abstract class _LoadMore implements OrderLoaderEvent {
|
||||||
const factory _LoadMore(final String status,
|
const factory _LoadMore(final String status,
|
||||||
{required final DateTime dateFrom,
|
{required final DateTime dateFrom,
|
||||||
required final DateTime dateTo,
|
required final DateTime dateTo}) = _$LoadMoreImpl;
|
||||||
final String? search}) = _$LoadMoreImpl;
|
|
||||||
|
|
||||||
String get status;
|
String get status;
|
||||||
DateTime get dateFrom;
|
DateTime get dateFrom;
|
||||||
DateTime get dateTo;
|
DateTime get dateTo;
|
||||||
String? get search;
|
|
||||||
|
|
||||||
/// Create a copy of OrderLoaderEvent
|
/// Create a copy of OrderLoaderEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@ -743,12 +703,11 @@ class _$RefreshImpl implements _Refresh {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
required TResult Function(
|
||||||
int? limit, String? search)
|
String status, DateTime dateFrom, DateTime dateTo, int? limit)
|
||||||
getByStatus,
|
getByStatus,
|
||||||
required TResult Function(String id) getById,
|
required TResult Function(String id) getById,
|
||||||
required TResult Function(
|
required TResult Function(String status, DateTime dateFrom, DateTime dateTo)
|
||||||
String status, DateTime dateFrom, DateTime dateTo, String? search)
|
|
||||||
loadMore,
|
loadMore,
|
||||||
required TResult Function(String status) refresh,
|
required TResult Function(String status) refresh,
|
||||||
}) {
|
}) {
|
||||||
@ -758,12 +717,11 @@ class _$RefreshImpl implements _Refresh {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(String status, DateTime dateFrom, DateTime dateTo,
|
TResult? Function(
|
||||||
int? limit, String? search)?
|
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult? Function(String id)? getById,
|
TResult? Function(String id)? getById,
|
||||||
TResult? Function(
|
TResult? Function(String status, DateTime dateFrom, DateTime dateTo)?
|
||||||
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult? Function(String status)? refresh,
|
TResult? Function(String status)? refresh,
|
||||||
}) {
|
}) {
|
||||||
@ -773,12 +731,11 @@ class _$RefreshImpl implements _Refresh {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
TResult Function(
|
||||||
int? limit, String? search)?
|
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult Function(String id)? getById,
|
TResult Function(String id)? getById,
|
||||||
TResult Function(
|
TResult Function(String status, DateTime dateFrom, DateTime dateTo)?
|
||||||
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult Function(String status)? refresh,
|
TResult Function(String status)? refresh,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
|
|||||||
@ -2,19 +2,15 @@ part of 'order_loader_bloc.dart';
|
|||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class OrderLoaderEvent with _$OrderLoaderEvent {
|
class OrderLoaderEvent with _$OrderLoaderEvent {
|
||||||
const factory OrderLoaderEvent.getByStatus(
|
const factory OrderLoaderEvent.getByStatus(String status,
|
||||||
String status, {
|
{required DateTime dateFrom,
|
||||||
required DateTime dateFrom,
|
required DateTime dateTo,
|
||||||
required DateTime dateTo,
|
int? limit}) = _GetByStatus;
|
||||||
int? limit,
|
|
||||||
String? search,
|
|
||||||
}) = _GetByStatus;
|
|
||||||
const factory OrderLoaderEvent.getById(String id) = _GetById;
|
const factory OrderLoaderEvent.getById(String id) = _GetById;
|
||||||
const factory OrderLoaderEvent.loadMore(
|
const factory OrderLoaderEvent.loadMore(
|
||||||
String status, {
|
String status, {
|
||||||
required DateTime dateFrom,
|
required DateTime dateFrom,
|
||||||
required DateTime dateTo,
|
required DateTime dateTo,
|
||||||
String? search,
|
|
||||||
}) = _LoadMore;
|
}) = _LoadMore;
|
||||||
const factory OrderLoaderEvent.refresh(String status) = _Refresh;
|
const factory OrderLoaderEvent.refresh(String status) = _Refresh;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,6 +45,18 @@ class _SalesPageState extends State<SalesPage> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Order> _filterOrders(List<Order> orders) {
|
||||||
|
if (searchQuery.isEmpty) {
|
||||||
|
return orders;
|
||||||
|
}
|
||||||
|
|
||||||
|
return orders.where((order) {
|
||||||
|
final customerName = order.orderNumber?.toLowerCase() ?? "";
|
||||||
|
final queryLower = searchQuery.toLowerCase();
|
||||||
|
return customerName.contains(queryLower);
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
@ -59,13 +71,8 @@ class _SalesPageState extends State<SalesPage> {
|
|||||||
if (notification is ScrollEndNotification &&
|
if (notification is ScrollEndNotification &&
|
||||||
scrollController.position.extentAfter == 0) {
|
scrollController.position.extentAfter == 0) {
|
||||||
context.read<OrderLoaderBloc>().add(
|
context.read<OrderLoaderBloc>().add(
|
||||||
OrderLoaderEvent.loadMore(
|
OrderLoaderEvent.loadMore(widget.status,
|
||||||
widget.status,
|
dateFrom: startDate, dateTo: endDate));
|
||||||
dateFrom: startDate,
|
|
||||||
dateTo: endDate,
|
|
||||||
search: searchQuery,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,16 +92,6 @@ class _SalesPageState extends State<SalesPage> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
searchQuery = value;
|
searchQuery = value;
|
||||||
});
|
});
|
||||||
Future.delayed(const Duration(milliseconds: 800), () {
|
|
||||||
context.read<OrderLoaderBloc>().add(
|
|
||||||
OrderLoaderEvent.getByStatus(
|
|
||||||
widget.status,
|
|
||||||
dateFrom: startDate,
|
|
||||||
dateTo: endDate,
|
|
||||||
search: searchQuery,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
onDateRangeChanged: (start, end) {
|
onDateRangeChanged: (start, end) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -128,7 +125,8 @@ class _SalesPageState extends State<SalesPage> {
|
|||||||
),
|
),
|
||||||
loaded: (orders, totalOrder, hasReachedMax,
|
loaded: (orders, totalOrder, hasReachedMax,
|
||||||
currentPage, isLoadingMore) {
|
currentPage, isLoadingMore) {
|
||||||
if (orders.isEmpty) {
|
final filtered = _filterOrders(orders);
|
||||||
|
if (filtered.isEmpty) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
"Belum ada transaksi saat ini. ",
|
"Belum ada transaksi saat ini. ",
|
||||||
@ -140,17 +138,17 @@ class _SalesPageState extends State<SalesPage> {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
itemCount: orders.length,
|
itemCount: filtered.length,
|
||||||
controller: scrollController,
|
controller: scrollController,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
orderDetail = orders[index];
|
orderDetail = filtered[index];
|
||||||
});
|
});
|
||||||
context.read<OrderFormBloc>().add(
|
context.read<OrderFormBloc>().add(
|
||||||
OrderFormEvent.started(
|
OrderFormEvent.started(
|
||||||
orders[index]));
|
filtered[index]));
|
||||||
},
|
},
|
||||||
child: SalesCard(
|
child: SalesCard(
|
||||||
order: orders[index],
|
order: orders[index],
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user