From 59d4d4c0e54e400741331fb9ab4a03902a9aa607 Mon Sep 17 00:00:00 2001 From: efrilm Date: Tue, 28 Oct 2025 15:43:51 +0700 Subject: [PATCH] success order page --- .../order/order_loader/order_loader_bloc.dart | 19 + .../order_loader_bloc.freezed.dart | 274 +++++++++++++- .../order_loader/order_loader_event.dart | 1 + .../order_loader/order_loader_state.dart | 5 + .../repositories/i_order_repository.dart | 2 + .../datasources/remote_data_provider.dart | 22 ++ .../order/repositories/order_repository.dart | 17 + .../pages/checkout/checkout_page.dart | 5 +- .../success_order/success_order_page.dart | 58 +++ .../widgets/success_order_left_panel.dart | 250 +++++++++++++ .../widgets/success_order_right_panel.dart | 352 ++++++++++++++++++ lib/presentation/router/app_router.dart | 1 + lib/presentation/router/app_router.gr.dart | 138 ++++--- 13 files changed, 1094 insertions(+), 50 deletions(-) create mode 100644 lib/presentation/pages/order/pages/success_order/success_order_page.dart create mode 100644 lib/presentation/pages/order/pages/success_order/widgets/success_order_left_panel.dart create mode 100644 lib/presentation/pages/order/pages/success_order/widgets/success_order_right_panel.dart diff --git a/lib/application/order/order_loader/order_loader_bloc.dart b/lib/application/order/order_loader/order_loader_bloc.dart index 367fb9f..410a278 100644 --- a/lib/application/order/order_loader/order_loader_bloc.dart +++ b/lib/application/order/order_loader/order_loader_bloc.dart @@ -45,6 +45,25 @@ class OrderLoaderBloc extends Bloc { ); emit(newState); }, + getById: (e) async { + emit(state.copyWith(isFetchingById: true, failureOption: none())); + + final failureOrOrder = await _repository.getOrderById(e.id); + failureOrOrder.fold( + (f) => emit( + state.copyWith(failureOption: optionOf(f), isFetching: false), + ), + (order) => emit( + state.copyWith( + order: order, + isFetching: false, + failureOption: none(), + ), + ), + ); + + emit(state.copyWith(isFetchingById: false)); + }, ); } diff --git a/lib/application/order/order_loader/order_loader_bloc.freezed.dart b/lib/application/order/order_loader/order_loader_bloc.freezed.dart index ae7a02e..9d205a4 100644 --- a/lib/application/order/order_loader/order_loader_bloc.freezed.dart +++ b/lib/application/order/order_loader/order_loader_bloc.freezed.dart @@ -23,6 +23,7 @@ mixin _$OrderLoaderEvent { dateTimeRangeChange, required TResult Function(String search) searchChange, required TResult Function(Order order) setSelectedOrder, + required TResult Function(String id) getById, required TResult Function(bool isRefresh, String status) fetched, }) => throw _privateConstructorUsedError; @optionalTypeArgs @@ -31,6 +32,7 @@ mixin _$OrderLoaderEvent { dateTimeRangeChange, TResult? Function(String search)? searchChange, TResult? Function(Order order)? setSelectedOrder, + TResult? Function(String id)? getById, TResult? Function(bool isRefresh, String status)? fetched, }) => throw _privateConstructorUsedError; @optionalTypeArgs @@ -38,6 +40,7 @@ mixin _$OrderLoaderEvent { TResult Function(DateTime startDate, DateTime endDate)? dateTimeRangeChange, TResult Function(String search)? searchChange, TResult Function(Order order)? setSelectedOrder, + TResult Function(String id)? getById, TResult Function(bool isRefresh, String status)? fetched, required TResult orElse(), }) => throw _privateConstructorUsedError; @@ -46,6 +49,7 @@ mixin _$OrderLoaderEvent { required TResult Function(_DateTimeRangeChange value) dateTimeRangeChange, required TResult Function(_SearchChange value) searchChange, required TResult Function(_SetSelectedOrder value) setSelectedOrder, + required TResult Function(_GetById value) getById, required TResult Function(_Fetched value) fetched, }) => throw _privateConstructorUsedError; @optionalTypeArgs @@ -53,6 +57,7 @@ mixin _$OrderLoaderEvent { TResult? Function(_DateTimeRangeChange value)? dateTimeRangeChange, TResult? Function(_SearchChange value)? searchChange, TResult? Function(_SetSelectedOrder value)? setSelectedOrder, + TResult? Function(_GetById value)? getById, TResult? Function(_Fetched value)? fetched, }) => throw _privateConstructorUsedError; @optionalTypeArgs @@ -60,6 +65,7 @@ mixin _$OrderLoaderEvent { TResult Function(_DateTimeRangeChange value)? dateTimeRangeChange, TResult Function(_SearchChange value)? searchChange, TResult Function(_SetSelectedOrder value)? setSelectedOrder, + TResult Function(_GetById value)? getById, TResult Function(_Fetched value)? fetched, required TResult orElse(), }) => throw _privateConstructorUsedError; @@ -172,6 +178,7 @@ class _$DateTimeRangeChangeImpl implements _DateTimeRangeChange { dateTimeRangeChange, required TResult Function(String search) searchChange, required TResult Function(Order order) setSelectedOrder, + required TResult Function(String id) getById, required TResult Function(bool isRefresh, String status) fetched, }) { return dateTimeRangeChange(startDate, endDate); @@ -184,6 +191,7 @@ class _$DateTimeRangeChangeImpl implements _DateTimeRangeChange { dateTimeRangeChange, TResult? Function(String search)? searchChange, TResult? Function(Order order)? setSelectedOrder, + TResult? Function(String id)? getById, TResult? Function(bool isRefresh, String status)? fetched, }) { return dateTimeRangeChange?.call(startDate, endDate); @@ -195,6 +203,7 @@ class _$DateTimeRangeChangeImpl implements _DateTimeRangeChange { TResult Function(DateTime startDate, DateTime endDate)? dateTimeRangeChange, TResult Function(String search)? searchChange, TResult Function(Order order)? setSelectedOrder, + TResult Function(String id)? getById, TResult Function(bool isRefresh, String status)? fetched, required TResult orElse(), }) { @@ -210,6 +219,7 @@ class _$DateTimeRangeChangeImpl implements _DateTimeRangeChange { required TResult Function(_DateTimeRangeChange value) dateTimeRangeChange, required TResult Function(_SearchChange value) searchChange, required TResult Function(_SetSelectedOrder value) setSelectedOrder, + required TResult Function(_GetById value) getById, required TResult Function(_Fetched value) fetched, }) { return dateTimeRangeChange(this); @@ -221,6 +231,7 @@ class _$DateTimeRangeChangeImpl implements _DateTimeRangeChange { TResult? Function(_DateTimeRangeChange value)? dateTimeRangeChange, TResult? Function(_SearchChange value)? searchChange, TResult? Function(_SetSelectedOrder value)? setSelectedOrder, + TResult? Function(_GetById value)? getById, TResult? Function(_Fetched value)? fetched, }) { return dateTimeRangeChange?.call(this); @@ -232,6 +243,7 @@ class _$DateTimeRangeChangeImpl implements _DateTimeRangeChange { TResult Function(_DateTimeRangeChange value)? dateTimeRangeChange, TResult Function(_SearchChange value)? searchChange, TResult Function(_SetSelectedOrder value)? setSelectedOrder, + TResult Function(_GetById value)? getById, TResult Function(_Fetched value)? fetched, required TResult orElse(), }) { @@ -332,6 +344,7 @@ class _$SearchChangeImpl implements _SearchChange { dateTimeRangeChange, required TResult Function(String search) searchChange, required TResult Function(Order order) setSelectedOrder, + required TResult Function(String id) getById, required TResult Function(bool isRefresh, String status) fetched, }) { return searchChange(search); @@ -344,6 +357,7 @@ class _$SearchChangeImpl implements _SearchChange { dateTimeRangeChange, TResult? Function(String search)? searchChange, TResult? Function(Order order)? setSelectedOrder, + TResult? Function(String id)? getById, TResult? Function(bool isRefresh, String status)? fetched, }) { return searchChange?.call(search); @@ -355,6 +369,7 @@ class _$SearchChangeImpl implements _SearchChange { TResult Function(DateTime startDate, DateTime endDate)? dateTimeRangeChange, TResult Function(String search)? searchChange, TResult Function(Order order)? setSelectedOrder, + TResult Function(String id)? getById, TResult Function(bool isRefresh, String status)? fetched, required TResult orElse(), }) { @@ -370,6 +385,7 @@ class _$SearchChangeImpl implements _SearchChange { required TResult Function(_DateTimeRangeChange value) dateTimeRangeChange, required TResult Function(_SearchChange value) searchChange, required TResult Function(_SetSelectedOrder value) setSelectedOrder, + required TResult Function(_GetById value) getById, required TResult Function(_Fetched value) fetched, }) { return searchChange(this); @@ -381,6 +397,7 @@ class _$SearchChangeImpl implements _SearchChange { TResult? Function(_DateTimeRangeChange value)? dateTimeRangeChange, TResult? Function(_SearchChange value)? searchChange, TResult? Function(_SetSelectedOrder value)? setSelectedOrder, + TResult? Function(_GetById value)? getById, TResult? Function(_Fetched value)? fetched, }) { return searchChange?.call(this); @@ -392,6 +409,7 @@ class _$SearchChangeImpl implements _SearchChange { TResult Function(_DateTimeRangeChange value)? dateTimeRangeChange, TResult Function(_SearchChange value)? searchChange, TResult Function(_SetSelectedOrder value)? setSelectedOrder, + TResult Function(_GetById value)? getById, TResult Function(_Fetched value)? fetched, required TResult orElse(), }) { @@ -503,6 +521,7 @@ class _$SetSelectedOrderImpl implements _SetSelectedOrder { dateTimeRangeChange, required TResult Function(String search) searchChange, required TResult Function(Order order) setSelectedOrder, + required TResult Function(String id) getById, required TResult Function(bool isRefresh, String status) fetched, }) { return setSelectedOrder(order); @@ -515,6 +534,7 @@ class _$SetSelectedOrderImpl implements _SetSelectedOrder { dateTimeRangeChange, TResult? Function(String search)? searchChange, TResult? Function(Order order)? setSelectedOrder, + TResult? Function(String id)? getById, TResult? Function(bool isRefresh, String status)? fetched, }) { return setSelectedOrder?.call(order); @@ -526,6 +546,7 @@ class _$SetSelectedOrderImpl implements _SetSelectedOrder { TResult Function(DateTime startDate, DateTime endDate)? dateTimeRangeChange, TResult Function(String search)? searchChange, TResult Function(Order order)? setSelectedOrder, + TResult Function(String id)? getById, TResult Function(bool isRefresh, String status)? fetched, required TResult orElse(), }) { @@ -541,6 +562,7 @@ class _$SetSelectedOrderImpl implements _SetSelectedOrder { required TResult Function(_DateTimeRangeChange value) dateTimeRangeChange, required TResult Function(_SearchChange value) searchChange, required TResult Function(_SetSelectedOrder value) setSelectedOrder, + required TResult Function(_GetById value) getById, required TResult Function(_Fetched value) fetched, }) { return setSelectedOrder(this); @@ -552,6 +574,7 @@ class _$SetSelectedOrderImpl implements _SetSelectedOrder { TResult? Function(_DateTimeRangeChange value)? dateTimeRangeChange, TResult? Function(_SearchChange value)? searchChange, TResult? Function(_SetSelectedOrder value)? setSelectedOrder, + TResult? Function(_GetById value)? getById, TResult? Function(_Fetched value)? fetched, }) { return setSelectedOrder?.call(this); @@ -563,6 +586,7 @@ class _$SetSelectedOrderImpl implements _SetSelectedOrder { TResult Function(_DateTimeRangeChange value)? dateTimeRangeChange, TResult Function(_SearchChange value)? searchChange, TResult Function(_SetSelectedOrder value)? setSelectedOrder, + TResult Function(_GetById value)? getById, TResult Function(_Fetched value)? fetched, required TResult orElse(), }) { @@ -585,6 +609,168 @@ abstract class _SetSelectedOrder implements OrderLoaderEvent { throw _privateConstructorUsedError; } +/// @nodoc +abstract class _$$GetByIdImplCopyWith<$Res> { + factory _$$GetByIdImplCopyWith( + _$GetByIdImpl value, + $Res Function(_$GetByIdImpl) then, + ) = __$$GetByIdImplCopyWithImpl<$Res>; + @useResult + $Res call({String id}); +} + +/// @nodoc +class __$$GetByIdImplCopyWithImpl<$Res> + extends _$OrderLoaderEventCopyWithImpl<$Res, _$GetByIdImpl> + implements _$$GetByIdImplCopyWith<$Res> { + __$$GetByIdImplCopyWithImpl( + _$GetByIdImpl _value, + $Res Function(_$GetByIdImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? id = null}) { + return _then( + _$GetByIdImpl( + null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$GetByIdImpl implements _GetById { + const _$GetByIdImpl(this.id); + + @override + final String id; + + @override + String toString() { + return 'OrderLoaderEvent.getById(id: $id)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$GetByIdImpl && + (identical(other.id, id) || other.id == id)); + } + + @override + int get hashCode => Object.hash(runtimeType, id); + + /// Create a copy of OrderLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$GetByIdImplCopyWith<_$GetByIdImpl> get copyWith => + __$$GetByIdImplCopyWithImpl<_$GetByIdImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(DateTime startDate, DateTime endDate) + dateTimeRangeChange, + required TResult Function(String search) searchChange, + required TResult Function(Order order) setSelectedOrder, + required TResult Function(String id) getById, + required TResult Function(bool isRefresh, String status) fetched, + }) { + return getById(id); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(DateTime startDate, DateTime endDate)? + dateTimeRangeChange, + TResult? Function(String search)? searchChange, + TResult? Function(Order order)? setSelectedOrder, + TResult? Function(String id)? getById, + TResult? Function(bool isRefresh, String status)? fetched, + }) { + return getById?.call(id); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(DateTime startDate, DateTime endDate)? dateTimeRangeChange, + TResult Function(String search)? searchChange, + TResult Function(Order order)? setSelectedOrder, + TResult Function(String id)? getById, + TResult Function(bool isRefresh, String status)? fetched, + required TResult orElse(), + }) { + if (getById != null) { + return getById(id); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_DateTimeRangeChange value) dateTimeRangeChange, + required TResult Function(_SearchChange value) searchChange, + required TResult Function(_SetSelectedOrder value) setSelectedOrder, + required TResult Function(_GetById value) getById, + required TResult Function(_Fetched value) fetched, + }) { + return getById(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_DateTimeRangeChange value)? dateTimeRangeChange, + TResult? Function(_SearchChange value)? searchChange, + TResult? Function(_SetSelectedOrder value)? setSelectedOrder, + TResult? Function(_GetById value)? getById, + TResult? Function(_Fetched value)? fetched, + }) { + return getById?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_DateTimeRangeChange value)? dateTimeRangeChange, + TResult Function(_SearchChange value)? searchChange, + TResult Function(_SetSelectedOrder value)? setSelectedOrder, + TResult Function(_GetById value)? getById, + TResult Function(_Fetched value)? fetched, + required TResult orElse(), + }) { + if (getById != null) { + return getById(this); + } + return orElse(); + } +} + +abstract class _GetById implements OrderLoaderEvent { + const factory _GetById(final String id) = _$GetByIdImpl; + + String get id; + + /// Create a copy of OrderLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$GetByIdImplCopyWith<_$GetByIdImpl> get copyWith => + throw _privateConstructorUsedError; +} + /// @nodoc abstract class _$$FetchedImplCopyWith<$Res> { factory _$$FetchedImplCopyWith( @@ -668,6 +854,7 @@ class _$FetchedImpl implements _Fetched { dateTimeRangeChange, required TResult Function(String search) searchChange, required TResult Function(Order order) setSelectedOrder, + required TResult Function(String id) getById, required TResult Function(bool isRefresh, String status) fetched, }) { return fetched(isRefresh, status); @@ -680,6 +867,7 @@ class _$FetchedImpl implements _Fetched { dateTimeRangeChange, TResult? Function(String search)? searchChange, TResult? Function(Order order)? setSelectedOrder, + TResult? Function(String id)? getById, TResult? Function(bool isRefresh, String status)? fetched, }) { return fetched?.call(isRefresh, status); @@ -691,6 +879,7 @@ class _$FetchedImpl implements _Fetched { TResult Function(DateTime startDate, DateTime endDate)? dateTimeRangeChange, TResult Function(String search)? searchChange, TResult Function(Order order)? setSelectedOrder, + TResult Function(String id)? getById, TResult Function(bool isRefresh, String status)? fetched, required TResult orElse(), }) { @@ -706,6 +895,7 @@ class _$FetchedImpl implements _Fetched { required TResult Function(_DateTimeRangeChange value) dateTimeRangeChange, required TResult Function(_SearchChange value) searchChange, required TResult Function(_SetSelectedOrder value) setSelectedOrder, + required TResult Function(_GetById value) getById, required TResult Function(_Fetched value) fetched, }) { return fetched(this); @@ -717,6 +907,7 @@ class _$FetchedImpl implements _Fetched { TResult? Function(_DateTimeRangeChange value)? dateTimeRangeChange, TResult? Function(_SearchChange value)? searchChange, TResult? Function(_SetSelectedOrder value)? setSelectedOrder, + TResult? Function(_GetById value)? getById, TResult? Function(_Fetched value)? fetched, }) { return fetched?.call(this); @@ -728,6 +919,7 @@ class _$FetchedImpl implements _Fetched { TResult Function(_DateTimeRangeChange value)? dateTimeRangeChange, TResult Function(_SearchChange value)? searchChange, TResult Function(_SetSelectedOrder value)? setSelectedOrder, + TResult Function(_GetById value)? getById, TResult Function(_Fetched value)? fetched, required TResult orElse(), }) { @@ -756,11 +948,15 @@ abstract class _Fetched implements OrderLoaderEvent { mixin _$OrderLoaderState { List get orders => throw _privateConstructorUsedError; Option get failureOption => throw _privateConstructorUsedError; + Option get failureOptionGetById => + throw _privateConstructorUsedError; + Order get order => throw _privateConstructorUsedError; Order? get selectedOrder => throw _privateConstructorUsedError; String? get search => throw _privateConstructorUsedError; DateTime get startDate => throw _privateConstructorUsedError; DateTime get endDate => throw _privateConstructorUsedError; bool get isFetching => throw _privateConstructorUsedError; + bool get isFetchingById => throw _privateConstructorUsedError; bool get hasReachedMax => throw _privateConstructorUsedError; int get page => throw _privateConstructorUsedError; @@ -781,15 +977,19 @@ abstract class $OrderLoaderStateCopyWith<$Res> { $Res call({ List orders, Option failureOption, + Option failureOptionGetById, + Order order, Order? selectedOrder, String? search, DateTime startDate, DateTime endDate, bool isFetching, + bool isFetchingById, bool hasReachedMax, int page, }); + $OrderCopyWith<$Res> get order; $OrderCopyWith<$Res>? get selectedOrder; } @@ -810,11 +1010,14 @@ class _$OrderLoaderStateCopyWithImpl<$Res, $Val extends OrderLoaderState> $Res call({ Object? orders = null, Object? failureOption = null, + Object? failureOptionGetById = null, + Object? order = null, Object? selectedOrder = freezed, Object? search = freezed, Object? startDate = null, Object? endDate = null, Object? isFetching = null, + Object? isFetchingById = null, Object? hasReachedMax = null, Object? page = null, }) { @@ -828,6 +1031,14 @@ class _$OrderLoaderStateCopyWithImpl<$Res, $Val extends OrderLoaderState> ? _value.failureOption : failureOption // ignore: cast_nullable_to_non_nullable as Option, + failureOptionGetById: null == failureOptionGetById + ? _value.failureOptionGetById + : failureOptionGetById // ignore: cast_nullable_to_non_nullable + as Option, + order: null == order + ? _value.order + : order // ignore: cast_nullable_to_non_nullable + as Order, selectedOrder: freezed == selectedOrder ? _value.selectedOrder : selectedOrder // ignore: cast_nullable_to_non_nullable @@ -848,6 +1059,10 @@ class _$OrderLoaderStateCopyWithImpl<$Res, $Val extends OrderLoaderState> ? _value.isFetching : isFetching // ignore: cast_nullable_to_non_nullable as bool, + isFetchingById: null == isFetchingById + ? _value.isFetchingById + : isFetchingById // ignore: cast_nullable_to_non_nullable + as bool, hasReachedMax: null == hasReachedMax ? _value.hasReachedMax : hasReachedMax // ignore: cast_nullable_to_non_nullable @@ -861,6 +1076,16 @@ class _$OrderLoaderStateCopyWithImpl<$Res, $Val extends OrderLoaderState> ); } + /// Create a copy of OrderLoaderState + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $OrderCopyWith<$Res> get order { + return $OrderCopyWith<$Res>(_value.order, (value) { + return _then(_value.copyWith(order: value) as $Val); + }); + } + /// Create a copy of OrderLoaderState /// with the given fields replaced by the non-null parameter values. @override @@ -888,15 +1113,20 @@ abstract class _$$OrderLoaderStateImplCopyWith<$Res> $Res call({ List orders, Option failureOption, + Option failureOptionGetById, + Order order, Order? selectedOrder, String? search, DateTime startDate, DateTime endDate, bool isFetching, + bool isFetchingById, bool hasReachedMax, int page, }); + @override + $OrderCopyWith<$Res> get order; @override $OrderCopyWith<$Res>? get selectedOrder; } @@ -917,11 +1147,14 @@ class __$$OrderLoaderStateImplCopyWithImpl<$Res> $Res call({ Object? orders = null, Object? failureOption = null, + Object? failureOptionGetById = null, + Object? order = null, Object? selectedOrder = freezed, Object? search = freezed, Object? startDate = null, Object? endDate = null, Object? isFetching = null, + Object? isFetchingById = null, Object? hasReachedMax = null, Object? page = null, }) { @@ -935,6 +1168,14 @@ class __$$OrderLoaderStateImplCopyWithImpl<$Res> ? _value.failureOption : failureOption // ignore: cast_nullable_to_non_nullable as Option, + failureOptionGetById: null == failureOptionGetById + ? _value.failureOptionGetById + : failureOptionGetById // ignore: cast_nullable_to_non_nullable + as Option, + order: null == order + ? _value.order + : order // ignore: cast_nullable_to_non_nullable + as Order, selectedOrder: freezed == selectedOrder ? _value.selectedOrder : selectedOrder // ignore: cast_nullable_to_non_nullable @@ -955,6 +1196,10 @@ class __$$OrderLoaderStateImplCopyWithImpl<$Res> ? _value.isFetching : isFetching // ignore: cast_nullable_to_non_nullable as bool, + isFetchingById: null == isFetchingById + ? _value.isFetchingById + : isFetchingById // ignore: cast_nullable_to_non_nullable + as bool, hasReachedMax: null == hasReachedMax ? _value.hasReachedMax : hasReachedMax // ignore: cast_nullable_to_non_nullable @@ -974,11 +1219,14 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState { _$OrderLoaderStateImpl({ required final List orders, required this.failureOption, + required this.failureOptionGetById, + required this.order, this.selectedOrder, this.search, required this.startDate, required this.endDate, this.isFetching = false, + this.isFetchingById = false, this.hasReachedMax = false, this.page = 1, }) : _orders = orders; @@ -994,6 +1242,10 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState { @override final Option failureOption; @override + final Option failureOptionGetById; + @override + final Order order; + @override final Order? selectedOrder; @override final String? search; @@ -1006,6 +1258,9 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState { final bool isFetching; @override @JsonKey() + final bool isFetchingById; + @override + @JsonKey() final bool hasReachedMax; @override @JsonKey() @@ -1013,7 +1268,7 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState { @override String toString() { - return 'OrderLoaderState(orders: $orders, failureOption: $failureOption, selectedOrder: $selectedOrder, search: $search, startDate: $startDate, endDate: $endDate, isFetching: $isFetching, hasReachedMax: $hasReachedMax, page: $page)'; + return 'OrderLoaderState(orders: $orders, failureOption: $failureOption, failureOptionGetById: $failureOptionGetById, order: $order, selectedOrder: $selectedOrder, search: $search, startDate: $startDate, endDate: $endDate, isFetching: $isFetching, isFetchingById: $isFetchingById, hasReachedMax: $hasReachedMax, page: $page)'; } @override @@ -1024,6 +1279,9 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState { const DeepCollectionEquality().equals(other._orders, _orders) && (identical(other.failureOption, failureOption) || other.failureOption == failureOption) && + (identical(other.failureOptionGetById, failureOptionGetById) || + other.failureOptionGetById == failureOptionGetById) && + (identical(other.order, order) || other.order == order) && (identical(other.selectedOrder, selectedOrder) || other.selectedOrder == selectedOrder) && (identical(other.search, search) || other.search == search) && @@ -1032,6 +1290,8 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState { (identical(other.endDate, endDate) || other.endDate == endDate) && (identical(other.isFetching, isFetching) || other.isFetching == isFetching) && + (identical(other.isFetchingById, isFetchingById) || + other.isFetchingById == isFetchingById) && (identical(other.hasReachedMax, hasReachedMax) || other.hasReachedMax == hasReachedMax) && (identical(other.page, page) || other.page == page)); @@ -1042,11 +1302,14 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState { runtimeType, const DeepCollectionEquality().hash(_orders), failureOption, + failureOptionGetById, + order, selectedOrder, search, startDate, endDate, isFetching, + isFetchingById, hasReachedMax, page, ); @@ -1067,11 +1330,14 @@ abstract class _OrderLoaderState implements OrderLoaderState { factory _OrderLoaderState({ required final List orders, required final Option failureOption, + required final Option failureOptionGetById, + required final Order order, final Order? selectedOrder, final String? search, required final DateTime startDate, required final DateTime endDate, final bool isFetching, + final bool isFetchingById, final bool hasReachedMax, final int page, }) = _$OrderLoaderStateImpl; @@ -1081,6 +1347,10 @@ abstract class _OrderLoaderState implements OrderLoaderState { @override Option get failureOption; @override + Option get failureOptionGetById; + @override + Order get order; + @override Order? get selectedOrder; @override String? get search; @@ -1091,6 +1361,8 @@ abstract class _OrderLoaderState implements OrderLoaderState { @override bool get isFetching; @override + bool get isFetchingById; + @override bool get hasReachedMax; @override int get page; diff --git a/lib/application/order/order_loader/order_loader_event.dart b/lib/application/order/order_loader/order_loader_event.dart index 1c7f2fb..a5bb3c3 100644 --- a/lib/application/order/order_loader/order_loader_event.dart +++ b/lib/application/order/order_loader/order_loader_event.dart @@ -9,6 +9,7 @@ class OrderLoaderEvent with _$OrderLoaderEvent { const factory OrderLoaderEvent.searchChange(String search) = _SearchChange; const factory OrderLoaderEvent.setSelectedOrder(Order order) = _SetSelectedOrder; + const factory OrderLoaderEvent.getById(String id) = _GetById; const factory OrderLoaderEvent.fetched({ @Default(false) bool isRefresh, required String status, diff --git a/lib/application/order/order_loader/order_loader_state.dart b/lib/application/order/order_loader/order_loader_state.dart index de8a27c..3bb0a05 100644 --- a/lib/application/order/order_loader/order_loader_state.dart +++ b/lib/application/order/order_loader/order_loader_state.dart @@ -5,11 +5,14 @@ class OrderLoaderState with _$OrderLoaderState { factory OrderLoaderState({ required List orders, required Option failureOption, + required Option failureOptionGetById, + required Order order, Order? selectedOrder, String? search, required DateTime startDate, required DateTime endDate, @Default(false) bool isFetching, + @Default(false) bool isFetchingById, @Default(false) bool hasReachedMax, @Default(1) int page, }) = _OrderLoaderState; @@ -19,5 +22,7 @@ class OrderLoaderState with _$OrderLoaderState { failureOption: none(), startDate: DateTime.now(), endDate: DateTime.now(), + failureOptionGetById: none(), + order: Order.empty(), ); } diff --git a/lib/domain/order/repositories/i_order_repository.dart b/lib/domain/order/repositories/i_order_repository.dart index e420987..558b96e 100644 --- a/lib/domain/order/repositories/i_order_repository.dart +++ b/lib/domain/order/repositories/i_order_repository.dart @@ -10,6 +10,8 @@ abstract class IOrderRepository { String? search, }); + Future> getOrderById(String id); + Future> createOrder({ required OrderRequest request, }); diff --git a/lib/infrastructure/order/datasources/remote_data_provider.dart b/lib/infrastructure/order/datasources/remote_data_provider.dart index 00c04a4..bb202fd 100644 --- a/lib/infrastructure/order/datasources/remote_data_provider.dart +++ b/lib/infrastructure/order/datasources/remote_data_provider.dart @@ -59,6 +59,28 @@ class OrderRemoteDataProvider { } } + Future> fetchOrderById(String id) async { + try { + final response = await _apiClient.get( + '${ApiPath.orders}/$id', + headers: getAuthorizationHeader(), + ); + + if (response.data['success'] == false) { + return DC.error(OrderFailure.unexpectedError()); + } + + final order = OrderDto.fromJson( + response.data['data'] as Map, + ); + + return DC.data(order); + } on ApiFailure catch (e, s) { + log('fetchOrderByIdError', name: _logName, error: e, stackTrace: s); + return DC.error(OrderFailure.serverError(e)); + } + } + Future> storeOrder({ required OrderRequestDto request, }) async { diff --git a/lib/infrastructure/order/repositories/order_repository.dart b/lib/infrastructure/order/repositories/order_repository.dart index 6289719..1f112f9 100644 --- a/lib/infrastructure/order/repositories/order_repository.dart +++ b/lib/infrastructure/order/repositories/order_repository.dart @@ -88,4 +88,21 @@ class OrderRepository implements IOrderRepository { return left(const OrderFailure.unexpectedError()); } } + + @override + Future> getOrderById(String id) async { + try { + final result = await _dataProvider.fetchOrderById(id); + + if (result.hasError) { + return left(result.error!); + } + + final order = result.data!.toDomain(); + return right(order); + } catch (e) { + log('getOrderByIdError', name: _logName, error: e); + return left(const OrderFailure.unexpectedError()); + } + } } diff --git a/lib/presentation/pages/checkout/checkout_page.dart b/lib/presentation/pages/checkout/checkout_page.dart index f5228f4..16687c7 100644 --- a/lib/presentation/pages/checkout/checkout_page.dart +++ b/lib/presentation/pages/checkout/checkout_page.dart @@ -9,6 +9,7 @@ import '../../../common/theme/theme.dart'; import '../../../injection.dart'; import '../../components/spaces/space.dart'; import '../../components/toast/flushbar.dart'; +import '../../router/app_router.gr.dart'; import 'widgets/checkout_left_panel.dart'; import 'widgets/checkout_right_panel.dart'; @@ -26,7 +27,9 @@ class CheckoutPage extends StatelessWidget implements AutoRouteWrapper { either.fold((f) => AppFlushbar.showOrderFailureToast(context, f), ( order, ) { - if (context.mounted) {} + if (context.mounted) { + context.router.replace(SuccessOrderRoute(order: order)); + } }); }); }, diff --git a/lib/presentation/pages/order/pages/success_order/success_order_page.dart b/lib/presentation/pages/order/pages/success_order/success_order_page.dart new file mode 100644 index 0000000..417e9fa --- /dev/null +++ b/lib/presentation/pages/order/pages/success_order/success_order_page.dart @@ -0,0 +1,58 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import '../../../../../application/order/order_loader/order_loader_bloc.dart'; +import '../../../../../common/theme/theme.dart'; +import '../../../../../domain/order/order.dart'; +import '../../../../../injection.dart'; +import '../../../../components/loader/loader_with_text.dart'; +import '../../../../components/spaces/space.dart'; +import 'widgets/success_order_left_panel.dart'; +import 'widgets/success_order_right_panel.dart'; + +@RoutePage() +class SuccessOrderPage extends StatelessWidget implements AutoRouteWrapper { + final Order order; + const SuccessOrderPage({super.key, required this.order}); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColor.background, + body: SafeArea( + child: BlocBuilder( + builder: (context, state) { + if (state.isFetchingById) { + return const Center(child: LoaderWithText()); + } + + return Padding( + padding: const EdgeInsets.all(24.0), + child: Row( + children: [ + Expanded( + flex: 35, + child: SuccessOrderLeftPanel(order: state.order), + ), + SpaceWidth(16), + Expanded( + flex: 65, + child: SuccessOrderRightPanel(order: state.order), + ), + ], + ), + ); + }, + ), + ), + ); + } + + @override + Widget wrappedRoute(BuildContext context) => BlocProvider( + create: (context) => + getIt()..add(OrderLoaderEvent.getById(order.id)), + child: this, + ); +} diff --git a/lib/presentation/pages/order/pages/success_order/widgets/success_order_left_panel.dart b/lib/presentation/pages/order/pages/success_order/widgets/success_order_left_panel.dart new file mode 100644 index 0000000..a3f01ba --- /dev/null +++ b/lib/presentation/pages/order/pages/success_order/widgets/success_order_left_panel.dart @@ -0,0 +1,250 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; + +import '../../../../../../common/extension/extension.dart'; +import '../../../../../../common/theme/theme.dart'; +import '../../../../../../domain/order/order.dart'; +import '../../../../../components/button/button.dart'; +import '../../../../../components/spaces/space.dart'; +import '../../../../../router/app_router.gr.dart'; + +class SuccessOrderLeftPanel extends StatelessWidget { + final Order order; + const SuccessOrderLeftPanel({super.key, required this.order}); + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(24), + ), + child: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Column( + children: [ + Container( + width: double.infinity, + padding: const EdgeInsets.all(32.0), + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + AppColor.primary.withOpacity(0.1), + AppColor.primary.withOpacity(0.05), + ], + ), + borderRadius: const BorderRadius.vertical( + top: Radius.circular(24), + ), + ), + child: Column( + children: [ + Container( + padding: const EdgeInsets.all(20.0), + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + AppColor.primary, + AppColor.primary.withOpacity(0.8), + ], + ), + shape: BoxShape.circle, + boxShadow: [ + BoxShadow( + color: AppColor.primary.withOpacity(0.3), + blurRadius: 20, + offset: const Offset(0, 10), + ), + ], + ), + child: const Icon( + Icons.check_rounded, + size: 48, + color: Colors.white, + ), + ), + SpaceWidth(24), + Text( + 'Pesanan Berhasil!', + style: AppStyle.h4.copyWith( + fontWeight: FontWeight.bold, + color: AppColor.primary, + ), + ), + SpaceWidth(12), + Text( + 'Pesanan telah diterima dan\nsedang diproses', + style: AppStyle.md.copyWith( + color: AppColor.primary, + fontWeight: FontWeight.w500, + ), + textAlign: TextAlign.center, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(24.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Informasi Pesanan', + style: AppStyle.lg.copyWith( + fontWeight: FontWeight.bold, + ), + ), + SpaceHeight(24), + _buildInfoRow( + icon: Icons.person, + label: 'Pemesan', + value: order.metadata['customer_name'] ?? "-", + ), + if (order.payments.isNotEmpty) ...[ + const SpaceHeight(12), + _buildInfoRow( + icon: Icons.wallet_outlined, + label: 'Metode Pembayaran', + value: order.payments.first.paymentMethodName, + ), + ], + if (order.tableNumber != "") ...[ + const SpaceHeight(12), + _buildInfoRow( + icon: Icons.table_restaurant_outlined, + label: 'No. Meja', + value: order.tableNumber, + ), + ], + const SpaceHeight(12), + _buildInfoRow( + icon: Icons.access_time_rounded, + label: 'Waktu', + value: (order.createdAt).toFormattedDateTime(), + ), + ], + ), + ), + ], + ), + ), + ), + _buildBottomSection(context), + ], + ), + ); + } + + Widget _buildBottomSection(BuildContext context) { + return Container( + width: double.infinity, + padding: const EdgeInsets.all(24.0), + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [Colors.grey.shade50, Colors.white], + ), + borderRadius: const BorderRadius.vertical(bottom: Radius.circular(24)), + ), + child: Column( + children: [ + // Action Buttons with Modern Design + Row( + children: [ + Expanded( + child: AppElevatedButton.outlined( + onPressed: () => + context.router.replaceAll([const MainRoute()]), + label: "Kembali", + ), + ), + const SpaceWidth(16), + Expanded( + child: AppElevatedButton.filled( + onPressed: () { + // onPrintRecipt( + // context, + // order: widget.order, + // paymentMethod: widget.paymentMethod, + // nominalBayar: widget.paymentMethod == "Cash" + // ? widget.nominalBayar + // : widget.order.totalAmount ?? 0, + // kembalian: widget.nominalBayar - + // (widget.order.totalAmount ?? 0), + // productQuantity: widget.productQuantity, + // ); + // onPrint( + // context, + // productQuantity: widget.productQuantity, + // order: widget.order, + // ); + }, + label: 'Cetak Struk', + icon: Icon(Icons.print_rounded, color: AppColor.white), + ), + ), + ], + ), + ], + ), + ); + } + + Widget _buildInfoRow({ + required IconData icon, + required String label, + required String value, + Color? valueColor, + bool showBadge = false, + }) { + return Row( + children: [ + Icon(icon, size: 18, color: AppColor.primary), + const SizedBox(width: 12), + Expanded( + child: Text( + label, + style: AppStyle.md.copyWith(color: AppColor.textSecondary), + ), + ), + if (showBadge && valueColor != null) + Container( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), + decoration: BoxDecoration( + color: valueColor.withOpacity(0.1), + borderRadius: BorderRadius.circular(12), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon(Icons.check_circle, size: 14, color: valueColor), + const SizedBox(width: 4), + Text( + value, + style: AppStyle.sm.copyWith( + fontWeight: FontWeight.bold, + color: valueColor, + ), + ), + ], + ), + ) + else + Text( + value, + style: AppStyle.md.copyWith( + fontWeight: FontWeight.bold, + color: valueColor ?? AppColor.primary, + ), + ), + ], + ); + } +} diff --git a/lib/presentation/pages/order/pages/success_order/widgets/success_order_right_panel.dart b/lib/presentation/pages/order/pages/success_order/widgets/success_order_right_panel.dart new file mode 100644 index 0000000..75ba8cb --- /dev/null +++ b/lib/presentation/pages/order/pages/success_order/widgets/success_order_right_panel.dart @@ -0,0 +1,352 @@ +import 'package:flutter/material.dart'; + +import '../../../../../../common/extension/extension.dart'; +import '../../../../../../common/theme/theme.dart'; +import '../../../../../../domain/order/order.dart'; +import '../../../../../components/spaces/space.dart'; + +class SuccessOrderRightPanel extends StatelessWidget { + final Order order; + const SuccessOrderRightPanel({super.key, required this.order}); + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(24), + ), + child: Column( + children: [ + _header(), + Expanded( + child: ListView.separated( + padding: const EdgeInsets.all(24.0), + itemCount: order.orderItems.length, + separatorBuilder: (context, index) => const SizedBox(height: 12), + itemBuilder: (context, index) { + return _buildProductCard(index); + }, + ), + ), + _buildSummaryFooter(), + ], + ), + ); + } + + Widget _buildSummaryFooter() { + return Container( + width: double.infinity, + padding: const EdgeInsets.all(24.0), + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [Colors.grey.shade50, Colors.white], + ), + borderRadius: const BorderRadius.vertical(bottom: Radius.circular(24)), + ), + child: Column( + children: [ + // Decorative Divider + Container( + height: 1, + margin: const EdgeInsets.only(bottom: 20), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + Colors.transparent, + AppColor.primary.withOpacity(0.3), + Colors.transparent, + ], + ), + ), + ), + + // Subtotal Row + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Icon( + Icons.shopping_cart_outlined, + size: 16, + color: AppColor.textSecondary, + ), + const SizedBox(width: 8), + Text( + 'Subtotal (${order.orderItems.length} items)', + style: AppStyle.md.copyWith( + color: AppColor.textSecondary, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + Text( + (order.totalAmount).toString().currencyFormatRpV2, + style: AppStyle.md.copyWith(fontWeight: FontWeight.w600), + ), + ], + ), + + const SpaceHeight(16), + + // Total Payment Row with Enhanced Styling + Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + AppColor.primary.withOpacity(0.1), + AppColor.primary.withOpacity(0.05), + ], + ), + borderRadius: BorderRadius.circular(12), + border: Border.all( + color: AppColor.primary.withOpacity(0.2), + width: 1, + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Container( + padding: const EdgeInsets.all(6), + decoration: BoxDecoration( + color: AppColor.primary.withOpacity(0.2), + borderRadius: BorderRadius.circular(8), + ), + child: Icon( + Icons.payments_rounded, + size: 16, + color: AppColor.primary, + ), + ), + SpaceWidth(12), + Text( + 'Total Pembayaran', + style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold), + ), + ], + ), + Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 6, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + AppColor.primary, + AppColor.primary.withOpacity(0.8), + ], + ), + borderRadius: BorderRadius.circular(8), + boxShadow: [ + BoxShadow( + color: AppColor.primary.withOpacity(0.3), + blurRadius: 4, + offset: const Offset(0, 2), + ), + ], + ), + child: Text( + (order.totalAmount).toString().currencyFormatRpV2, + style: AppStyle.xl.copyWith( + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), + ), + ], + ), + ), + ], + ), + ); + } + + Widget _buildProductCard(int index) { + final item = order.orderItems[index]; + + return Container( + padding: const EdgeInsets.all(16.0), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16.0), + border: Border.all(color: AppColor.border, width: 1), + ), + child: Row( + children: [ + // Enhanced Product Image + Container( + width: 70, + height: 70, + decoration: BoxDecoration( + color: AppColor.primaryWithOpacity(0.1), + borderRadius: BorderRadius.circular(16.0), + ), + child: Icon( + Icons.restaurant_rounded, + color: AppColor.primary, + size: 28, + ), + ), + + const SpaceWidth(16), + + // Product Details + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + item.productName, + style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold), + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + const SpaceHeight(6), + Container( + padding: const EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + decoration: BoxDecoration( + color: Colors.grey.shade100, + borderRadius: BorderRadius.circular(8), + ), + child: Text( + item.unitPrice.currencyFormatRpV2, + style: AppStyle.md.copyWith( + color: AppColor.textSecondary, + fontWeight: FontWeight.w500, + ), + ), + ), + ], + ), + ), + + const SpaceWidth(16), + + // Quantity and Total + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + AppColor.primary, + AppColor.primary.withOpacity(0.8), + ], + ), + borderRadius: BorderRadius.circular(12), + ), + child: Text( + '${item.quantity}x', + style: AppStyle.md.copyWith( + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), + ), + const SpaceHeight(8), + Text( + item.totalPrice.toString().currencyFormatRpV2, + style: AppStyle.lg.copyWith( + fontWeight: FontWeight.bold, + color: AppColor.primary, + ), + ), + ], + ), + ], + ), + ); + } + + Container _header() { + return Container( + width: double.infinity, + padding: const EdgeInsets.all(24.0), + decoration: BoxDecoration( + border: Border(bottom: BorderSide(color: AppColor.border)), + borderRadius: const BorderRadius.vertical(top: Radius.circular(24)), + ), + child: Row( + children: [ + Container( + padding: const EdgeInsets.all(12.0), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + AppColor.primary.withOpacity(0.2), + AppColor.primary.withOpacity(0.1), + ], + ), + borderRadius: BorderRadius.circular(16.0), + ), + child: Icon( + Icons.receipt_long_rounded, + color: AppColor.primary, + size: 28, + ), + ), + SpaceWidth(16), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Detail Pesanan', + style: AppStyle.xxl.copyWith(fontWeight: FontWeight.bold), + ), + SpaceHeight(4), + Text( + 'Ringkasan item yang dipesan', + style: AppStyle.md.copyWith(color: Colors.grey.shade600), + ), + ], + ), + ), + Container( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [AppColor.primary, AppColor.primary.withOpacity(0.8)], + ), + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: AppColor.primary.withOpacity(0.3), + blurRadius: 8, + offset: const Offset(0, 4), + ), + ], + ), + child: Text( + '${order.orderItems.length} Items', + style: const TextStyle( + fontSize: 13, + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/presentation/router/app_router.dart b/lib/presentation/router/app_router.dart index cfda196..ea153ac 100644 --- a/lib/presentation/router/app_router.dart +++ b/lib/presentation/router/app_router.dart @@ -31,5 +31,6 @@ class AppRouter extends RootStackRouter { // Order AutoRoute(page: OrderRoute.page), + AutoRoute(page: SuccessOrderRoute.page), ]; } diff --git a/lib/presentation/router/app_router.gr.dart b/lib/presentation/router/app_router.gr.dart index 68d0176..93a191c 100644 --- a/lib/presentation/router/app_router.gr.dart +++ b/lib/presentation/router/app_router.gr.dart @@ -9,6 +9,7 @@ // coverage:ignore-file // ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:apskel_pos_flutter_v2/domain/order/order.dart' as _i15; import 'package:apskel_pos_flutter_v2/presentation/pages/auth/login/login_page.dart' as _i4; import 'package:apskel_pos_flutter_v2/presentation/pages/checkout/checkout_page.dart' @@ -24,89 +25,91 @@ import 'package:apskel_pos_flutter_v2/presentation/pages/main/pages/report/repor import 'package:apskel_pos_flutter_v2/presentation/pages/main/pages/setting/setting_page.dart' as _i8; import 'package:apskel_pos_flutter_v2/presentation/pages/main/pages/table/table_page.dart' - as _i11; + as _i12; import 'package:apskel_pos_flutter_v2/presentation/pages/order/order_page.dart' as _i6; +import 'package:apskel_pos_flutter_v2/presentation/pages/order/pages/success_order/success_order_page.dart' + as _i10; import 'package:apskel_pos_flutter_v2/presentation/pages/splash/splash_page.dart' as _i9; import 'package:apskel_pos_flutter_v2/presentation/pages/sync/sync_page.dart' - as _i10; -import 'package:auto_route/auto_route.dart' as _i12; -import 'package:flutter/material.dart' as _i13; + as _i11; +import 'package:auto_route/auto_route.dart' as _i13; +import 'package:flutter/material.dart' as _i14; /// generated route for /// [_i1.CheckoutPage] -class CheckoutRoute extends _i12.PageRouteInfo { - const CheckoutRoute({List<_i12.PageRouteInfo>? children}) +class CheckoutRoute extends _i13.PageRouteInfo { + const CheckoutRoute({List<_i13.PageRouteInfo>? children}) : super(CheckoutRoute.name, initialChildren: children); static const String name = 'CheckoutRoute'; - static _i12.PageInfo page = _i12.PageInfo( + static _i13.PageInfo page = _i13.PageInfo( name, builder: (data) { - return _i12.WrappedRoute(child: const _i1.CheckoutPage()); + return _i13.WrappedRoute(child: const _i1.CheckoutPage()); }, ); } /// generated route for /// [_i2.CustomerPage] -class CustomerRoute extends _i12.PageRouteInfo { - const CustomerRoute({List<_i12.PageRouteInfo>? children}) +class CustomerRoute extends _i13.PageRouteInfo { + const CustomerRoute({List<_i13.PageRouteInfo>? children}) : super(CustomerRoute.name, initialChildren: children); static const String name = 'CustomerRoute'; - static _i12.PageInfo page = _i12.PageInfo( + static _i13.PageInfo page = _i13.PageInfo( name, builder: (data) { - return _i12.WrappedRoute(child: const _i2.CustomerPage()); + return _i13.WrappedRoute(child: const _i2.CustomerPage()); }, ); } /// generated route for /// [_i3.HomePage] -class HomeRoute extends _i12.PageRouteInfo { - const HomeRoute({List<_i12.PageRouteInfo>? children}) +class HomeRoute extends _i13.PageRouteInfo { + const HomeRoute({List<_i13.PageRouteInfo>? children}) : super(HomeRoute.name, initialChildren: children); static const String name = 'HomeRoute'; - static _i12.PageInfo page = _i12.PageInfo( + static _i13.PageInfo page = _i13.PageInfo( name, builder: (data) { - return _i12.WrappedRoute(child: const _i3.HomePage()); + return _i13.WrappedRoute(child: const _i3.HomePage()); }, ); } /// generated route for /// [_i4.LoginPage] -class LoginRoute extends _i12.PageRouteInfo { - const LoginRoute({List<_i12.PageRouteInfo>? children}) +class LoginRoute extends _i13.PageRouteInfo { + const LoginRoute({List<_i13.PageRouteInfo>? children}) : super(LoginRoute.name, initialChildren: children); static const String name = 'LoginRoute'; - static _i12.PageInfo page = _i12.PageInfo( + static _i13.PageInfo page = _i13.PageInfo( name, builder: (data) { - return _i12.WrappedRoute(child: const _i4.LoginPage()); + return _i13.WrappedRoute(child: const _i4.LoginPage()); }, ); } /// generated route for /// [_i5.MainPage] -class MainRoute extends _i12.PageRouteInfo { - const MainRoute({List<_i12.PageRouteInfo>? children}) +class MainRoute extends _i13.PageRouteInfo { + const MainRoute({List<_i13.PageRouteInfo>? children}) : super(MainRoute.name, initialChildren: children); static const String name = 'MainRoute'; - static _i12.PageInfo page = _i12.PageInfo( + static _i13.PageInfo page = _i13.PageInfo( name, builder: (data) { return const _i5.MainPage(); @@ -116,11 +119,11 @@ class MainRoute extends _i12.PageRouteInfo { /// generated route for /// [_i6.OrderPage] -class OrderRoute extends _i12.PageRouteInfo { +class OrderRoute extends _i13.PageRouteInfo { OrderRoute({ - _i13.Key? key, + _i14.Key? key, required String status, - List<_i12.PageRouteInfo>? children, + List<_i13.PageRouteInfo>? children, }) : super( OrderRoute.name, args: OrderRouteArgs(key: key, status: status), @@ -129,11 +132,11 @@ class OrderRoute extends _i12.PageRouteInfo { static const String name = 'OrderRoute'; - static _i12.PageInfo page = _i12.PageInfo( + static _i13.PageInfo page = _i13.PageInfo( name, builder: (data) { final args = data.argsAs(); - return _i12.WrappedRoute( + return _i13.WrappedRoute( child: _i6.OrderPage(key: args.key, status: args.status), ); }, @@ -143,7 +146,7 @@ class OrderRoute extends _i12.PageRouteInfo { class OrderRouteArgs { const OrderRouteArgs({this.key, required this.status}); - final _i13.Key? key; + final _i14.Key? key; final String status; @@ -155,13 +158,13 @@ class OrderRouteArgs { /// generated route for /// [_i7.ReportPage] -class ReportRoute extends _i12.PageRouteInfo { - const ReportRoute({List<_i12.PageRouteInfo>? children}) +class ReportRoute extends _i13.PageRouteInfo { + const ReportRoute({List<_i13.PageRouteInfo>? children}) : super(ReportRoute.name, initialChildren: children); static const String name = 'ReportRoute'; - static _i12.PageInfo page = _i12.PageInfo( + static _i13.PageInfo page = _i13.PageInfo( name, builder: (data) { return const _i7.ReportPage(); @@ -171,13 +174,13 @@ class ReportRoute extends _i12.PageRouteInfo { /// generated route for /// [_i8.SettingPage] -class SettingRoute extends _i12.PageRouteInfo { - const SettingRoute({List<_i12.PageRouteInfo>? children}) +class SettingRoute extends _i13.PageRouteInfo { + const SettingRoute({List<_i13.PageRouteInfo>? children}) : super(SettingRoute.name, initialChildren: children); static const String name = 'SettingRoute'; - static _i12.PageInfo page = _i12.PageInfo( + static _i13.PageInfo page = _i13.PageInfo( name, builder: (data) { return const _i8.SettingPage(); @@ -187,13 +190,13 @@ class SettingRoute extends _i12.PageRouteInfo { /// generated route for /// [_i9.SplashPage] -class SplashRoute extends _i12.PageRouteInfo { - const SplashRoute({List<_i12.PageRouteInfo>? children}) +class SplashRoute extends _i13.PageRouteInfo { + const SplashRoute({List<_i13.PageRouteInfo>? children}) : super(SplashRoute.name, initialChildren: children); static const String name = 'SplashRoute'; - static _i12.PageInfo page = _i12.PageInfo( + static _i13.PageInfo page = _i13.PageInfo( name, builder: (data) { return const _i9.SplashPage(); @@ -202,33 +205,72 @@ class SplashRoute extends _i12.PageRouteInfo { } /// generated route for -/// [_i10.SyncPage] -class SyncRoute extends _i12.PageRouteInfo { - const SyncRoute({List<_i12.PageRouteInfo>? children}) +/// [_i10.SuccessOrderPage] +class SuccessOrderRoute extends _i13.PageRouteInfo { + SuccessOrderRoute({ + _i14.Key? key, + required _i15.Order order, + List<_i13.PageRouteInfo>? children, + }) : super( + SuccessOrderRoute.name, + args: SuccessOrderRouteArgs(key: key, order: order), + initialChildren: children, + ); + + static const String name = 'SuccessOrderRoute'; + + static _i13.PageInfo page = _i13.PageInfo( + name, + builder: (data) { + final args = data.argsAs(); + return _i13.WrappedRoute( + child: _i10.SuccessOrderPage(key: args.key, order: args.order), + ); + }, + ); +} + +class SuccessOrderRouteArgs { + const SuccessOrderRouteArgs({this.key, required this.order}); + + final _i14.Key? key; + + final _i15.Order order; + + @override + String toString() { + return 'SuccessOrderRouteArgs{key: $key, order: $order}'; + } +} + +/// generated route for +/// [_i11.SyncPage] +class SyncRoute extends _i13.PageRouteInfo { + const SyncRoute({List<_i13.PageRouteInfo>? children}) : super(SyncRoute.name, initialChildren: children); static const String name = 'SyncRoute'; - static _i12.PageInfo page = _i12.PageInfo( + static _i13.PageInfo page = _i13.PageInfo( name, builder: (data) { - return _i12.WrappedRoute(child: const _i10.SyncPage()); + return _i13.WrappedRoute(child: const _i11.SyncPage()); }, ); } /// generated route for -/// [_i11.TablePage] -class TableRoute extends _i12.PageRouteInfo { - const TableRoute({List<_i12.PageRouteInfo>? children}) +/// [_i12.TablePage] +class TableRoute extends _i13.PageRouteInfo { + const TableRoute({List<_i13.PageRouteInfo>? children}) : super(TableRoute.name, initialChildren: children); static const String name = 'TableRoute'; - static _i12.PageInfo page = _i12.PageInfo( + static _i13.PageInfo page = _i13.PageInfo( name, builder: (data) { - return _i12.WrappedRoute(child: const _i11.TablePage()); + return _i13.WrappedRoute(child: const _i12.TablePage()); }, ); }