dev #1
@ -272,18 +272,26 @@ 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();
|
||||||
final response = await dio.get(
|
|
||||||
'${Variables.baseUrl}/api/v1/orders',
|
Map<String, dynamic> params = {
|
||||||
queryParameters: {
|
|
||||||
'page': page,
|
'page': page,
|
||||||
'limit': limit,
|
'limit': limit,
|
||||||
'status': status,
|
'status': status,
|
||||||
'date_from': DateFormat('dd-MM-yyyy').format(dateFrom),
|
'date_from': DateFormat('dd-MM-yyyy').format(dateFrom),
|
||||||
'date_to': DateFormat('dd-MM-yyyy').format(dateTo),
|
'date_to': DateFormat('dd-MM-yyyy').format(dateTo),
|
||||||
},
|
};
|
||||||
|
|
||||||
|
if (search != null && search.isNotEmpty) {
|
||||||
|
params['search'] = search;
|
||||||
|
}
|
||||||
|
|
||||||
|
final response = await dio.get(
|
||||||
|
'${Variables.baseUrl}/api/v1/orders',
|
||||||
|
queryParameters: params,
|
||||||
options: Options(
|
options: Options(
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer ${authData.token}',
|
'Authorization': 'Bearer ${authData.token}',
|
||||||
|
|||||||
@ -60,6 +60,7 @@ 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(
|
||||||
@ -108,6 +109,7 @@ 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,33 +18,36 @@ final _privateConstructorUsedError = UnsupportedError(
|
|||||||
mixin _$OrderLoaderEvent {
|
mixin _$OrderLoaderEvent {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(
|
required TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)
|
int? limit, String? search)
|
||||||
getByStatus,
|
getByStatus,
|
||||||
required TResult Function(String id) getById,
|
required TResult Function(String id) getById,
|
||||||
required TResult Function(String status, DateTime dateFrom, DateTime dateTo)
|
required TResult Function(
|
||||||
|
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(
|
TResult? Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult? Function(String id)? getById,
|
TResult? Function(String id)? getById,
|
||||||
TResult? Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult? Function(
|
||||||
|
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(
|
TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult Function(String id)? getById,
|
TResult Function(String id)? getById,
|
||||||
TResult Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult Function(
|
||||||
|
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(),
|
||||||
@ -104,7 +107,12 @@ abstract class _$$GetByStatusImplCopyWith<$Res> {
|
|||||||
_$GetByStatusImpl value, $Res Function(_$GetByStatusImpl) then) =
|
_$GetByStatusImpl value, $Res Function(_$GetByStatusImpl) then) =
|
||||||
__$$GetByStatusImplCopyWithImpl<$Res>;
|
__$$GetByStatusImplCopyWithImpl<$Res>;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({String status, DateTime dateFrom, DateTime dateTo, int? limit});
|
$Res call(
|
||||||
|
{String status,
|
||||||
|
DateTime dateFrom,
|
||||||
|
DateTime dateTo,
|
||||||
|
int? limit,
|
||||||
|
String? search});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -124,6 +132,7 @@ 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
|
||||||
@ -142,6 +151,10 @@ 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?,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,7 +163,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});
|
{required this.dateFrom, required this.dateTo, this.limit, this.search});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final String status;
|
final String status;
|
||||||
@ -160,10 +173,12 @@ 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)';
|
return 'OrderLoaderEvent.getByStatus(status: $status, dateFrom: $dateFrom, dateTo: $dateTo, limit: $limit, search: $search)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -175,11 +190,13 @@ 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 => Object.hash(runtimeType, status, dateFrom, dateTo, limit);
|
int get hashCode =>
|
||||||
|
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.
|
||||||
@ -192,45 +209,48 @@ class _$GetByStatusImpl implements _GetByStatus {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(
|
required TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)
|
int? limit, String? search)
|
||||||
getByStatus,
|
getByStatus,
|
||||||
required TResult Function(String id) getById,
|
required TResult Function(String id) getById,
|
||||||
required TResult Function(String status, DateTime dateFrom, DateTime dateTo)
|
required TResult Function(
|
||||||
|
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);
|
return getByStatus(status, dateFrom, dateTo, limit, search);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(
|
TResult? Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult? Function(String id)? getById,
|
TResult? Function(String id)? getById,
|
||||||
TResult? Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult? Function(
|
||||||
|
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);
|
return getByStatus?.call(status, dateFrom, dateTo, limit, search);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(
|
TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult Function(String id)? getById,
|
TResult Function(String id)? getById,
|
||||||
TResult Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult Function(
|
||||||
|
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);
|
return getByStatus(status, dateFrom, dateTo, limit, search);
|
||||||
}
|
}
|
||||||
return orElse();
|
return orElse();
|
||||||
}
|
}
|
||||||
@ -277,12 +297,14 @@ 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}) = _$GetByStatusImpl;
|
final int? limit,
|
||||||
|
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.
|
||||||
@ -359,11 +381,12 @@ class _$GetByIdImpl implements _GetById {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(
|
required TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)
|
int? limit, String? search)
|
||||||
getByStatus,
|
getByStatus,
|
||||||
required TResult Function(String id) getById,
|
required TResult Function(String id) getById,
|
||||||
required TResult Function(String status, DateTime dateFrom, DateTime dateTo)
|
required TResult Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)
|
||||||
loadMore,
|
loadMore,
|
||||||
required TResult Function(String status) refresh,
|
required TResult Function(String status) refresh,
|
||||||
}) {
|
}) {
|
||||||
@ -373,11 +396,12 @@ class _$GetByIdImpl implements _GetById {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(
|
TResult? Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult? Function(String id)? getById,
|
TResult? Function(String id)? getById,
|
||||||
TResult? Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult? Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult? Function(String status)? refresh,
|
TResult? Function(String status)? refresh,
|
||||||
}) {
|
}) {
|
||||||
@ -387,11 +411,12 @@ class _$GetByIdImpl implements _GetById {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(
|
TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult Function(String id)? getById,
|
TResult Function(String id)? getById,
|
||||||
TResult Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult Function(
|
||||||
|
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(),
|
||||||
@ -458,7 +483,8 @@ abstract class _$$LoadMoreImplCopyWith<$Res> {
|
|||||||
_$LoadMoreImpl value, $Res Function(_$LoadMoreImpl) then) =
|
_$LoadMoreImpl value, $Res Function(_$LoadMoreImpl) then) =
|
||||||
__$$LoadMoreImplCopyWithImpl<$Res>;
|
__$$LoadMoreImplCopyWithImpl<$Res>;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({String status, DateTime dateFrom, DateTime dateTo});
|
$Res call(
|
||||||
|
{String status, DateTime dateFrom, DateTime dateTo, String? search});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -477,6 +503,7 @@ 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
|
||||||
@ -491,6 +518,10 @@ 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?,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -499,7 +530,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});
|
{required this.dateFrom, required this.dateTo, this.search});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final String status;
|
final String status;
|
||||||
@ -507,10 +538,12 @@ 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)';
|
return 'OrderLoaderEvent.loadMore(status: $status, dateFrom: $dateFrom, dateTo: $dateTo, search: $search)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -521,11 +554,13 @@ 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 => Object.hash(runtimeType, status, dateFrom, dateTo);
|
int get hashCode =>
|
||||||
|
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.
|
||||||
@ -538,45 +573,48 @@ class _$LoadMoreImpl implements _LoadMore {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(
|
required TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)
|
int? limit, String? search)
|
||||||
getByStatus,
|
getByStatus,
|
||||||
required TResult Function(String id) getById,
|
required TResult Function(String id) getById,
|
||||||
required TResult Function(String status, DateTime dateFrom, DateTime dateTo)
|
required TResult Function(
|
||||||
|
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);
|
return loadMore(status, dateFrom, dateTo, search);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(
|
TResult? Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult? Function(String id)? getById,
|
TResult? Function(String id)? getById,
|
||||||
TResult? Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult? Function(
|
||||||
|
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);
|
return loadMore?.call(status, dateFrom, dateTo, search);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(
|
TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult Function(String id)? getById,
|
TResult Function(String id)? getById,
|
||||||
TResult Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult Function(
|
||||||
|
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);
|
return loadMore(status, dateFrom, dateTo, search);
|
||||||
}
|
}
|
||||||
return orElse();
|
return orElse();
|
||||||
}
|
}
|
||||||
@ -622,11 +660,13 @@ 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}) = _$LoadMoreImpl;
|
required final DateTime dateTo,
|
||||||
|
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.
|
||||||
@ -703,11 +743,12 @@ class _$RefreshImpl implements _Refresh {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(
|
required TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)
|
int? limit, String? search)
|
||||||
getByStatus,
|
getByStatus,
|
||||||
required TResult Function(String id) getById,
|
required TResult Function(String id) getById,
|
||||||
required TResult Function(String status, DateTime dateFrom, DateTime dateTo)
|
required TResult Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)
|
||||||
loadMore,
|
loadMore,
|
||||||
required TResult Function(String status) refresh,
|
required TResult Function(String status) refresh,
|
||||||
}) {
|
}) {
|
||||||
@ -717,11 +758,12 @@ class _$RefreshImpl implements _Refresh {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(
|
TResult? Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult? Function(String id)? getById,
|
TResult? Function(String id)? getById,
|
||||||
TResult? Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult? Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult? Function(String status)? refresh,
|
TResult? Function(String status)? refresh,
|
||||||
}) {
|
}) {
|
||||||
@ -731,11 +773,12 @@ class _$RefreshImpl implements _Refresh {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(
|
TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult Function(String id)? getById,
|
TResult Function(String id)? getById,
|
||||||
TResult Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult Function(
|
||||||
|
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,15 +2,19 @@ part of 'order_loader_bloc.dart';
|
|||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class OrderLoaderEvent with _$OrderLoaderEvent {
|
class OrderLoaderEvent with _$OrderLoaderEvent {
|
||||||
const factory OrderLoaderEvent.getByStatus(String status,
|
const factory OrderLoaderEvent.getByStatus(
|
||||||
{required DateTime dateFrom,
|
String status, {
|
||||||
|
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,18 +45,6 @@ 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(
|
||||||
@ -71,8 +59,13 @@ 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(widget.status,
|
OrderLoaderEvent.loadMore(
|
||||||
dateFrom: startDate, dateTo: endDate));
|
widget.status,
|
||||||
|
dateFrom: startDate,
|
||||||
|
dateTo: endDate,
|
||||||
|
search: searchQuery,
|
||||||
|
),
|
||||||
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,6 +85,16 @@ 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(() {
|
||||||
@ -125,8 +128,7 @@ class _SalesPageState extends State<SalesPage> {
|
|||||||
),
|
),
|
||||||
loaded: (orders, totalOrder, hasReachedMax,
|
loaded: (orders, totalOrder, hasReachedMax,
|
||||||
currentPage, isLoadingMore) {
|
currentPage, isLoadingMore) {
|
||||||
final filtered = _filterOrders(orders);
|
if (orders.isEmpty) {
|
||||||
if (filtered.isEmpty) {
|
|
||||||
return Center(
|
return Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
"Belum ada transaksi saat ini. ",
|
"Belum ada transaksi saat ini. ",
|
||||||
@ -138,17 +140,17 @@ class _SalesPageState extends State<SalesPage> {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
itemCount: filtered.length,
|
itemCount: orders.length,
|
||||||
controller: scrollController,
|
controller: scrollController,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
orderDetail = filtered[index];
|
orderDetail = orders[index];
|
||||||
});
|
});
|
||||||
context.read<OrderFormBloc>().add(
|
context.read<OrderFormBloc>().add(
|
||||||
OrderFormEvent.started(
|
OrderFormEvent.started(
|
||||||
filtered[index]));
|
orders[index]));
|
||||||
},
|
},
|
||||||
child: SalesCard(
|
child: SalesCard(
|
||||||
order: orders[index],
|
order: orders[index],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user