Compare commits
No commits in common. "8fec9c8cd0b70543904aafd6817da0316ba1c0ca" and "5c683eda8d49800bf79b5ccd622434ec7c564548" have entirely different histories.
8fec9c8cd0
...
5c683eda8d
@ -166,9 +166,6 @@ class CheckoutFormBloc extends Bloc<CheckoutFormEvent, CheckoutFormState> {
|
||||
|
||||
emit(currentState.copyWith(items: items, isLoading: false));
|
||||
},
|
||||
updateOrderType: (e) async {
|
||||
emit(state.copyWith(orderType: e.orderType));
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,7 +24,6 @@ mixin _$CheckoutFormEvent {
|
||||
required TResult Function(Product product, ProductVariant? variant)
|
||||
removeItem,
|
||||
required TResult Function(Product product, String notes) updateItemNotes,
|
||||
required TResult Function(OrderType orderType) updateOrderType,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
@ -32,7 +31,6 @@ mixin _$CheckoutFormEvent {
|
||||
TResult? Function(Product product, ProductVariant? variant)? addItem,
|
||||
TResult? Function(Product product, ProductVariant? variant)? removeItem,
|
||||
TResult? Function(Product product, String notes)? updateItemNotes,
|
||||
TResult? Function(OrderType orderType)? updateOrderType,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
@ -40,7 +38,6 @@ mixin _$CheckoutFormEvent {
|
||||
TResult Function(Product product, ProductVariant? variant)? addItem,
|
||||
TResult Function(Product product, ProductVariant? variant)? removeItem,
|
||||
TResult Function(Product product, String notes)? updateItemNotes,
|
||||
TResult Function(OrderType orderType)? updateOrderType,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
@ -49,7 +46,6 @@ mixin _$CheckoutFormEvent {
|
||||
required TResult Function(_AddItem value) addItem,
|
||||
required TResult Function(_RemoveItem value) removeItem,
|
||||
required TResult Function(_UpdateItemNotes value) updateItemNotes,
|
||||
required TResult Function(_UpdateOrderType value) updateOrderType,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
@ -57,7 +53,6 @@ mixin _$CheckoutFormEvent {
|
||||
TResult? Function(_AddItem value)? addItem,
|
||||
TResult? Function(_RemoveItem value)? removeItem,
|
||||
TResult? Function(_UpdateItemNotes value)? updateItemNotes,
|
||||
TResult? Function(_UpdateOrderType value)? updateOrderType,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
@ -65,7 +60,6 @@ mixin _$CheckoutFormEvent {
|
||||
TResult Function(_AddItem value)? addItem,
|
||||
TResult Function(_RemoveItem value)? removeItem,
|
||||
TResult Function(_UpdateItemNotes value)? updateItemNotes,
|
||||
TResult Function(_UpdateOrderType value)? updateOrderType,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}
|
||||
@ -173,7 +167,6 @@ class _$StartedImpl implements _Started {
|
||||
required TResult Function(Product product, ProductVariant? variant)
|
||||
removeItem,
|
||||
required TResult Function(Product product, String notes) updateItemNotes,
|
||||
required TResult Function(OrderType orderType) updateOrderType,
|
||||
}) {
|
||||
return started(items);
|
||||
}
|
||||
@ -185,7 +178,6 @@ class _$StartedImpl implements _Started {
|
||||
TResult? Function(Product product, ProductVariant? variant)? addItem,
|
||||
TResult? Function(Product product, ProductVariant? variant)? removeItem,
|
||||
TResult? Function(Product product, String notes)? updateItemNotes,
|
||||
TResult? Function(OrderType orderType)? updateOrderType,
|
||||
}) {
|
||||
return started?.call(items);
|
||||
}
|
||||
@ -197,7 +189,6 @@ class _$StartedImpl implements _Started {
|
||||
TResult Function(Product product, ProductVariant? variant)? addItem,
|
||||
TResult Function(Product product, ProductVariant? variant)? removeItem,
|
||||
TResult Function(Product product, String notes)? updateItemNotes,
|
||||
TResult Function(OrderType orderType)? updateOrderType,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (started != null) {
|
||||
@ -213,7 +204,6 @@ class _$StartedImpl implements _Started {
|
||||
required TResult Function(_AddItem value) addItem,
|
||||
required TResult Function(_RemoveItem value) removeItem,
|
||||
required TResult Function(_UpdateItemNotes value) updateItemNotes,
|
||||
required TResult Function(_UpdateOrderType value) updateOrderType,
|
||||
}) {
|
||||
return started(this);
|
||||
}
|
||||
@ -225,7 +215,6 @@ class _$StartedImpl implements _Started {
|
||||
TResult? Function(_AddItem value)? addItem,
|
||||
TResult? Function(_RemoveItem value)? removeItem,
|
||||
TResult? Function(_UpdateItemNotes value)? updateItemNotes,
|
||||
TResult? Function(_UpdateOrderType value)? updateOrderType,
|
||||
}) {
|
||||
return started?.call(this);
|
||||
}
|
||||
@ -237,7 +226,6 @@ class _$StartedImpl implements _Started {
|
||||
TResult Function(_AddItem value)? addItem,
|
||||
TResult Function(_RemoveItem value)? removeItem,
|
||||
TResult Function(_UpdateItemNotes value)? updateItemNotes,
|
||||
TResult Function(_UpdateOrderType value)? updateOrderType,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (started != null) {
|
||||
@ -368,7 +356,6 @@ class _$AddItemImpl implements _AddItem {
|
||||
required TResult Function(Product product, ProductVariant? variant)
|
||||
removeItem,
|
||||
required TResult Function(Product product, String notes) updateItemNotes,
|
||||
required TResult Function(OrderType orderType) updateOrderType,
|
||||
}) {
|
||||
return addItem(product, variant);
|
||||
}
|
||||
@ -380,7 +367,6 @@ class _$AddItemImpl implements _AddItem {
|
||||
TResult? Function(Product product, ProductVariant? variant)? addItem,
|
||||
TResult? Function(Product product, ProductVariant? variant)? removeItem,
|
||||
TResult? Function(Product product, String notes)? updateItemNotes,
|
||||
TResult? Function(OrderType orderType)? updateOrderType,
|
||||
}) {
|
||||
return addItem?.call(product, variant);
|
||||
}
|
||||
@ -392,7 +378,6 @@ class _$AddItemImpl implements _AddItem {
|
||||
TResult Function(Product product, ProductVariant? variant)? addItem,
|
||||
TResult Function(Product product, ProductVariant? variant)? removeItem,
|
||||
TResult Function(Product product, String notes)? updateItemNotes,
|
||||
TResult Function(OrderType orderType)? updateOrderType,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (addItem != null) {
|
||||
@ -408,7 +393,6 @@ class _$AddItemImpl implements _AddItem {
|
||||
required TResult Function(_AddItem value) addItem,
|
||||
required TResult Function(_RemoveItem value) removeItem,
|
||||
required TResult Function(_UpdateItemNotes value) updateItemNotes,
|
||||
required TResult Function(_UpdateOrderType value) updateOrderType,
|
||||
}) {
|
||||
return addItem(this);
|
||||
}
|
||||
@ -420,7 +404,6 @@ class _$AddItemImpl implements _AddItem {
|
||||
TResult? Function(_AddItem value)? addItem,
|
||||
TResult? Function(_RemoveItem value)? removeItem,
|
||||
TResult? Function(_UpdateItemNotes value)? updateItemNotes,
|
||||
TResult? Function(_UpdateOrderType value)? updateOrderType,
|
||||
}) {
|
||||
return addItem?.call(this);
|
||||
}
|
||||
@ -432,7 +415,6 @@ class _$AddItemImpl implements _AddItem {
|
||||
TResult Function(_AddItem value)? addItem,
|
||||
TResult Function(_RemoveItem value)? removeItem,
|
||||
TResult Function(_UpdateItemNotes value)? updateItemNotes,
|
||||
TResult Function(_UpdateOrderType value)? updateOrderType,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (addItem != null) {
|
||||
@ -565,7 +547,6 @@ class _$RemoveItemImpl implements _RemoveItem {
|
||||
required TResult Function(Product product, ProductVariant? variant)
|
||||
removeItem,
|
||||
required TResult Function(Product product, String notes) updateItemNotes,
|
||||
required TResult Function(OrderType orderType) updateOrderType,
|
||||
}) {
|
||||
return removeItem(product, variant);
|
||||
}
|
||||
@ -577,7 +558,6 @@ class _$RemoveItemImpl implements _RemoveItem {
|
||||
TResult? Function(Product product, ProductVariant? variant)? addItem,
|
||||
TResult? Function(Product product, ProductVariant? variant)? removeItem,
|
||||
TResult? Function(Product product, String notes)? updateItemNotes,
|
||||
TResult? Function(OrderType orderType)? updateOrderType,
|
||||
}) {
|
||||
return removeItem?.call(product, variant);
|
||||
}
|
||||
@ -589,7 +569,6 @@ class _$RemoveItemImpl implements _RemoveItem {
|
||||
TResult Function(Product product, ProductVariant? variant)? addItem,
|
||||
TResult Function(Product product, ProductVariant? variant)? removeItem,
|
||||
TResult Function(Product product, String notes)? updateItemNotes,
|
||||
TResult Function(OrderType orderType)? updateOrderType,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (removeItem != null) {
|
||||
@ -605,7 +584,6 @@ class _$RemoveItemImpl implements _RemoveItem {
|
||||
required TResult Function(_AddItem value) addItem,
|
||||
required TResult Function(_RemoveItem value) removeItem,
|
||||
required TResult Function(_UpdateItemNotes value) updateItemNotes,
|
||||
required TResult Function(_UpdateOrderType value) updateOrderType,
|
||||
}) {
|
||||
return removeItem(this);
|
||||
}
|
||||
@ -617,7 +595,6 @@ class _$RemoveItemImpl implements _RemoveItem {
|
||||
TResult? Function(_AddItem value)? addItem,
|
||||
TResult? Function(_RemoveItem value)? removeItem,
|
||||
TResult? Function(_UpdateItemNotes value)? updateItemNotes,
|
||||
TResult? Function(_UpdateOrderType value)? updateOrderType,
|
||||
}) {
|
||||
return removeItem?.call(this);
|
||||
}
|
||||
@ -629,7 +606,6 @@ class _$RemoveItemImpl implements _RemoveItem {
|
||||
TResult Function(_AddItem value)? addItem,
|
||||
TResult Function(_RemoveItem value)? removeItem,
|
||||
TResult Function(_UpdateItemNotes value)? updateItemNotes,
|
||||
TResult Function(_UpdateOrderType value)? updateOrderType,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (removeItem != null) {
|
||||
@ -752,7 +728,6 @@ class _$UpdateItemNotesImpl implements _UpdateItemNotes {
|
||||
required TResult Function(Product product, ProductVariant? variant)
|
||||
removeItem,
|
||||
required TResult Function(Product product, String notes) updateItemNotes,
|
||||
required TResult Function(OrderType orderType) updateOrderType,
|
||||
}) {
|
||||
return updateItemNotes(product, notes);
|
||||
}
|
||||
@ -764,7 +739,6 @@ class _$UpdateItemNotesImpl implements _UpdateItemNotes {
|
||||
TResult? Function(Product product, ProductVariant? variant)? addItem,
|
||||
TResult? Function(Product product, ProductVariant? variant)? removeItem,
|
||||
TResult? Function(Product product, String notes)? updateItemNotes,
|
||||
TResult? Function(OrderType orderType)? updateOrderType,
|
||||
}) {
|
||||
return updateItemNotes?.call(product, notes);
|
||||
}
|
||||
@ -776,7 +750,6 @@ class _$UpdateItemNotesImpl implements _UpdateItemNotes {
|
||||
TResult Function(Product product, ProductVariant? variant)? addItem,
|
||||
TResult Function(Product product, ProductVariant? variant)? removeItem,
|
||||
TResult Function(Product product, String notes)? updateItemNotes,
|
||||
TResult Function(OrderType orderType)? updateOrderType,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (updateItemNotes != null) {
|
||||
@ -792,7 +765,6 @@ class _$UpdateItemNotesImpl implements _UpdateItemNotes {
|
||||
required TResult Function(_AddItem value) addItem,
|
||||
required TResult Function(_RemoveItem value) removeItem,
|
||||
required TResult Function(_UpdateItemNotes value) updateItemNotes,
|
||||
required TResult Function(_UpdateOrderType value) updateOrderType,
|
||||
}) {
|
||||
return updateItemNotes(this);
|
||||
}
|
||||
@ -804,7 +776,6 @@ class _$UpdateItemNotesImpl implements _UpdateItemNotes {
|
||||
TResult? Function(_AddItem value)? addItem,
|
||||
TResult? Function(_RemoveItem value)? removeItem,
|
||||
TResult? Function(_UpdateItemNotes value)? updateItemNotes,
|
||||
TResult? Function(_UpdateOrderType value)? updateOrderType,
|
||||
}) {
|
||||
return updateItemNotes?.call(this);
|
||||
}
|
||||
@ -816,7 +787,6 @@ class _$UpdateItemNotesImpl implements _UpdateItemNotes {
|
||||
TResult Function(_AddItem value)? addItem,
|
||||
TResult Function(_RemoveItem value)? removeItem,
|
||||
TResult Function(_UpdateItemNotes value)? updateItemNotes,
|
||||
TResult Function(_UpdateOrderType value)? updateOrderType,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (updateItemNotes != null) {
|
||||
@ -840,172 +810,6 @@ abstract class _UpdateItemNotes implements CheckoutFormEvent {
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$UpdateOrderTypeImplCopyWith<$Res> {
|
||||
factory _$$UpdateOrderTypeImplCopyWith(
|
||||
_$UpdateOrderTypeImpl value,
|
||||
$Res Function(_$UpdateOrderTypeImpl) then,
|
||||
) = __$$UpdateOrderTypeImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({OrderType orderType});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$UpdateOrderTypeImplCopyWithImpl<$Res>
|
||||
extends _$CheckoutFormEventCopyWithImpl<$Res, _$UpdateOrderTypeImpl>
|
||||
implements _$$UpdateOrderTypeImplCopyWith<$Res> {
|
||||
__$$UpdateOrderTypeImplCopyWithImpl(
|
||||
_$UpdateOrderTypeImpl _value,
|
||||
$Res Function(_$UpdateOrderTypeImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of CheckoutFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? orderType = null}) {
|
||||
return _then(
|
||||
_$UpdateOrderTypeImpl(
|
||||
null == orderType
|
||||
? _value.orderType
|
||||
: orderType // ignore: cast_nullable_to_non_nullable
|
||||
as OrderType,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$UpdateOrderTypeImpl implements _UpdateOrderType {
|
||||
const _$UpdateOrderTypeImpl(this.orderType);
|
||||
|
||||
@override
|
||||
final OrderType orderType;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CheckoutFormEvent.updateOrderType(orderType: $orderType)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$UpdateOrderTypeImpl &&
|
||||
(identical(other.orderType, orderType) ||
|
||||
other.orderType == orderType));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, orderType);
|
||||
|
||||
/// Create a copy of CheckoutFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$UpdateOrderTypeImplCopyWith<_$UpdateOrderTypeImpl> get copyWith =>
|
||||
__$$UpdateOrderTypeImplCopyWithImpl<_$UpdateOrderTypeImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(List<ProductQuantity> items) started,
|
||||
required TResult Function(Product product, ProductVariant? variant) addItem,
|
||||
required TResult Function(Product product, ProductVariant? variant)
|
||||
removeItem,
|
||||
required TResult Function(Product product, String notes) updateItemNotes,
|
||||
required TResult Function(OrderType orderType) updateOrderType,
|
||||
}) {
|
||||
return updateOrderType(orderType);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(List<ProductQuantity> items)? started,
|
||||
TResult? Function(Product product, ProductVariant? variant)? addItem,
|
||||
TResult? Function(Product product, ProductVariant? variant)? removeItem,
|
||||
TResult? Function(Product product, String notes)? updateItemNotes,
|
||||
TResult? Function(OrderType orderType)? updateOrderType,
|
||||
}) {
|
||||
return updateOrderType?.call(orderType);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(List<ProductQuantity> items)? started,
|
||||
TResult Function(Product product, ProductVariant? variant)? addItem,
|
||||
TResult Function(Product product, ProductVariant? variant)? removeItem,
|
||||
TResult Function(Product product, String notes)? updateItemNotes,
|
||||
TResult Function(OrderType orderType)? updateOrderType,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (updateOrderType != null) {
|
||||
return updateOrderType(orderType);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Started value) started,
|
||||
required TResult Function(_AddItem value) addItem,
|
||||
required TResult Function(_RemoveItem value) removeItem,
|
||||
required TResult Function(_UpdateItemNotes value) updateItemNotes,
|
||||
required TResult Function(_UpdateOrderType value) updateOrderType,
|
||||
}) {
|
||||
return updateOrderType(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Started value)? started,
|
||||
TResult? Function(_AddItem value)? addItem,
|
||||
TResult? Function(_RemoveItem value)? removeItem,
|
||||
TResult? Function(_UpdateItemNotes value)? updateItemNotes,
|
||||
TResult? Function(_UpdateOrderType value)? updateOrderType,
|
||||
}) {
|
||||
return updateOrderType?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Started value)? started,
|
||||
TResult Function(_AddItem value)? addItem,
|
||||
TResult Function(_RemoveItem value)? removeItem,
|
||||
TResult Function(_UpdateItemNotes value)? updateItemNotes,
|
||||
TResult Function(_UpdateOrderType value)? updateOrderType,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (updateOrderType != null) {
|
||||
return updateOrderType(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _UpdateOrderType implements CheckoutFormEvent {
|
||||
const factory _UpdateOrderType(final OrderType orderType) =
|
||||
_$UpdateOrderTypeImpl;
|
||||
|
||||
OrderType get orderType;
|
||||
|
||||
/// Create a copy of CheckoutFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$UpdateOrderTypeImplCopyWith<_$UpdateOrderTypeImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$CheckoutFormState {
|
||||
List<ProductQuantity> get items => throw _privateConstructorUsedError;
|
||||
|
||||
@ -19,7 +19,4 @@ class CheckoutFormEvent with _$CheckoutFormEvent {
|
||||
Product product,
|
||||
String notes,
|
||||
) = _UpdateItemNotes;
|
||||
|
||||
const factory CheckoutFormEvent.updateOrderType(OrderType orderType) =
|
||||
_UpdateOrderType;
|
||||
}
|
||||
|
||||
@ -1,82 +0,0 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import '../../../domain/customer/customer.dart';
|
||||
|
||||
part 'customer_loader_event.dart';
|
||||
part 'customer_loader_state.dart';
|
||||
part 'customer_loader_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class CustomerLoaderBloc
|
||||
extends Bloc<CustomerLoaderEvent, CustomerLoaderState> {
|
||||
final ICustomerRepository _repository;
|
||||
CustomerLoaderBloc(this._repository) : super(CustomerLoaderState.initial()) {
|
||||
on<CustomerLoaderEvent>(_onCustomerLoaderEvent);
|
||||
}
|
||||
|
||||
Future<void> _onCustomerLoaderEvent(
|
||||
CustomerLoaderEvent event,
|
||||
Emitter<CustomerLoaderState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
fetched: (e) async {
|
||||
var newState = state;
|
||||
|
||||
if (e.isRefresh) {
|
||||
newState = newState.copyWith(isFetching: true);
|
||||
emit(newState);
|
||||
}
|
||||
|
||||
newState = await _mapFetchedToState(newState, isRefresh: e.isRefresh);
|
||||
|
||||
emit(newState);
|
||||
},
|
||||
setSelectedCustomer: (e) async {
|
||||
emit(state.copyWith(selectedCustomer: e.customer));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<CustomerLoaderState> _mapFetchedToState(
|
||||
CustomerLoaderState state, {
|
||||
bool isRefresh = false,
|
||||
}) async {
|
||||
state = state.copyWith(isFetching: false);
|
||||
|
||||
if (state.hasReachedMax && state.customers.isNotEmpty && !isRefresh) {
|
||||
return state;
|
||||
}
|
||||
|
||||
if (isRefresh) {
|
||||
state = state.copyWith(
|
||||
page: 1,
|
||||
failureOrOption: none(),
|
||||
hasReachedMax: false,
|
||||
customers: [],
|
||||
);
|
||||
}
|
||||
|
||||
final failureOrCustomer = await _repository.getCustomer(page: state.page);
|
||||
|
||||
state = failureOrCustomer.fold(
|
||||
(f) {
|
||||
if (state.customers.isNotEmpty) {
|
||||
return state.copyWith(hasReachedMax: true);
|
||||
}
|
||||
return state.copyWith(failureOrOption: optionOf(f));
|
||||
},
|
||||
(customers) {
|
||||
return state.copyWith(
|
||||
customers: List.from(state.customers)..addAll(customers.customers),
|
||||
failureOrOption: none(),
|
||||
page: state.page + 1,
|
||||
hasReachedMax: customers.customers.length < 10,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@ -1,668 +0,0 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'customer_loader_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
||||
);
|
||||
|
||||
/// @nodoc
|
||||
mixin _$CustomerLoaderEvent {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(Customer customer) setSelectedCustomer,
|
||||
required TResult Function(bool isRefresh) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Customer customer)? setSelectedCustomer,
|
||||
TResult? Function(bool isRefresh)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Customer customer)? setSelectedCustomer,
|
||||
TResult Function(bool isRefresh)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_SetSelectedCustomer value) setSelectedCustomer,
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetSelectedCustomer value)? setSelectedCustomer,
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetSelectedCustomer value)? setSelectedCustomer,
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $CustomerLoaderEventCopyWith<$Res> {
|
||||
factory $CustomerLoaderEventCopyWith(
|
||||
CustomerLoaderEvent value,
|
||||
$Res Function(CustomerLoaderEvent) then,
|
||||
) = _$CustomerLoaderEventCopyWithImpl<$Res, CustomerLoaderEvent>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$CustomerLoaderEventCopyWithImpl<$Res, $Val extends CustomerLoaderEvent>
|
||||
implements $CustomerLoaderEventCopyWith<$Res> {
|
||||
_$CustomerLoaderEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of CustomerLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SetSelectedCustomerImplCopyWith<$Res> {
|
||||
factory _$$SetSelectedCustomerImplCopyWith(
|
||||
_$SetSelectedCustomerImpl value,
|
||||
$Res Function(_$SetSelectedCustomerImpl) then,
|
||||
) = __$$SetSelectedCustomerImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({Customer customer});
|
||||
|
||||
$CustomerCopyWith<$Res> get customer;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SetSelectedCustomerImplCopyWithImpl<$Res>
|
||||
extends _$CustomerLoaderEventCopyWithImpl<$Res, _$SetSelectedCustomerImpl>
|
||||
implements _$$SetSelectedCustomerImplCopyWith<$Res> {
|
||||
__$$SetSelectedCustomerImplCopyWithImpl(
|
||||
_$SetSelectedCustomerImpl _value,
|
||||
$Res Function(_$SetSelectedCustomerImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of CustomerLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? customer = null}) {
|
||||
return _then(
|
||||
_$SetSelectedCustomerImpl(
|
||||
null == customer
|
||||
? _value.customer
|
||||
: customer // ignore: cast_nullable_to_non_nullable
|
||||
as Customer,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of CustomerLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$CustomerCopyWith<$Res> get customer {
|
||||
return $CustomerCopyWith<$Res>(_value.customer, (value) {
|
||||
return _then(_value.copyWith(customer: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SetSelectedCustomerImpl implements _SetSelectedCustomer {
|
||||
const _$SetSelectedCustomerImpl(this.customer);
|
||||
|
||||
@override
|
||||
final Customer customer;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CustomerLoaderEvent.setSelectedCustomer(customer: $customer)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$SetSelectedCustomerImpl &&
|
||||
(identical(other.customer, customer) ||
|
||||
other.customer == customer));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, customer);
|
||||
|
||||
/// Create a copy of CustomerLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$SetSelectedCustomerImplCopyWith<_$SetSelectedCustomerImpl> get copyWith =>
|
||||
__$$SetSelectedCustomerImplCopyWithImpl<_$SetSelectedCustomerImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(Customer customer) setSelectedCustomer,
|
||||
required TResult Function(bool isRefresh) fetched,
|
||||
}) {
|
||||
return setSelectedCustomer(customer);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Customer customer)? setSelectedCustomer,
|
||||
TResult? Function(bool isRefresh)? fetched,
|
||||
}) {
|
||||
return setSelectedCustomer?.call(customer);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Customer customer)? setSelectedCustomer,
|
||||
TResult Function(bool isRefresh)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (setSelectedCustomer != null) {
|
||||
return setSelectedCustomer(customer);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_SetSelectedCustomer value) setSelectedCustomer,
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) {
|
||||
return setSelectedCustomer(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetSelectedCustomer value)? setSelectedCustomer,
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) {
|
||||
return setSelectedCustomer?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetSelectedCustomer value)? setSelectedCustomer,
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (setSelectedCustomer != null) {
|
||||
return setSelectedCustomer(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _SetSelectedCustomer implements CustomerLoaderEvent {
|
||||
const factory _SetSelectedCustomer(final Customer customer) =
|
||||
_$SetSelectedCustomerImpl;
|
||||
|
||||
Customer get customer;
|
||||
|
||||
/// Create a copy of CustomerLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$SetSelectedCustomerImplCopyWith<_$SetSelectedCustomerImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$FetchedImplCopyWith<$Res> {
|
||||
factory _$$FetchedImplCopyWith(
|
||||
_$FetchedImpl value,
|
||||
$Res Function(_$FetchedImpl) then,
|
||||
) = __$$FetchedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({bool isRefresh});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$FetchedImplCopyWithImpl<$Res>
|
||||
extends _$CustomerLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
||||
implements _$$FetchedImplCopyWith<$Res> {
|
||||
__$$FetchedImplCopyWithImpl(
|
||||
_$FetchedImpl _value,
|
||||
$Res Function(_$FetchedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of CustomerLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? isRefresh = null}) {
|
||||
return _then(
|
||||
_$FetchedImpl(
|
||||
isRefresh: null == isRefresh
|
||||
? _value.isRefresh
|
||||
: isRefresh // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$FetchedImpl implements _Fetched {
|
||||
const _$FetchedImpl({this.isRefresh = false});
|
||||
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isRefresh;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CustomerLoaderEvent.fetched(isRefresh: $isRefresh)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$FetchedImpl &&
|
||||
(identical(other.isRefresh, isRefresh) ||
|
||||
other.isRefresh == isRefresh));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, isRefresh);
|
||||
|
||||
/// Create a copy of CustomerLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
__$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(Customer customer) setSelectedCustomer,
|
||||
required TResult Function(bool isRefresh) fetched,
|
||||
}) {
|
||||
return fetched(isRefresh);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Customer customer)? setSelectedCustomer,
|
||||
TResult? Function(bool isRefresh)? fetched,
|
||||
}) {
|
||||
return fetched?.call(isRefresh);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Customer customer)? setSelectedCustomer,
|
||||
TResult Function(bool isRefresh)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(isRefresh);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_SetSelectedCustomer value) setSelectedCustomer,
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) {
|
||||
return fetched(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetSelectedCustomer value)? setSelectedCustomer,
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) {
|
||||
return fetched?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetSelectedCustomer value)? setSelectedCustomer,
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Fetched implements CustomerLoaderEvent {
|
||||
const factory _Fetched({final bool isRefresh}) = _$FetchedImpl;
|
||||
|
||||
bool get isRefresh;
|
||||
|
||||
/// Create a copy of CustomerLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$CustomerLoaderState {
|
||||
List<Customer> get customers => throw _privateConstructorUsedError;
|
||||
Option<CustomerFailure> get failureOrOption =>
|
||||
throw _privateConstructorUsedError;
|
||||
Customer? get selectedCustomer => throw _privateConstructorUsedError;
|
||||
bool get isFetching => throw _privateConstructorUsedError;
|
||||
bool get hasReachedMax => throw _privateConstructorUsedError;
|
||||
int get page => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of CustomerLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$CustomerLoaderStateCopyWith<CustomerLoaderState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $CustomerLoaderStateCopyWith<$Res> {
|
||||
factory $CustomerLoaderStateCopyWith(
|
||||
CustomerLoaderState value,
|
||||
$Res Function(CustomerLoaderState) then,
|
||||
) = _$CustomerLoaderStateCopyWithImpl<$Res, CustomerLoaderState>;
|
||||
@useResult
|
||||
$Res call({
|
||||
List<Customer> customers,
|
||||
Option<CustomerFailure> failureOrOption,
|
||||
Customer? selectedCustomer,
|
||||
bool isFetching,
|
||||
bool hasReachedMax,
|
||||
int page,
|
||||
});
|
||||
|
||||
$CustomerCopyWith<$Res>? get selectedCustomer;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$CustomerLoaderStateCopyWithImpl<$Res, $Val extends CustomerLoaderState>
|
||||
implements $CustomerLoaderStateCopyWith<$Res> {
|
||||
_$CustomerLoaderStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of CustomerLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? customers = null,
|
||||
Object? failureOrOption = null,
|
||||
Object? selectedCustomer = freezed,
|
||||
Object? isFetching = null,
|
||||
Object? hasReachedMax = null,
|
||||
Object? page = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
customers: null == customers
|
||||
? _value.customers
|
||||
: customers // ignore: cast_nullable_to_non_nullable
|
||||
as List<Customer>,
|
||||
failureOrOption: null == failureOrOption
|
||||
? _value.failureOrOption
|
||||
: failureOrOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<CustomerFailure>,
|
||||
selectedCustomer: freezed == selectedCustomer
|
||||
? _value.selectedCustomer
|
||||
: selectedCustomer // ignore: cast_nullable_to_non_nullable
|
||||
as Customer?,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
hasReachedMax: null == hasReachedMax
|
||||
? _value.hasReachedMax
|
||||
: hasReachedMax // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
page: null == page
|
||||
? _value.page
|
||||
: page // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of CustomerLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$CustomerCopyWith<$Res>? get selectedCustomer {
|
||||
if (_value.selectedCustomer == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $CustomerCopyWith<$Res>(_value.selectedCustomer!, (value) {
|
||||
return _then(_value.copyWith(selectedCustomer: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CustomerLoaderStateImplCopyWith<$Res>
|
||||
implements $CustomerLoaderStateCopyWith<$Res> {
|
||||
factory _$$CustomerLoaderStateImplCopyWith(
|
||||
_$CustomerLoaderStateImpl value,
|
||||
$Res Function(_$CustomerLoaderStateImpl) then,
|
||||
) = __$$CustomerLoaderStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
List<Customer> customers,
|
||||
Option<CustomerFailure> failureOrOption,
|
||||
Customer? selectedCustomer,
|
||||
bool isFetching,
|
||||
bool hasReachedMax,
|
||||
int page,
|
||||
});
|
||||
|
||||
@override
|
||||
$CustomerCopyWith<$Res>? get selectedCustomer;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CustomerLoaderStateImplCopyWithImpl<$Res>
|
||||
extends _$CustomerLoaderStateCopyWithImpl<$Res, _$CustomerLoaderStateImpl>
|
||||
implements _$$CustomerLoaderStateImplCopyWith<$Res> {
|
||||
__$$CustomerLoaderStateImplCopyWithImpl(
|
||||
_$CustomerLoaderStateImpl _value,
|
||||
$Res Function(_$CustomerLoaderStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of CustomerLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? customers = null,
|
||||
Object? failureOrOption = null,
|
||||
Object? selectedCustomer = freezed,
|
||||
Object? isFetching = null,
|
||||
Object? hasReachedMax = null,
|
||||
Object? page = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$CustomerLoaderStateImpl(
|
||||
customers: null == customers
|
||||
? _value._customers
|
||||
: customers // ignore: cast_nullable_to_non_nullable
|
||||
as List<Customer>,
|
||||
failureOrOption: null == failureOrOption
|
||||
? _value.failureOrOption
|
||||
: failureOrOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<CustomerFailure>,
|
||||
selectedCustomer: freezed == selectedCustomer
|
||||
? _value.selectedCustomer
|
||||
: selectedCustomer // ignore: cast_nullable_to_non_nullable
|
||||
as Customer?,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
hasReachedMax: null == hasReachedMax
|
||||
? _value.hasReachedMax
|
||||
: hasReachedMax // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
page: null == page
|
||||
? _value.page
|
||||
: page // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$CustomerLoaderStateImpl implements _CustomerLoaderState {
|
||||
_$CustomerLoaderStateImpl({
|
||||
required final List<Customer> customers,
|
||||
required this.failureOrOption,
|
||||
this.selectedCustomer,
|
||||
this.isFetching = false,
|
||||
this.hasReachedMax = false,
|
||||
this.page = 1,
|
||||
}) : _customers = customers;
|
||||
|
||||
final List<Customer> _customers;
|
||||
@override
|
||||
List<Customer> get customers {
|
||||
if (_customers is EqualUnmodifiableListView) return _customers;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_customers);
|
||||
}
|
||||
|
||||
@override
|
||||
final Option<CustomerFailure> failureOrOption;
|
||||
@override
|
||||
final Customer? selectedCustomer;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isFetching;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool hasReachedMax;
|
||||
@override
|
||||
@JsonKey()
|
||||
final int page;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CustomerLoaderState(customers: $customers, failureOrOption: $failureOrOption, selectedCustomer: $selectedCustomer, isFetching: $isFetching, hasReachedMax: $hasReachedMax, page: $page)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CustomerLoaderStateImpl &&
|
||||
const DeepCollectionEquality().equals(
|
||||
other._customers,
|
||||
_customers,
|
||||
) &&
|
||||
(identical(other.failureOrOption, failureOrOption) ||
|
||||
other.failureOrOption == failureOrOption) &&
|
||||
(identical(other.selectedCustomer, selectedCustomer) ||
|
||||
other.selectedCustomer == selectedCustomer) &&
|
||||
(identical(other.isFetching, isFetching) ||
|
||||
other.isFetching == isFetching) &&
|
||||
(identical(other.hasReachedMax, hasReachedMax) ||
|
||||
other.hasReachedMax == hasReachedMax) &&
|
||||
(identical(other.page, page) || other.page == page));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
const DeepCollectionEquality().hash(_customers),
|
||||
failureOrOption,
|
||||
selectedCustomer,
|
||||
isFetching,
|
||||
hasReachedMax,
|
||||
page,
|
||||
);
|
||||
|
||||
/// Create a copy of CustomerLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$CustomerLoaderStateImplCopyWith<_$CustomerLoaderStateImpl> get copyWith =>
|
||||
__$$CustomerLoaderStateImplCopyWithImpl<_$CustomerLoaderStateImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
}
|
||||
|
||||
abstract class _CustomerLoaderState implements CustomerLoaderState {
|
||||
factory _CustomerLoaderState({
|
||||
required final List<Customer> customers,
|
||||
required final Option<CustomerFailure> failureOrOption,
|
||||
final Customer? selectedCustomer,
|
||||
final bool isFetching,
|
||||
final bool hasReachedMax,
|
||||
final int page,
|
||||
}) = _$CustomerLoaderStateImpl;
|
||||
|
||||
@override
|
||||
List<Customer> get customers;
|
||||
@override
|
||||
Option<CustomerFailure> get failureOrOption;
|
||||
@override
|
||||
Customer? get selectedCustomer;
|
||||
@override
|
||||
bool get isFetching;
|
||||
@override
|
||||
bool get hasReachedMax;
|
||||
@override
|
||||
int get page;
|
||||
|
||||
/// Create a copy of CustomerLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$CustomerLoaderStateImplCopyWith<_$CustomerLoaderStateImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
part of 'customer_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class CustomerLoaderEvent with _$CustomerLoaderEvent {
|
||||
const factory CustomerLoaderEvent.setSelectedCustomer(Customer customer) =
|
||||
_SetSelectedCustomer;
|
||||
const factory CustomerLoaderEvent.fetched({@Default(false) bool isRefresh}) =
|
||||
_Fetched;
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
part of 'customer_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class CustomerLoaderState with _$CustomerLoaderState {
|
||||
factory CustomerLoaderState({
|
||||
required List<Customer> customers,
|
||||
required Option<CustomerFailure> failureOrOption,
|
||||
Customer? selectedCustomer,
|
||||
@Default(false) bool isFetching,
|
||||
@Default(false) bool hasReachedMax,
|
||||
@Default(1) int page,
|
||||
}) = _CustomerLoaderState;
|
||||
|
||||
factory CustomerLoaderState.initial() =>
|
||||
CustomerLoaderState(customers: [], failureOrOption: none());
|
||||
}
|
||||
@ -1,16 +1,6 @@
|
||||
part of 'extension.dart';
|
||||
|
||||
extension StringX on String {
|
||||
String toTitleCase() {
|
||||
if (isEmpty) return '';
|
||||
return split(' ')
|
||||
.map((word) {
|
||||
if (word.isEmpty) return '';
|
||||
return word[0].toUpperCase() + word.substring(1).toLowerCase();
|
||||
})
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
TableStatusType toTableStatusType() {
|
||||
switch (this) {
|
||||
case 'available':
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum OrderType {
|
||||
dineIn('DINE IN'),
|
||||
takeAway('TAKE AWAY'),
|
||||
@ -15,17 +13,4 @@ enum OrderType {
|
||||
orElse: () => OrderType.dineIn,
|
||||
);
|
||||
}
|
||||
|
||||
IconData get icon {
|
||||
switch (this) {
|
||||
case OrderType.dineIn:
|
||||
return Icons.dinner_dining_outlined;
|
||||
case OrderType.takeAway:
|
||||
return Icons.takeout_dining_outlined;
|
||||
case OrderType.delivery:
|
||||
return Icons.delivery_dining_outlined;
|
||||
case OrderType.freeTable:
|
||||
return Icons.table_bar_outlined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,5 +4,4 @@ class ApiPath {
|
||||
static const String categories = '/api/v1/categories';
|
||||
static const String products = '/api/v1/products';
|
||||
static const String tables = '/api/v1/tables';
|
||||
static const String customers = '/api/v1/customers';
|
||||
}
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import '../../common/api/api_failure.dart';
|
||||
|
||||
part 'customer.freezed.dart';
|
||||
|
||||
part 'entities/customer_entity.dart';
|
||||
part 'failures/customer_failure.dart';
|
||||
part 'repositories/i_customer_repository.dart';
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,51 +0,0 @@
|
||||
part of '../customer.dart';
|
||||
|
||||
@freezed
|
||||
class ListCustomer with _$ListCustomer {
|
||||
const factory ListCustomer({
|
||||
required List<Customer> customers,
|
||||
required int totalCount,
|
||||
required int page,
|
||||
required int limit,
|
||||
required int totalPages,
|
||||
}) = _ListCustomer;
|
||||
|
||||
factory ListCustomer.empty() => ListCustomer(
|
||||
customers: const [],
|
||||
totalCount: 0,
|
||||
page: 0,
|
||||
limit: 0,
|
||||
totalPages: 0,
|
||||
);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Customer with _$Customer {
|
||||
const factory Customer({
|
||||
required String id,
|
||||
required String organizationId,
|
||||
required String name,
|
||||
required String email,
|
||||
required String phone,
|
||||
required String address,
|
||||
required bool isDefault,
|
||||
required bool isActive,
|
||||
required Map<String, dynamic> metadata,
|
||||
required DateTime createdAt,
|
||||
required DateTime updatedAt,
|
||||
}) = _Customer;
|
||||
|
||||
factory Customer.empty() => Customer(
|
||||
id: '',
|
||||
organizationId: '',
|
||||
name: '',
|
||||
email: '',
|
||||
phone: '',
|
||||
address: '',
|
||||
isDefault: false,
|
||||
isActive: false,
|
||||
metadata: const {},
|
||||
createdAt: DateTime(1970),
|
||||
updatedAt: DateTime(1970),
|
||||
);
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
part of '../customer.dart';
|
||||
|
||||
@freezed
|
||||
sealed class CustomerFailure with _$CustomerFailure {
|
||||
const factory CustomerFailure.serverError(ApiFailure failure) = _ServerError;
|
||||
const factory CustomerFailure.unexpectedError() = _UnexpectedError;
|
||||
const factory CustomerFailure.empty() = _Empty;
|
||||
const factory CustomerFailure.localStorageError(String erroMessage) =
|
||||
_LocalStorageError;
|
||||
const factory CustomerFailure.dynamicErrorMessage(String erroMessage) =
|
||||
_DynamicErrorMessage;
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
part of '../customer.dart';
|
||||
|
||||
abstract class ICustomerRepository {
|
||||
Future<Either<CustomerFailure, ListCustomer>> getCustomer({
|
||||
int page = 1,
|
||||
int limit = 10,
|
||||
});
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import '../../domain/customer/customer.dart';
|
||||
|
||||
part 'customer_dtos.freezed.dart';
|
||||
part 'customer_dtos.g.dart';
|
||||
|
||||
part 'dtos/customer_dto.dart';
|
||||
@ -1,754 +0,0 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'customer_dtos.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
||||
);
|
||||
|
||||
ListCustomerDto _$ListCustomerDtoFromJson(Map<String, dynamic> json) {
|
||||
return _ListCustomerDto.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ListCustomerDto {
|
||||
@JsonKey(name: "data")
|
||||
List<CustomerDto>? get customers => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "total_count")
|
||||
int? get totalCount => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "page")
|
||||
int? get page => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "limit")
|
||||
int? get limit => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "total_pages")
|
||||
int? get totalPages => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this ListCustomerDto to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of ListCustomerDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$ListCustomerDtoCopyWith<ListCustomerDto> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ListCustomerDtoCopyWith<$Res> {
|
||||
factory $ListCustomerDtoCopyWith(
|
||||
ListCustomerDto value,
|
||||
$Res Function(ListCustomerDto) then,
|
||||
) = _$ListCustomerDtoCopyWithImpl<$Res, ListCustomerDto>;
|
||||
@useResult
|
||||
$Res call({
|
||||
@JsonKey(name: "data") List<CustomerDto>? customers,
|
||||
@JsonKey(name: "total_count") int? totalCount,
|
||||
@JsonKey(name: "page") int? page,
|
||||
@JsonKey(name: "limit") int? limit,
|
||||
@JsonKey(name: "total_pages") int? totalPages,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ListCustomerDtoCopyWithImpl<$Res, $Val extends ListCustomerDto>
|
||||
implements $ListCustomerDtoCopyWith<$Res> {
|
||||
_$ListCustomerDtoCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of ListCustomerDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? customers = freezed,
|
||||
Object? totalCount = freezed,
|
||||
Object? page = freezed,
|
||||
Object? limit = freezed,
|
||||
Object? totalPages = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
customers: freezed == customers
|
||||
? _value.customers
|
||||
: customers // ignore: cast_nullable_to_non_nullable
|
||||
as List<CustomerDto>?,
|
||||
totalCount: freezed == totalCount
|
||||
? _value.totalCount
|
||||
: totalCount // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
page: freezed == page
|
||||
? _value.page
|
||||
: page // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
limit: freezed == limit
|
||||
? _value.limit
|
||||
: limit // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
totalPages: freezed == totalPages
|
||||
? _value.totalPages
|
||||
: totalPages // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ListCustomerDtoImplCopyWith<$Res>
|
||||
implements $ListCustomerDtoCopyWith<$Res> {
|
||||
factory _$$ListCustomerDtoImplCopyWith(
|
||||
_$ListCustomerDtoImpl value,
|
||||
$Res Function(_$ListCustomerDtoImpl) then,
|
||||
) = __$$ListCustomerDtoImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
@JsonKey(name: "data") List<CustomerDto>? customers,
|
||||
@JsonKey(name: "total_count") int? totalCount,
|
||||
@JsonKey(name: "page") int? page,
|
||||
@JsonKey(name: "limit") int? limit,
|
||||
@JsonKey(name: "total_pages") int? totalPages,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ListCustomerDtoImplCopyWithImpl<$Res>
|
||||
extends _$ListCustomerDtoCopyWithImpl<$Res, _$ListCustomerDtoImpl>
|
||||
implements _$$ListCustomerDtoImplCopyWith<$Res> {
|
||||
__$$ListCustomerDtoImplCopyWithImpl(
|
||||
_$ListCustomerDtoImpl _value,
|
||||
$Res Function(_$ListCustomerDtoImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of ListCustomerDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? customers = freezed,
|
||||
Object? totalCount = freezed,
|
||||
Object? page = freezed,
|
||||
Object? limit = freezed,
|
||||
Object? totalPages = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_$ListCustomerDtoImpl(
|
||||
customers: freezed == customers
|
||||
? _value._customers
|
||||
: customers // ignore: cast_nullable_to_non_nullable
|
||||
as List<CustomerDto>?,
|
||||
totalCount: freezed == totalCount
|
||||
? _value.totalCount
|
||||
: totalCount // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
page: freezed == page
|
||||
? _value.page
|
||||
: page // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
limit: freezed == limit
|
||||
? _value.limit
|
||||
: limit // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
totalPages: freezed == totalPages
|
||||
? _value.totalPages
|
||||
: totalPages // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$ListCustomerDtoImpl extends _ListCustomerDto
|
||||
with DiagnosticableTreeMixin {
|
||||
const _$ListCustomerDtoImpl({
|
||||
@JsonKey(name: "data") final List<CustomerDto>? customers,
|
||||
@JsonKey(name: "total_count") this.totalCount,
|
||||
@JsonKey(name: "page") this.page,
|
||||
@JsonKey(name: "limit") this.limit,
|
||||
@JsonKey(name: "total_pages") this.totalPages,
|
||||
}) : _customers = customers,
|
||||
super._();
|
||||
|
||||
factory _$ListCustomerDtoImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$ListCustomerDtoImplFromJson(json);
|
||||
|
||||
final List<CustomerDto>? _customers;
|
||||
@override
|
||||
@JsonKey(name: "data")
|
||||
List<CustomerDto>? get customers {
|
||||
final value = _customers;
|
||||
if (value == null) return null;
|
||||
if (_customers is EqualUnmodifiableListView) return _customers;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(value);
|
||||
}
|
||||
|
||||
@override
|
||||
@JsonKey(name: "total_count")
|
||||
final int? totalCount;
|
||||
@override
|
||||
@JsonKey(name: "page")
|
||||
final int? page;
|
||||
@override
|
||||
@JsonKey(name: "limit")
|
||||
final int? limit;
|
||||
@override
|
||||
@JsonKey(name: "total_pages")
|
||||
final int? totalPages;
|
||||
|
||||
@override
|
||||
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
|
||||
return 'ListCustomerDto(customers: $customers, totalCount: $totalCount, page: $page, limit: $limit, totalPages: $totalPages)';
|
||||
}
|
||||
|
||||
@override
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
properties
|
||||
..add(DiagnosticsProperty('type', 'ListCustomerDto'))
|
||||
..add(DiagnosticsProperty('customers', customers))
|
||||
..add(DiagnosticsProperty('totalCount', totalCount))
|
||||
..add(DiagnosticsProperty('page', page))
|
||||
..add(DiagnosticsProperty('limit', limit))
|
||||
..add(DiagnosticsProperty('totalPages', totalPages));
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ListCustomerDtoImpl &&
|
||||
const DeepCollectionEquality().equals(
|
||||
other._customers,
|
||||
_customers,
|
||||
) &&
|
||||
(identical(other.totalCount, totalCount) ||
|
||||
other.totalCount == totalCount) &&
|
||||
(identical(other.page, page) || other.page == page) &&
|
||||
(identical(other.limit, limit) || other.limit == limit) &&
|
||||
(identical(other.totalPages, totalPages) ||
|
||||
other.totalPages == totalPages));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
const DeepCollectionEquality().hash(_customers),
|
||||
totalCount,
|
||||
page,
|
||||
limit,
|
||||
totalPages,
|
||||
);
|
||||
|
||||
/// Create a copy of ListCustomerDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ListCustomerDtoImplCopyWith<_$ListCustomerDtoImpl> get copyWith =>
|
||||
__$$ListCustomerDtoImplCopyWithImpl<_$ListCustomerDtoImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$ListCustomerDtoImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _ListCustomerDto extends ListCustomerDto {
|
||||
const factory _ListCustomerDto({
|
||||
@JsonKey(name: "data") final List<CustomerDto>? customers,
|
||||
@JsonKey(name: "total_count") final int? totalCount,
|
||||
@JsonKey(name: "page") final int? page,
|
||||
@JsonKey(name: "limit") final int? limit,
|
||||
@JsonKey(name: "total_pages") final int? totalPages,
|
||||
}) = _$ListCustomerDtoImpl;
|
||||
const _ListCustomerDto._() : super._();
|
||||
|
||||
factory _ListCustomerDto.fromJson(Map<String, dynamic> json) =
|
||||
_$ListCustomerDtoImpl.fromJson;
|
||||
|
||||
@override
|
||||
@JsonKey(name: "data")
|
||||
List<CustomerDto>? get customers;
|
||||
@override
|
||||
@JsonKey(name: "total_count")
|
||||
int? get totalCount;
|
||||
@override
|
||||
@JsonKey(name: "page")
|
||||
int? get page;
|
||||
@override
|
||||
@JsonKey(name: "limit")
|
||||
int? get limit;
|
||||
@override
|
||||
@JsonKey(name: "total_pages")
|
||||
int? get totalPages;
|
||||
|
||||
/// Create a copy of ListCustomerDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ListCustomerDtoImplCopyWith<_$ListCustomerDtoImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
CustomerDto _$CustomerDtoFromJson(Map<String, dynamic> json) {
|
||||
return _CustomerDto.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$CustomerDto {
|
||||
@JsonKey(name: "id")
|
||||
String? get id => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "organization_id")
|
||||
String? get organizationId => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "name")
|
||||
String? get name => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "email")
|
||||
String? get email => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "phone")
|
||||
String? get phone => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "address")
|
||||
String? get address => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "is_default")
|
||||
bool? get isDefault => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "is_active")
|
||||
bool? get isActive => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "metadata")
|
||||
Map<String, dynamic>? get metadata => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "created_at")
|
||||
String? get createdAt => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "updated_at")
|
||||
String? get updatedAt => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this CustomerDto to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of CustomerDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$CustomerDtoCopyWith<CustomerDto> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $CustomerDtoCopyWith<$Res> {
|
||||
factory $CustomerDtoCopyWith(
|
||||
CustomerDto value,
|
||||
$Res Function(CustomerDto) then,
|
||||
) = _$CustomerDtoCopyWithImpl<$Res, CustomerDto>;
|
||||
@useResult
|
||||
$Res call({
|
||||
@JsonKey(name: "id") String? id,
|
||||
@JsonKey(name: "organization_id") String? organizationId,
|
||||
@JsonKey(name: "name") String? name,
|
||||
@JsonKey(name: "email") String? email,
|
||||
@JsonKey(name: "phone") String? phone,
|
||||
@JsonKey(name: "address") String? address,
|
||||
@JsonKey(name: "is_default") bool? isDefault,
|
||||
@JsonKey(name: "is_active") bool? isActive,
|
||||
@JsonKey(name: "metadata") Map<String, dynamic>? metadata,
|
||||
@JsonKey(name: "created_at") String? createdAt,
|
||||
@JsonKey(name: "updated_at") String? updatedAt,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$CustomerDtoCopyWithImpl<$Res, $Val extends CustomerDto>
|
||||
implements $CustomerDtoCopyWith<$Res> {
|
||||
_$CustomerDtoCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of CustomerDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = freezed,
|
||||
Object? organizationId = freezed,
|
||||
Object? name = freezed,
|
||||
Object? email = freezed,
|
||||
Object? phone = freezed,
|
||||
Object? address = freezed,
|
||||
Object? isDefault = freezed,
|
||||
Object? isActive = freezed,
|
||||
Object? metadata = freezed,
|
||||
Object? createdAt = freezed,
|
||||
Object? updatedAt = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
id: freezed == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
organizationId: freezed == organizationId
|
||||
? _value.organizationId
|
||||
: organizationId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
name: freezed == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
email: freezed == email
|
||||
? _value.email
|
||||
: email // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
phone: freezed == phone
|
||||
? _value.phone
|
||||
: phone // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
address: freezed == address
|
||||
? _value.address
|
||||
: address // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
isDefault: freezed == isDefault
|
||||
? _value.isDefault
|
||||
: isDefault // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
isActive: freezed == isActive
|
||||
? _value.isActive
|
||||
: isActive // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
metadata: freezed == metadata
|
||||
? _value.metadata
|
||||
: metadata // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>?,
|
||||
createdAt: freezed == createdAt
|
||||
? _value.createdAt
|
||||
: createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
updatedAt: freezed == updatedAt
|
||||
? _value.updatedAt
|
||||
: updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CustomerDtoImplCopyWith<$Res>
|
||||
implements $CustomerDtoCopyWith<$Res> {
|
||||
factory _$$CustomerDtoImplCopyWith(
|
||||
_$CustomerDtoImpl value,
|
||||
$Res Function(_$CustomerDtoImpl) then,
|
||||
) = __$$CustomerDtoImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
@JsonKey(name: "id") String? id,
|
||||
@JsonKey(name: "organization_id") String? organizationId,
|
||||
@JsonKey(name: "name") String? name,
|
||||
@JsonKey(name: "email") String? email,
|
||||
@JsonKey(name: "phone") String? phone,
|
||||
@JsonKey(name: "address") String? address,
|
||||
@JsonKey(name: "is_default") bool? isDefault,
|
||||
@JsonKey(name: "is_active") bool? isActive,
|
||||
@JsonKey(name: "metadata") Map<String, dynamic>? metadata,
|
||||
@JsonKey(name: "created_at") String? createdAt,
|
||||
@JsonKey(name: "updated_at") String? updatedAt,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CustomerDtoImplCopyWithImpl<$Res>
|
||||
extends _$CustomerDtoCopyWithImpl<$Res, _$CustomerDtoImpl>
|
||||
implements _$$CustomerDtoImplCopyWith<$Res> {
|
||||
__$$CustomerDtoImplCopyWithImpl(
|
||||
_$CustomerDtoImpl _value,
|
||||
$Res Function(_$CustomerDtoImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of CustomerDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = freezed,
|
||||
Object? organizationId = freezed,
|
||||
Object? name = freezed,
|
||||
Object? email = freezed,
|
||||
Object? phone = freezed,
|
||||
Object? address = freezed,
|
||||
Object? isDefault = freezed,
|
||||
Object? isActive = freezed,
|
||||
Object? metadata = freezed,
|
||||
Object? createdAt = freezed,
|
||||
Object? updatedAt = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_$CustomerDtoImpl(
|
||||
id: freezed == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
organizationId: freezed == organizationId
|
||||
? _value.organizationId
|
||||
: organizationId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
name: freezed == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
email: freezed == email
|
||||
? _value.email
|
||||
: email // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
phone: freezed == phone
|
||||
? _value.phone
|
||||
: phone // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
address: freezed == address
|
||||
? _value.address
|
||||
: address // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
isDefault: freezed == isDefault
|
||||
? _value.isDefault
|
||||
: isDefault // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
isActive: freezed == isActive
|
||||
? _value.isActive
|
||||
: isActive // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
metadata: freezed == metadata
|
||||
? _value._metadata
|
||||
: metadata // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>?,
|
||||
createdAt: freezed == createdAt
|
||||
? _value.createdAt
|
||||
: createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
updatedAt: freezed == updatedAt
|
||||
? _value.updatedAt
|
||||
: updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$CustomerDtoImpl extends _CustomerDto with DiagnosticableTreeMixin {
|
||||
const _$CustomerDtoImpl({
|
||||
@JsonKey(name: "id") this.id,
|
||||
@JsonKey(name: "organization_id") this.organizationId,
|
||||
@JsonKey(name: "name") this.name,
|
||||
@JsonKey(name: "email") this.email,
|
||||
@JsonKey(name: "phone") this.phone,
|
||||
@JsonKey(name: "address") this.address,
|
||||
@JsonKey(name: "is_default") this.isDefault,
|
||||
@JsonKey(name: "is_active") this.isActive,
|
||||
@JsonKey(name: "metadata") final Map<String, dynamic>? metadata,
|
||||
@JsonKey(name: "created_at") this.createdAt,
|
||||
@JsonKey(name: "updated_at") this.updatedAt,
|
||||
}) : _metadata = metadata,
|
||||
super._();
|
||||
|
||||
factory _$CustomerDtoImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$CustomerDtoImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey(name: "id")
|
||||
final String? id;
|
||||
@override
|
||||
@JsonKey(name: "organization_id")
|
||||
final String? organizationId;
|
||||
@override
|
||||
@JsonKey(name: "name")
|
||||
final String? name;
|
||||
@override
|
||||
@JsonKey(name: "email")
|
||||
final String? email;
|
||||
@override
|
||||
@JsonKey(name: "phone")
|
||||
final String? phone;
|
||||
@override
|
||||
@JsonKey(name: "address")
|
||||
final String? address;
|
||||
@override
|
||||
@JsonKey(name: "is_default")
|
||||
final bool? isDefault;
|
||||
@override
|
||||
@JsonKey(name: "is_active")
|
||||
final bool? isActive;
|
||||
final Map<String, dynamic>? _metadata;
|
||||
@override
|
||||
@JsonKey(name: "metadata")
|
||||
Map<String, dynamic>? get metadata {
|
||||
final value = _metadata;
|
||||
if (value == null) return null;
|
||||
if (_metadata is EqualUnmodifiableMapView) return _metadata;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableMapView(value);
|
||||
}
|
||||
|
||||
@override
|
||||
@JsonKey(name: "created_at")
|
||||
final String? createdAt;
|
||||
@override
|
||||
@JsonKey(name: "updated_at")
|
||||
final String? updatedAt;
|
||||
|
||||
@override
|
||||
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
|
||||
return 'CustomerDto(id: $id, organizationId: $organizationId, name: $name, email: $email, phone: $phone, address: $address, isDefault: $isDefault, isActive: $isActive, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt)';
|
||||
}
|
||||
|
||||
@override
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
properties
|
||||
..add(DiagnosticsProperty('type', 'CustomerDto'))
|
||||
..add(DiagnosticsProperty('id', id))
|
||||
..add(DiagnosticsProperty('organizationId', organizationId))
|
||||
..add(DiagnosticsProperty('name', name))
|
||||
..add(DiagnosticsProperty('email', email))
|
||||
..add(DiagnosticsProperty('phone', phone))
|
||||
..add(DiagnosticsProperty('address', address))
|
||||
..add(DiagnosticsProperty('isDefault', isDefault))
|
||||
..add(DiagnosticsProperty('isActive', isActive))
|
||||
..add(DiagnosticsProperty('metadata', metadata))
|
||||
..add(DiagnosticsProperty('createdAt', createdAt))
|
||||
..add(DiagnosticsProperty('updatedAt', updatedAt));
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CustomerDtoImpl &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.organizationId, organizationId) ||
|
||||
other.organizationId == organizationId) &&
|
||||
(identical(other.name, name) || other.name == name) &&
|
||||
(identical(other.email, email) || other.email == email) &&
|
||||
(identical(other.phone, phone) || other.phone == phone) &&
|
||||
(identical(other.address, address) || other.address == address) &&
|
||||
(identical(other.isDefault, isDefault) ||
|
||||
other.isDefault == isDefault) &&
|
||||
(identical(other.isActive, isActive) ||
|
||||
other.isActive == isActive) &&
|
||||
const DeepCollectionEquality().equals(other._metadata, _metadata) &&
|
||||
(identical(other.createdAt, createdAt) ||
|
||||
other.createdAt == createdAt) &&
|
||||
(identical(other.updatedAt, updatedAt) ||
|
||||
other.updatedAt == updatedAt));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
id,
|
||||
organizationId,
|
||||
name,
|
||||
email,
|
||||
phone,
|
||||
address,
|
||||
isDefault,
|
||||
isActive,
|
||||
const DeepCollectionEquality().hash(_metadata),
|
||||
createdAt,
|
||||
updatedAt,
|
||||
);
|
||||
|
||||
/// Create a copy of CustomerDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$CustomerDtoImplCopyWith<_$CustomerDtoImpl> get copyWith =>
|
||||
__$$CustomerDtoImplCopyWithImpl<_$CustomerDtoImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$CustomerDtoImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _CustomerDto extends CustomerDto {
|
||||
const factory _CustomerDto({
|
||||
@JsonKey(name: "id") final String? id,
|
||||
@JsonKey(name: "organization_id") final String? organizationId,
|
||||
@JsonKey(name: "name") final String? name,
|
||||
@JsonKey(name: "email") final String? email,
|
||||
@JsonKey(name: "phone") final String? phone,
|
||||
@JsonKey(name: "address") final String? address,
|
||||
@JsonKey(name: "is_default") final bool? isDefault,
|
||||
@JsonKey(name: "is_active") final bool? isActive,
|
||||
@JsonKey(name: "metadata") final Map<String, dynamic>? metadata,
|
||||
@JsonKey(name: "created_at") final String? createdAt,
|
||||
@JsonKey(name: "updated_at") final String? updatedAt,
|
||||
}) = _$CustomerDtoImpl;
|
||||
const _CustomerDto._() : super._();
|
||||
|
||||
factory _CustomerDto.fromJson(Map<String, dynamic> json) =
|
||||
_$CustomerDtoImpl.fromJson;
|
||||
|
||||
@override
|
||||
@JsonKey(name: "id")
|
||||
String? get id;
|
||||
@override
|
||||
@JsonKey(name: "organization_id")
|
||||
String? get organizationId;
|
||||
@override
|
||||
@JsonKey(name: "name")
|
||||
String? get name;
|
||||
@override
|
||||
@JsonKey(name: "email")
|
||||
String? get email;
|
||||
@override
|
||||
@JsonKey(name: "phone")
|
||||
String? get phone;
|
||||
@override
|
||||
@JsonKey(name: "address")
|
||||
String? get address;
|
||||
@override
|
||||
@JsonKey(name: "is_default")
|
||||
bool? get isDefault;
|
||||
@override
|
||||
@JsonKey(name: "is_active")
|
||||
bool? get isActive;
|
||||
@override
|
||||
@JsonKey(name: "metadata")
|
||||
Map<String, dynamic>? get metadata;
|
||||
@override
|
||||
@JsonKey(name: "created_at")
|
||||
String? get createdAt;
|
||||
@override
|
||||
@JsonKey(name: "updated_at")
|
||||
String? get updatedAt;
|
||||
|
||||
/// Create a copy of CustomerDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$CustomerDtoImplCopyWith<_$CustomerDtoImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@ -1,59 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'customer_dtos.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$ListCustomerDtoImpl _$$ListCustomerDtoImplFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _$ListCustomerDtoImpl(
|
||||
customers: (json['data'] as List<dynamic>?)
|
||||
?.map((e) => CustomerDto.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
totalCount: (json['total_count'] as num?)?.toInt(),
|
||||
page: (json['page'] as num?)?.toInt(),
|
||||
limit: (json['limit'] as num?)?.toInt(),
|
||||
totalPages: (json['total_pages'] as num?)?.toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ListCustomerDtoImplToJson(
|
||||
_$ListCustomerDtoImpl instance,
|
||||
) => <String, dynamic>{
|
||||
'data': instance.customers,
|
||||
'total_count': instance.totalCount,
|
||||
'page': instance.page,
|
||||
'limit': instance.limit,
|
||||
'total_pages': instance.totalPages,
|
||||
};
|
||||
|
||||
_$CustomerDtoImpl _$$CustomerDtoImplFromJson(Map<String, dynamic> json) =>
|
||||
_$CustomerDtoImpl(
|
||||
id: json['id'] as String?,
|
||||
organizationId: json['organization_id'] as String?,
|
||||
name: json['name'] as String?,
|
||||
email: json['email'] as String?,
|
||||
phone: json['phone'] as String?,
|
||||
address: json['address'] as String?,
|
||||
isDefault: json['is_default'] as bool?,
|
||||
isActive: json['is_active'] as bool?,
|
||||
metadata: json['metadata'] as Map<String, dynamic>?,
|
||||
createdAt: json['created_at'] as String?,
|
||||
updatedAt: json['updated_at'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$CustomerDtoImplToJson(_$CustomerDtoImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'organization_id': instance.organizationId,
|
||||
'name': instance.name,
|
||||
'email': instance.email,
|
||||
'phone': instance.phone,
|
||||
'address': instance.address,
|
||||
'is_default': instance.isDefault,
|
||||
'is_active': instance.isActive,
|
||||
'metadata': instance.metadata,
|
||||
'created_at': instance.createdAt,
|
||||
'updated_at': instance.updatedAt,
|
||||
};
|
||||
@ -1,45 +0,0 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:data_channel/data_channel.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../common/api/api_client.dart';
|
||||
import '../../../common/api/api_failure.dart';
|
||||
import '../../../common/function/app_function.dart';
|
||||
import '../../../common/url/api_path.dart';
|
||||
import '../../../domain/customer/customer.dart';
|
||||
import '../customer_dtos.dart';
|
||||
|
||||
@injectable
|
||||
class CustomerRemoteDataProvider {
|
||||
final ApiClient _apiClient;
|
||||
final _logName = 'CustomerRemoteDataProvider';
|
||||
|
||||
CustomerRemoteDataProvider(this._apiClient);
|
||||
|
||||
Future<DC<CustomerFailure, ListCustomerDto>> fetchCustomers({
|
||||
int page = 1,
|
||||
int limit = 10,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _apiClient.get(
|
||||
ApiPath.customers,
|
||||
params: {'page': page, 'limit': limit},
|
||||
headers: getAuthorizationHeader(),
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(CustomerFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final customers = ListCustomerDto.fromJson(
|
||||
response.data['data'] as Map<String, dynamic>,
|
||||
);
|
||||
|
||||
return DC.data(customers);
|
||||
} on ApiFailure catch (e, s) {
|
||||
log('fetchCustomersError', name: _logName, error: e, stackTrace: s);
|
||||
return DC.error(CustomerFailure.serverError(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,62 +0,0 @@
|
||||
part of '../customer_dtos.dart';
|
||||
|
||||
@freezed
|
||||
class ListCustomerDto with _$ListCustomerDto {
|
||||
const ListCustomerDto._();
|
||||
|
||||
const factory ListCustomerDto({
|
||||
@JsonKey(name: "data") List<CustomerDto>? customers,
|
||||
@JsonKey(name: "total_count") int? totalCount,
|
||||
@JsonKey(name: "page") int? page,
|
||||
@JsonKey(name: "limit") int? limit,
|
||||
@JsonKey(name: "total_pages") int? totalPages,
|
||||
}) = _ListCustomerDto;
|
||||
|
||||
factory ListCustomerDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$ListCustomerDtoFromJson(json);
|
||||
|
||||
ListCustomer toDomain() => ListCustomer(
|
||||
customers: customers?.map((e) => e.toDomain()).toList() ?? [],
|
||||
totalCount: totalCount ?? 0,
|
||||
page: page ?? 0,
|
||||
limit: limit ?? 0,
|
||||
totalPages: totalPages ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class CustomerDto with _$CustomerDto {
|
||||
const CustomerDto._();
|
||||
|
||||
const factory CustomerDto({
|
||||
@JsonKey(name: "id") String? id,
|
||||
@JsonKey(name: "organization_id") String? organizationId,
|
||||
@JsonKey(name: "name") String? name,
|
||||
@JsonKey(name: "email") String? email,
|
||||
@JsonKey(name: "phone") String? phone,
|
||||
@JsonKey(name: "address") String? address,
|
||||
@JsonKey(name: "is_default") bool? isDefault,
|
||||
@JsonKey(name: "is_active") bool? isActive,
|
||||
@JsonKey(name: "metadata") Map<String, dynamic>? metadata,
|
||||
@JsonKey(name: "created_at") String? createdAt,
|
||||
@JsonKey(name: "updated_at") String? updatedAt,
|
||||
}) = _CustomerDto;
|
||||
|
||||
factory CustomerDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$CustomerDtoFromJson(json);
|
||||
|
||||
/// Mapping ke domain
|
||||
Customer toDomain() => Customer(
|
||||
id: id ?? '',
|
||||
organizationId: organizationId ?? '',
|
||||
name: name ?? '',
|
||||
email: email ?? '',
|
||||
phone: phone ?? '',
|
||||
address: address ?? '',
|
||||
isDefault: isDefault ?? false,
|
||||
isActive: isActive ?? false,
|
||||
metadata: metadata ?? {},
|
||||
createdAt: createdAt != null ? DateTime.parse(createdAt!) : DateTime(1970),
|
||||
updatedAt: updatedAt != null ? DateTime.parse(updatedAt!) : DateTime(1970),
|
||||
);
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../domain/customer/customer.dart';
|
||||
import '../datasources/remote_data_provider.dart';
|
||||
|
||||
@Injectable(as: ICustomerRepository)
|
||||
class CustomerRepository implements ICustomerRepository {
|
||||
final CustomerRemoteDataProvider _remoteDataProvider;
|
||||
final _logName = 'CustomerRepository';
|
||||
|
||||
CustomerRepository(this._remoteDataProvider);
|
||||
|
||||
@override
|
||||
Future<Either<CustomerFailure, ListCustomer>> getCustomer({
|
||||
int page = 1,
|
||||
int limit = 10,
|
||||
}) async {
|
||||
try {
|
||||
final result = await _remoteDataProvider.fetchCustomers(
|
||||
page: page,
|
||||
limit: limit,
|
||||
);
|
||||
|
||||
if (result.hasError) {
|
||||
return left(result.error!);
|
||||
}
|
||||
|
||||
final customers = result.data!.toDomain();
|
||||
return right(customers);
|
||||
} catch (e) {
|
||||
log('getCustomerError', name: _logName, error: e);
|
||||
return left(const CustomerFailure.unexpectedError());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -16,8 +16,6 @@ import 'package:apskel_pos_flutter_v2/application/category/category_loader/categ
|
||||
as _i1018;
|
||||
import 'package:apskel_pos_flutter_v2/application/checkout/checkout_form/checkout_form_bloc.dart'
|
||||
as _i13;
|
||||
import 'package:apskel_pos_flutter_v2/application/customer/customer_loader/customer_loader_bloc.dart'
|
||||
as _i683;
|
||||
import 'package:apskel_pos_flutter_v2/application/outlet/outlet_loader/outlet_loader_bloc.dart'
|
||||
as _i76;
|
||||
import 'package:apskel_pos_flutter_v2/application/product/product_loader/product_loader_bloc.dart'
|
||||
@ -40,7 +38,6 @@ import 'package:apskel_pos_flutter_v2/common/network/network_client.dart'
|
||||
as _i171;
|
||||
import 'package:apskel_pos_flutter_v2/domain/auth/auth.dart' as _i776;
|
||||
import 'package:apskel_pos_flutter_v2/domain/category/category.dart' as _i502;
|
||||
import 'package:apskel_pos_flutter_v2/domain/customer/customer.dart' as _i143;
|
||||
import 'package:apskel_pos_flutter_v2/domain/outlet/outlet.dart' as _i552;
|
||||
import 'package:apskel_pos_flutter_v2/domain/product/product.dart' as _i44;
|
||||
import 'package:apskel_pos_flutter_v2/domain/table/table.dart' as _i983;
|
||||
@ -57,10 +54,6 @@ import 'package:apskel_pos_flutter_v2/infrastructure/category/datasources/remote
|
||||
as _i856;
|
||||
import 'package:apskel_pos_flutter_v2/infrastructure/category/repositories/category_repository.dart'
|
||||
as _i604;
|
||||
import 'package:apskel_pos_flutter_v2/infrastructure/customer/datasources/remote_data_provider.dart'
|
||||
as _i841;
|
||||
import 'package:apskel_pos_flutter_v2/infrastructure/customer/repositories/customer_repository.dart'
|
||||
as _i385;
|
||||
import 'package:apskel_pos_flutter_v2/infrastructure/outlet/datasources/local_data_provider.dart'
|
||||
as _i693;
|
||||
import 'package:apskel_pos_flutter_v2/infrastructure/outlet/datasources/remote_data_provider.dart'
|
||||
@ -144,9 +137,6 @@ extension GetItInjectableX on _i174.GetIt {
|
||||
gh.factory<_i95.TableRemoteDataProvider>(
|
||||
() => _i95.TableRemoteDataProvider(gh<_i457.ApiClient>()),
|
||||
);
|
||||
gh.factory<_i841.CustomerRemoteDataProvider>(
|
||||
() => _i841.CustomerRemoteDataProvider(gh<_i457.ApiClient>()),
|
||||
);
|
||||
gh.factory<_i776.IAuthRepository>(
|
||||
() => _i941.AuthRepository(
|
||||
gh<_i370.AuthRemoteDataProvider>(),
|
||||
@ -189,12 +179,6 @@ extension GetItInjectableX on _i174.GetIt {
|
||||
gh.factory<_i1018.CategoryLoaderBloc>(
|
||||
() => _i1018.CategoryLoaderBloc(gh<_i502.ICategoryRepository>()),
|
||||
);
|
||||
gh.factory<_i143.ICustomerRepository>(
|
||||
() => _i385.CustomerRepository(gh<_i841.CustomerRemoteDataProvider>()),
|
||||
);
|
||||
gh.factory<_i683.CustomerLoaderBloc>(
|
||||
() => _i683.CustomerLoaderBloc(gh<_i143.ICustomerRepository>()),
|
||||
);
|
||||
gh.factory<_i343.AuthBloc>(
|
||||
() => _i343.AuthBloc(
|
||||
gh<_i776.IAuthRepository>(),
|
||||
|
||||
@ -1,39 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DashedDivider extends StatelessWidget {
|
||||
final double height;
|
||||
final double dashWidth;
|
||||
final double dashSpacing;
|
||||
final Color color;
|
||||
|
||||
const DashedDivider({
|
||||
super.key,
|
||||
this.height = 1,
|
||||
this.dashWidth = 5,
|
||||
this.dashSpacing = 3,
|
||||
this.color = Colors.grey,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: height,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final boxWidth = constraints.constrainWidth();
|
||||
final dashCount = (boxWidth / (dashWidth + dashSpacing)).floor();
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: List.generate(dashCount, (_) {
|
||||
return SizedBox(
|
||||
width: dashWidth,
|
||||
height: height,
|
||||
child: DecoratedBox(decoration: BoxDecoration(color: color)),
|
||||
);
|
||||
}),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,73 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../common/theme/theme.dart';
|
||||
import '../../../domain/customer/customer.dart';
|
||||
|
||||
class CustomerCard extends StatelessWidget {
|
||||
final Customer customer;
|
||||
final bool isActive;
|
||||
final Function() onTap;
|
||||
const CustomerCard({
|
||||
super.key,
|
||||
required this.customer,
|
||||
required this.isActive,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16).copyWith(bottom: 16),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: isActive ? AppColor.primary.withOpacity(0.1) : AppColor.white,
|
||||
border: Border.all(
|
||||
color: isActive ? AppColor.primary : AppColor.border,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 22,
|
||||
backgroundColor: AppColor.primary,
|
||||
child: Icon(Icons.person, color: Colors.white),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
customer.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
customer.email.isNotEmpty ? customer.email : '-',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,126 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../application/checkout/checkout_form/checkout_form_bloc.dart';
|
||||
import '../../../common/theme/theme.dart';
|
||||
import '../../../common/types/order_type.dart';
|
||||
import '../spaces/space.dart';
|
||||
import 'dialog.dart';
|
||||
|
||||
class OrderTypeDialog extends StatelessWidget {
|
||||
const OrderTypeDialog({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Map<String, dynamic>> types = [
|
||||
{
|
||||
'value': 'dine_in',
|
||||
'label': 'Dine In',
|
||||
'icon': Icons.restaurant_outlined,
|
||||
'type': OrderType.dineIn,
|
||||
},
|
||||
{
|
||||
'value': 'take_away',
|
||||
'label': 'Take Away',
|
||||
'icon': Icons.takeout_dining_outlined,
|
||||
'type': OrderType.takeAway,
|
||||
},
|
||||
{
|
||||
'value': 'delivery',
|
||||
'label': 'Delivery',
|
||||
'icon': Icons.delivery_dining_outlined,
|
||||
'type': OrderType.delivery,
|
||||
},
|
||||
{
|
||||
'value': 'free_table',
|
||||
'label': 'Free Table',
|
||||
'icon': Icons.table_bar_outlined,
|
||||
'type': OrderType.freeTable,
|
||||
},
|
||||
];
|
||||
return CustomModalDialog(
|
||||
title: 'Pilih Tipe',
|
||||
subtitle: 'Silahkan pilih tipe yang sesuai',
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16.0,
|
||||
vertical: 24.0,
|
||||
),
|
||||
child: BlocBuilder<CheckoutFormBloc, CheckoutFormState>(
|
||||
builder: (context, state) {
|
||||
return Column(
|
||||
children: List.generate(types.length, (index) {
|
||||
return _buildItem(
|
||||
context,
|
||||
types[index],
|
||||
selectedType: state.orderType,
|
||||
);
|
||||
}),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItem(
|
||||
BuildContext context,
|
||||
Map<String, dynamic> type, {
|
||||
required OrderType selectedType,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
context.read<CheckoutFormBloc>().add(
|
||||
CheckoutFormEvent.updateOrderType(type['type']),
|
||||
);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0),
|
||||
margin: const EdgeInsets.only(bottom: 8.0),
|
||||
decoration: BoxDecoration(
|
||||
color: selectedType == type['type']
|
||||
? AppColor.primary
|
||||
: AppColor.white,
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
border: Border.all(
|
||||
color: selectedType == type['type']
|
||||
? AppColor.primary
|
||||
: AppColor.textSecondary,
|
||||
width: 1.0,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
type['icon'],
|
||||
color: selectedType == type['type']
|
||||
? AppColor.white
|
||||
: AppColor.black,
|
||||
),
|
||||
SpaceWidth(12.0),
|
||||
Expanded(
|
||||
child: Text(
|
||||
type['label']!,
|
||||
style: AppStyle.lg.copyWith(
|
||||
color: selectedType == type['type']
|
||||
? AppColor.white
|
||||
: AppColor.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
SpaceWidth(12.0),
|
||||
Icon(
|
||||
Icons.check_circle,
|
||||
color: selectedType == type['value']
|
||||
? AppColor.success
|
||||
: Colors.transparent,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,63 +0,0 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../common/extension/extension.dart';
|
||||
import '../../../common/theme/theme.dart';
|
||||
import '../spaces/space.dart';
|
||||
|
||||
class PageTitle extends StatelessWidget {
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final bool isBack;
|
||||
final List<Widget>? actionWidget;
|
||||
const PageTitle({
|
||||
super.key,
|
||||
required this.title,
|
||||
this.subtitle,
|
||||
this.isBack = true,
|
||||
this.actionWidget,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: context.deviceHeight * 0.123,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.white,
|
||||
border: Border(bottom: BorderSide(color: AppColor.border, width: 1.0)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
if (isBack) ...[
|
||||
GestureDetector(
|
||||
onTap: () => context.maybePop(),
|
||||
child: Icon(Icons.arrow_back, color: AppColor.primary, size: 24),
|
||||
),
|
||||
SpaceWidth(16),
|
||||
],
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: AppStyle.xxl.copyWith(fontWeight: FontWeight.w600),
|
||||
),
|
||||
if (subtitle != null) ...[
|
||||
const SizedBox(height: 4.0),
|
||||
Text(
|
||||
subtitle!,
|
||||
style: AppStyle.md.copyWith(color: AppColor.textSecondary),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
if (actionWidget != null) ...actionWidget!,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,269 +1,12 @@
|
||||
import 'package:apskel_pos_flutter_v2/domain/customer/customer.dart';
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../../application/customer/customer_loader/customer_loader_bloc.dart';
|
||||
import '../../../../../common/extension/extension.dart';
|
||||
import '../../../../../common/theme/theme.dart';
|
||||
import '../../../../../injection.dart';
|
||||
import '../../../../components/border/dashed_border.dart';
|
||||
import '../../../../components/card/customer_card.dart';
|
||||
import '../../../../components/card/error_card.dart';
|
||||
import '../../../../components/loader/loader_with_text.dart';
|
||||
import '../../../../components/page/page_title.dart';
|
||||
import '../../../../components/spaces/space.dart';
|
||||
|
||||
@RoutePage()
|
||||
class CustomerPage extends StatelessWidget implements AutoRouteWrapper {
|
||||
class CustomerPage extends StatelessWidget {
|
||||
const CustomerPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColor.background,
|
||||
body: BlocBuilder<CustomerLoaderBloc, CustomerLoaderState>(
|
||||
builder: (context, state) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Material(
|
||||
color: AppColor.white,
|
||||
child: Column(
|
||||
children: [
|
||||
PageTitle(title: 'Daftar Pelanggan'),
|
||||
Expanded(
|
||||
child: state.isFetching
|
||||
? Center(child: const LoaderWithText())
|
||||
: state.failureOrOption.fold(
|
||||
() => ListView.builder(
|
||||
itemCount: state.customers.length,
|
||||
itemBuilder: (context, index) {
|
||||
final customer = state.customers[index];
|
||||
return CustomerCard(
|
||||
customer: customer,
|
||||
isActive:
|
||||
customer == state.selectedCustomer,
|
||||
onTap: () {
|
||||
context.read<CustomerLoaderBloc>().add(
|
||||
CustomerLoaderEvent.setSelectedCustomer(
|
||||
customer,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
(f) => _buildErrorState(f, context),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: state.selectedCustomer == null
|
||||
? Center(
|
||||
child: Text(
|
||||
"Belum ada pelanggan yang dipilih.",
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
)
|
||||
: Center(
|
||||
child: Container(
|
||||
width: context.deviceHeight * 0.5,
|
||||
height: context.deviceHeight * 0.6,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12.0,
|
||||
vertical: 16.0,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 24,
|
||||
backgroundColor: AppColor.primary,
|
||||
child: Icon(
|
||||
Icons.person,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
state.selectedCustomer?.name ?? "",
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
DashedDivider(color: AppColor.border),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12.0,
|
||||
vertical: 16.0,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'No. Handphone',
|
||||
style: TextStyle(fontSize: 12.0),
|
||||
),
|
||||
Text(
|
||||
(state
|
||||
.selectedCustomer
|
||||
?.phone
|
||||
.isEmpty ??
|
||||
true)
|
||||
? "-"
|
||||
: state.selectedCustomer?.phone ??
|
||||
"-",
|
||||
style: TextStyle(
|
||||
fontSize: 12.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SpaceHeight(8),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Email',
|
||||
style: TextStyle(fontSize: 12.0),
|
||||
),
|
||||
Text(
|
||||
(state
|
||||
.selectedCustomer
|
||||
?.email
|
||||
.isEmpty ??
|
||||
true)
|
||||
? "-"
|
||||
: state.selectedCustomer?.email ??
|
||||
"-",
|
||||
style: TextStyle(
|
||||
fontSize: 12.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SpaceHeight(8),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Alamat',
|
||||
style: TextStyle(fontSize: 12.0),
|
||||
),
|
||||
Text(
|
||||
(state
|
||||
.selectedCustomer
|
||||
?.address
|
||||
.isEmpty ??
|
||||
true)
|
||||
? "-"
|
||||
: state
|
||||
.selectedCustomer
|
||||
?.address ??
|
||||
"-",
|
||||
style: TextStyle(
|
||||
fontSize: 12.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
return const Placeholder();
|
||||
}
|
||||
|
||||
Widget _buildErrorState(CustomerFailure f, BuildContext context) {
|
||||
return f.maybeMap(
|
||||
orElse: () => ErrorCard(
|
||||
title: "Pelanggan",
|
||||
message: "Terjadi kesalahan saat memuat pelanggan",
|
||||
onTap: () {
|
||||
context.read<CustomerLoaderBloc>().add(
|
||||
CustomerLoaderEvent.fetched(isRefresh: true),
|
||||
);
|
||||
},
|
||||
),
|
||||
empty: (value) => ErrorCard(
|
||||
title: "Pelanggan",
|
||||
message: "Pelanggan masih kosong, silahkan tambahkan pelanggan",
|
||||
onTap: () {
|
||||
context.read<CustomerLoaderBloc>().add(
|
||||
CustomerLoaderEvent.fetched(isRefresh: true),
|
||||
);
|
||||
},
|
||||
),
|
||||
serverError: (value) => ErrorCard(
|
||||
title: "Pelanggan",
|
||||
message: "Terjadi kesalahan saat memuat pelanggan",
|
||||
onTap: () {
|
||||
context.read<CustomerLoaderBloc>().add(
|
||||
CustomerLoaderEvent.fetched(isRefresh: true),
|
||||
);
|
||||
},
|
||||
),
|
||||
dynamicErrorMessage: (value) => ErrorCard(
|
||||
title: "Pelanggan",
|
||||
message: value.erroMessage,
|
||||
onTap: () {
|
||||
context.read<CustomerLoaderBloc>().add(
|
||||
CustomerLoaderEvent.fetched(isRefresh: true),
|
||||
);
|
||||
},
|
||||
),
|
||||
unexpectedError: (value) => ErrorCard(
|
||||
title: "Pelanggan",
|
||||
message: "Terjadi kesalahan saat memuat pelanggan",
|
||||
onTap: () {
|
||||
context.read<CustomerLoaderBloc>().add(
|
||||
CustomerLoaderEvent.fetched(isRefresh: true),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget wrappedRoute(BuildContext context) => BlocProvider(
|
||||
create: (context) =>
|
||||
getIt<CustomerLoaderBloc>()
|
||||
..add(CustomerLoaderEvent.fetched(isRefresh: true)),
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,11 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../../../application/checkout/checkout_form/checkout_form_bloc.dart';
|
||||
import '../../../../../../common/extension/extension.dart';
|
||||
import '../../../../../../common/theme/theme.dart';
|
||||
import '../../../../../components/button/button.dart';
|
||||
import '../../../../../components/dialog/order_type_dialog.dart';
|
||||
|
||||
class HomeRightTitle extends StatelessWidget {
|
||||
// final TableModel? table;
|
||||
@ -13,92 +10,88 @@ class HomeRightTitle extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<CheckoutFormBloc, CheckoutFormState>(
|
||||
builder: (context, state) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 20),
|
||||
height: context.deviceHeight * 0.15,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.primary,
|
||||
border: Border(left: BorderSide(color: Colors.white, width: 1.0)),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: AppElevatedButton.filled(
|
||||
width: 180.0,
|
||||
height: 40,
|
||||
elevation: 0,
|
||||
onPressed: () {},
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
icon: Icon(Icons.list, color: Colors.white, size: 24),
|
||||
label: 'Daftar Pesanan',
|
||||
),
|
||||
),
|
||||
],
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 20),
|
||||
height: context.deviceHeight * 0.15,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.primary,
|
||||
border: Border(left: BorderSide(color: Colors.white, width: 1.0)),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: AppElevatedButton.filled(
|
||||
width: 180.0,
|
||||
height: 40,
|
||||
elevation: 0,
|
||||
onPressed: () {},
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
icon: Icon(Icons.list, color: Colors.white, size: 24),
|
||||
label: 'Daftar Pesanan',
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: AppElevatedButton.filled(
|
||||
width: 180.0,
|
||||
height: 40,
|
||||
elevation: 0,
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return OrderTypeDialog();
|
||||
},
|
||||
);
|
||||
},
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
icon: Icon(
|
||||
state.orderType.icon,
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
label: state.orderType.value.toTitleCase(),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: AppElevatedButton.filled(
|
||||
width: 180.0,
|
||||
height: 40,
|
||||
elevation: 0,
|
||||
icon: Icon(
|
||||
Icons.motorcycle_outlined,
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
onPressed: () {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (context) {
|
||||
// return DeliveryDialog();
|
||||
// },
|
||||
// );
|
||||
},
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
label: 'Pilih Pengiriman',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: AppElevatedButton.filled(
|
||||
width: 180.0,
|
||||
height: 40,
|
||||
elevation: 0,
|
||||
onPressed: () {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (context) {
|
||||
// return TypeDialog();
|
||||
// },
|
||||
// );
|
||||
},
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
icon: Icon(
|
||||
Icons.dinner_dining_outlined,
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
label: 'Dine In',
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: AppElevatedButton.filled(
|
||||
width: 180.0,
|
||||
height: 40,
|
||||
elevation: 0,
|
||||
icon: Icon(
|
||||
Icons.motorcycle_outlined,
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
onPressed: () {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (context) {
|
||||
// return DeliveryDialog();
|
||||
// },
|
||||
// );
|
||||
},
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
label: 'Pilih Pengiriman',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ class CustomerRoute extends _i10.PageRouteInfo<void> {
|
||||
static _i10.PageInfo page = _i10.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return _i10.WrappedRoute(child: const _i1.CustomerPage());
|
||||
return const _i1.CustomerPage();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user