From 8bd61eb58eac4d2d1625941778a14a0b69a8b208 Mon Sep 17 00:00:00 2001 From: efrilm Date: Mon, 27 Oct 2025 21:55:19 +0700 Subject: [PATCH] order page --- .../order/order_loader/order_loader_bloc.dart | 98 + .../order_loader_bloc.freezed.dart | 1104 +++++++ .../order_loader/order_loader_event.dart | 16 + .../order_loader/order_loader_state.dart | 23 + lib/common/extension/datetime_extension.dart | 65 + lib/common/extension/extension.dart | 1 + lib/common/url/api_path.dart | 1 + lib/domain/order/entities/order_entity.dart | 154 + lib/domain/order/failures/order_failure.dart | 12 + lib/domain/order/order.dart | 10 + lib/domain/order/order.freezed.dart | 2705 +++++++++++++++++ .../repositories/i_order_repository.dart | 12 + .../datasources/remote_data_provider.dart | 61 + lib/infrastructure/order/dtos/order_dto.dart | 182 ++ lib/infrastructure/order/order_dtos.dart | 8 + .../order/order_dtos.freezed.dart | 2165 +++++++++++++ lib/infrastructure/order/order_dtos.g.dart | 169 + .../order/repositories/order_repository.dart | 46 + lib/injection.config.dart | 16 + lib/presentation/app_widget.dart | 2 + .../components/card/order_card.dart | 207 ++ .../order_loader_error_state_widget.dart | 67 + .../components/field/text_field.dart | 1 + .../components/page/page_title.dart | 88 +- .../components/picker/date_range_picker.dart | 411 +++ .../pages/home/widgets/home_right_title.dart | 6 +- lib/presentation/pages/order/order_page.dart | 71 + .../order/widgets/order_information.dart | 130 + .../pages/order/widgets/order_left_panel.dart | 71 + .../pages/order/widgets/order_list.dart | 357 +++ .../order/widgets/order_list_payment.dart | 166 + .../order/widgets/order_payment_summary.dart | 88 + .../order/widgets/order_right_panel.dart | 114 + .../pages/order/widgets/order_title.dart | 93 + lib/presentation/router/app_router.dart | 3 + lib/presentation/router/app_router.gr.dart | 142 +- pubspec.lock | 18 +- pubspec.yaml | 1 + 38 files changed, 8795 insertions(+), 89 deletions(-) create mode 100644 lib/application/order/order_loader/order_loader_bloc.dart create mode 100644 lib/application/order/order_loader/order_loader_bloc.freezed.dart create mode 100644 lib/application/order/order_loader/order_loader_event.dart create mode 100644 lib/application/order/order_loader/order_loader_state.dart create mode 100644 lib/common/extension/datetime_extension.dart create mode 100644 lib/domain/order/entities/order_entity.dart create mode 100644 lib/domain/order/failures/order_failure.dart create mode 100644 lib/domain/order/order.dart create mode 100644 lib/domain/order/order.freezed.dart create mode 100644 lib/domain/order/repositories/i_order_repository.dart create mode 100644 lib/infrastructure/order/datasources/remote_data_provider.dart create mode 100644 lib/infrastructure/order/dtos/order_dto.dart create mode 100644 lib/infrastructure/order/order_dtos.dart create mode 100644 lib/infrastructure/order/order_dtos.freezed.dart create mode 100644 lib/infrastructure/order/order_dtos.g.dart create mode 100644 lib/infrastructure/order/repositories/order_repository.dart create mode 100644 lib/presentation/components/card/order_card.dart create mode 100644 lib/presentation/components/error/order_loader_error_state_widget.dart create mode 100644 lib/presentation/components/picker/date_range_picker.dart create mode 100644 lib/presentation/pages/order/order_page.dart create mode 100644 lib/presentation/pages/order/widgets/order_information.dart create mode 100644 lib/presentation/pages/order/widgets/order_left_panel.dart create mode 100644 lib/presentation/pages/order/widgets/order_list.dart create mode 100644 lib/presentation/pages/order/widgets/order_list_payment.dart create mode 100644 lib/presentation/pages/order/widgets/order_payment_summary.dart create mode 100644 lib/presentation/pages/order/widgets/order_right_panel.dart create mode 100644 lib/presentation/pages/order/widgets/order_title.dart diff --git a/lib/application/order/order_loader/order_loader_bloc.dart b/lib/application/order/order_loader/order_loader_bloc.dart new file mode 100644 index 0000000..367fb9f --- /dev/null +++ b/lib/application/order/order_loader/order_loader_bloc.dart @@ -0,0 +1,98 @@ +import 'package:bloc/bloc.dart'; +import 'package:dartz/dartz.dart' hide Order; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:injectable/injectable.dart' hide Order; + +import '../../../domain/order/order.dart'; + +part 'order_loader_event.dart'; +part 'order_loader_state.dart'; +part 'order_loader_bloc.freezed.dart'; + +@injectable +class OrderLoaderBloc extends Bloc { + final IOrderRepository _repository; + OrderLoaderBloc(this._repository) : super(OrderLoaderState.initial()) { + on(_onOrderLoaderEvent); + } + + Future _onOrderLoaderEvent( + OrderLoaderEvent event, + Emitter emit, + ) { + return event.map( + setSelectedOrder: (e) async { + emit(state.copyWith(selectedOrder: e.order)); + }, + dateTimeRangeChange: (e) async { + emit(state.copyWith(startDate: e.startDate, endDate: e.endDate)); + }, + searchChange: (e) async { + emit(state.copyWith(search: e.search)); + }, + fetched: (e) async { + var newState = state; + + if (e.isRefresh) { + newState = newState.copyWith(isFetching: true); + emit(newState); + } + + newState = await _mapFetchedToState( + newState, + isRefresh: e.isRefresh, + status: e.status, + ); + emit(newState); + }, + ); + } + + Future _mapFetchedToState( + OrderLoaderState state, { + bool isRefresh = false, + String status = 'completed', + }) async { + state = state.copyWith(isFetching: false); + + if (state.hasReachedMax && state.orders.isNotEmpty && !isRefresh) { + return state; + } + + if (isRefresh) { + state = state.copyWith( + page: 1, + failureOption: none(), + hasReachedMax: false, + orders: [], + ); + } + + final failureOrTable = await _repository.getOrders( + page: state.page, + status: status, + startDate: state.startDate, + endDate: state.endDate, + search: state.search, + ); + + state = failureOrTable.fold( + (f) { + if (state.orders.isNotEmpty) { + return state.copyWith(hasReachedMax: true); + } + return state.copyWith(failureOption: optionOf(f)); + }, + (orders) { + return state.copyWith( + orders: List.from(state.orders)..addAll(orders.orders), + failureOption: none(), + page: state.page + 1, + hasReachedMax: orders.orders.length < 10, + ); + }, + ); + + return state; + } +} diff --git a/lib/application/order/order_loader/order_loader_bloc.freezed.dart b/lib/application/order/order_loader/order_loader_bloc.freezed.dart new file mode 100644 index 0000000..ae7a02e --- /dev/null +++ b/lib/application/order/order_loader/order_loader_bloc.freezed.dart @@ -0,0 +1,1104 @@ +// 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 'order_loader_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(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 _$OrderLoaderEvent { + @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(bool isRefresh, String status) fetched, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(DateTime startDate, DateTime endDate)? + dateTimeRangeChange, + TResult? Function(String search)? searchChange, + TResult? Function(Order order)? setSelectedOrder, + TResult? Function(bool isRefresh, String status)? fetched, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(DateTime startDate, DateTime endDate)? dateTimeRangeChange, + TResult Function(String search)? searchChange, + TResult Function(Order order)? setSelectedOrder, + TResult Function(bool isRefresh, String status)? fetched, + required TResult orElse(), + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(_DateTimeRangeChange value) dateTimeRangeChange, + required TResult Function(_SearchChange value) searchChange, + required TResult Function(_SetSelectedOrder value) setSelectedOrder, + required TResult Function(_Fetched value) fetched, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_DateTimeRangeChange value)? dateTimeRangeChange, + TResult? Function(_SearchChange value)? searchChange, + TResult? Function(_SetSelectedOrder value)? setSelectedOrder, + TResult? Function(_Fetched value)? fetched, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_DateTimeRangeChange value)? dateTimeRangeChange, + TResult Function(_SearchChange value)? searchChange, + TResult Function(_SetSelectedOrder value)? setSelectedOrder, + TResult Function(_Fetched value)? fetched, + required TResult orElse(), + }) => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OrderLoaderEventCopyWith<$Res> { + factory $OrderLoaderEventCopyWith( + OrderLoaderEvent value, + $Res Function(OrderLoaderEvent) then, + ) = _$OrderLoaderEventCopyWithImpl<$Res, OrderLoaderEvent>; +} + +/// @nodoc +class _$OrderLoaderEventCopyWithImpl<$Res, $Val extends OrderLoaderEvent> + implements $OrderLoaderEventCopyWith<$Res> { + _$OrderLoaderEventCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of OrderLoaderEvent + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$DateTimeRangeChangeImplCopyWith<$Res> { + factory _$$DateTimeRangeChangeImplCopyWith( + _$DateTimeRangeChangeImpl value, + $Res Function(_$DateTimeRangeChangeImpl) then, + ) = __$$DateTimeRangeChangeImplCopyWithImpl<$Res>; + @useResult + $Res call({DateTime startDate, DateTime endDate}); +} + +/// @nodoc +class __$$DateTimeRangeChangeImplCopyWithImpl<$Res> + extends _$OrderLoaderEventCopyWithImpl<$Res, _$DateTimeRangeChangeImpl> + implements _$$DateTimeRangeChangeImplCopyWith<$Res> { + __$$DateTimeRangeChangeImplCopyWithImpl( + _$DateTimeRangeChangeImpl _value, + $Res Function(_$DateTimeRangeChangeImpl) _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? startDate = null, Object? endDate = null}) { + return _then( + _$DateTimeRangeChangeImpl( + null == startDate + ? _value.startDate + : startDate // ignore: cast_nullable_to_non_nullable + as DateTime, + null == endDate + ? _value.endDate + : endDate // ignore: cast_nullable_to_non_nullable + as DateTime, + ), + ); + } +} + +/// @nodoc + +class _$DateTimeRangeChangeImpl implements _DateTimeRangeChange { + const _$DateTimeRangeChangeImpl(this.startDate, this.endDate); + + @override + final DateTime startDate; + @override + final DateTime endDate; + + @override + String toString() { + return 'OrderLoaderEvent.dateTimeRangeChange(startDate: $startDate, endDate: $endDate)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DateTimeRangeChangeImpl && + (identical(other.startDate, startDate) || + other.startDate == startDate) && + (identical(other.endDate, endDate) || other.endDate == endDate)); + } + + @override + int get hashCode => Object.hash(runtimeType, startDate, endDate); + + /// 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') + _$$DateTimeRangeChangeImplCopyWith<_$DateTimeRangeChangeImpl> get copyWith => + __$$DateTimeRangeChangeImplCopyWithImpl<_$DateTimeRangeChangeImpl>( + 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(bool isRefresh, String status) fetched, + }) { + return dateTimeRangeChange(startDate, endDate); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(DateTime startDate, DateTime endDate)? + dateTimeRangeChange, + TResult? Function(String search)? searchChange, + TResult? Function(Order order)? setSelectedOrder, + TResult? Function(bool isRefresh, String status)? fetched, + }) { + return dateTimeRangeChange?.call(startDate, endDate); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(DateTime startDate, DateTime endDate)? dateTimeRangeChange, + TResult Function(String search)? searchChange, + TResult Function(Order order)? setSelectedOrder, + TResult Function(bool isRefresh, String status)? fetched, + required TResult orElse(), + }) { + if (dateTimeRangeChange != null) { + return dateTimeRangeChange(startDate, endDate); + } + 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(_Fetched value) fetched, + }) { + return dateTimeRangeChange(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_DateTimeRangeChange value)? dateTimeRangeChange, + TResult? Function(_SearchChange value)? searchChange, + TResult? Function(_SetSelectedOrder value)? setSelectedOrder, + TResult? Function(_Fetched value)? fetched, + }) { + return dateTimeRangeChange?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_DateTimeRangeChange value)? dateTimeRangeChange, + TResult Function(_SearchChange value)? searchChange, + TResult Function(_SetSelectedOrder value)? setSelectedOrder, + TResult Function(_Fetched value)? fetched, + required TResult orElse(), + }) { + if (dateTimeRangeChange != null) { + return dateTimeRangeChange(this); + } + return orElse(); + } +} + +abstract class _DateTimeRangeChange implements OrderLoaderEvent { + const factory _DateTimeRangeChange( + final DateTime startDate, + final DateTime endDate, + ) = _$DateTimeRangeChangeImpl; + + DateTime get startDate; + DateTime get endDate; + + /// Create a copy of OrderLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DateTimeRangeChangeImplCopyWith<_$DateTimeRangeChangeImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$SearchChangeImplCopyWith<$Res> { + factory _$$SearchChangeImplCopyWith( + _$SearchChangeImpl value, + $Res Function(_$SearchChangeImpl) then, + ) = __$$SearchChangeImplCopyWithImpl<$Res>; + @useResult + $Res call({String search}); +} + +/// @nodoc +class __$$SearchChangeImplCopyWithImpl<$Res> + extends _$OrderLoaderEventCopyWithImpl<$Res, _$SearchChangeImpl> + implements _$$SearchChangeImplCopyWith<$Res> { + __$$SearchChangeImplCopyWithImpl( + _$SearchChangeImpl _value, + $Res Function(_$SearchChangeImpl) _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? search = null}) { + return _then( + _$SearchChangeImpl( + null == search + ? _value.search + : search // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$SearchChangeImpl implements _SearchChange { + const _$SearchChangeImpl(this.search); + + @override + final String search; + + @override + String toString() { + return 'OrderLoaderEvent.searchChange(search: $search)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SearchChangeImpl && + (identical(other.search, search) || other.search == search)); + } + + @override + int get hashCode => Object.hash(runtimeType, search); + + /// 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') + _$$SearchChangeImplCopyWith<_$SearchChangeImpl> get copyWith => + __$$SearchChangeImplCopyWithImpl<_$SearchChangeImpl>(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(bool isRefresh, String status) fetched, + }) { + return searchChange(search); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(DateTime startDate, DateTime endDate)? + dateTimeRangeChange, + TResult? Function(String search)? searchChange, + TResult? Function(Order order)? setSelectedOrder, + TResult? Function(bool isRefresh, String status)? fetched, + }) { + return searchChange?.call(search); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(DateTime startDate, DateTime endDate)? dateTimeRangeChange, + TResult Function(String search)? searchChange, + TResult Function(Order order)? setSelectedOrder, + TResult Function(bool isRefresh, String status)? fetched, + required TResult orElse(), + }) { + if (searchChange != null) { + return searchChange(search); + } + 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(_Fetched value) fetched, + }) { + return searchChange(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_DateTimeRangeChange value)? dateTimeRangeChange, + TResult? Function(_SearchChange value)? searchChange, + TResult? Function(_SetSelectedOrder value)? setSelectedOrder, + TResult? Function(_Fetched value)? fetched, + }) { + return searchChange?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_DateTimeRangeChange value)? dateTimeRangeChange, + TResult Function(_SearchChange value)? searchChange, + TResult Function(_SetSelectedOrder value)? setSelectedOrder, + TResult Function(_Fetched value)? fetched, + required TResult orElse(), + }) { + if (searchChange != null) { + return searchChange(this); + } + return orElse(); + } +} + +abstract class _SearchChange implements OrderLoaderEvent { + const factory _SearchChange(final String search) = _$SearchChangeImpl; + + String get search; + + /// Create a copy of OrderLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$SearchChangeImplCopyWith<_$SearchChangeImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$SetSelectedOrderImplCopyWith<$Res> { + factory _$$SetSelectedOrderImplCopyWith( + _$SetSelectedOrderImpl value, + $Res Function(_$SetSelectedOrderImpl) then, + ) = __$$SetSelectedOrderImplCopyWithImpl<$Res>; + @useResult + $Res call({Order order}); + + $OrderCopyWith<$Res> get order; +} + +/// @nodoc +class __$$SetSelectedOrderImplCopyWithImpl<$Res> + extends _$OrderLoaderEventCopyWithImpl<$Res, _$SetSelectedOrderImpl> + implements _$$SetSelectedOrderImplCopyWith<$Res> { + __$$SetSelectedOrderImplCopyWithImpl( + _$SetSelectedOrderImpl _value, + $Res Function(_$SetSelectedOrderImpl) _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? order = null}) { + return _then( + _$SetSelectedOrderImpl( + null == order + ? _value.order + : order // ignore: cast_nullable_to_non_nullable + as Order, + ), + ); + } + + /// Create a copy of OrderLoaderEvent + /// 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)); + }); + } +} + +/// @nodoc + +class _$SetSelectedOrderImpl implements _SetSelectedOrder { + const _$SetSelectedOrderImpl(this.order); + + @override + final Order order; + + @override + String toString() { + return 'OrderLoaderEvent.setSelectedOrder(order: $order)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SetSelectedOrderImpl && + (identical(other.order, order) || other.order == order)); + } + + @override + int get hashCode => Object.hash(runtimeType, order); + + /// 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') + _$$SetSelectedOrderImplCopyWith<_$SetSelectedOrderImpl> get copyWith => + __$$SetSelectedOrderImplCopyWithImpl<_$SetSelectedOrderImpl>( + 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(bool isRefresh, String status) fetched, + }) { + return setSelectedOrder(order); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(DateTime startDate, DateTime endDate)? + dateTimeRangeChange, + TResult? Function(String search)? searchChange, + TResult? Function(Order order)? setSelectedOrder, + TResult? Function(bool isRefresh, String status)? fetched, + }) { + return setSelectedOrder?.call(order); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(DateTime startDate, DateTime endDate)? dateTimeRangeChange, + TResult Function(String search)? searchChange, + TResult Function(Order order)? setSelectedOrder, + TResult Function(bool isRefresh, String status)? fetched, + required TResult orElse(), + }) { + if (setSelectedOrder != null) { + return setSelectedOrder(order); + } + 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(_Fetched value) fetched, + }) { + return setSelectedOrder(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_DateTimeRangeChange value)? dateTimeRangeChange, + TResult? Function(_SearchChange value)? searchChange, + TResult? Function(_SetSelectedOrder value)? setSelectedOrder, + TResult? Function(_Fetched value)? fetched, + }) { + return setSelectedOrder?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_DateTimeRangeChange value)? dateTimeRangeChange, + TResult Function(_SearchChange value)? searchChange, + TResult Function(_SetSelectedOrder value)? setSelectedOrder, + TResult Function(_Fetched value)? fetched, + required TResult orElse(), + }) { + if (setSelectedOrder != null) { + return setSelectedOrder(this); + } + return orElse(); + } +} + +abstract class _SetSelectedOrder implements OrderLoaderEvent { + const factory _SetSelectedOrder(final Order order) = _$SetSelectedOrderImpl; + + Order get order; + + /// Create a copy of OrderLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$SetSelectedOrderImplCopyWith<_$SetSelectedOrderImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$FetchedImplCopyWith<$Res> { + factory _$$FetchedImplCopyWith( + _$FetchedImpl value, + $Res Function(_$FetchedImpl) then, + ) = __$$FetchedImplCopyWithImpl<$Res>; + @useResult + $Res call({bool isRefresh, String status}); +} + +/// @nodoc +class __$$FetchedImplCopyWithImpl<$Res> + extends _$OrderLoaderEventCopyWithImpl<$Res, _$FetchedImpl> + implements _$$FetchedImplCopyWith<$Res> { + __$$FetchedImplCopyWithImpl( + _$FetchedImpl _value, + $Res Function(_$FetchedImpl) _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? isRefresh = null, Object? status = null}) { + return _then( + _$FetchedImpl( + isRefresh: null == isRefresh + ? _value.isRefresh + : isRefresh // ignore: cast_nullable_to_non_nullable + as bool, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$FetchedImpl implements _Fetched { + const _$FetchedImpl({this.isRefresh = false, required this.status}); + + @override + @JsonKey() + final bool isRefresh; + @override + final String status; + + @override + String toString() { + return 'OrderLoaderEvent.fetched(isRefresh: $isRefresh, status: $status)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$FetchedImpl && + (identical(other.isRefresh, isRefresh) || + other.isRefresh == isRefresh) && + (identical(other.status, status) || other.status == status)); + } + + @override + int get hashCode => Object.hash(runtimeType, isRefresh, status); + + /// 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') + _$$FetchedImplCopyWith<_$FetchedImpl> get copyWith => + __$$FetchedImplCopyWithImpl<_$FetchedImpl>(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(bool isRefresh, String status) fetched, + }) { + return fetched(isRefresh, status); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(DateTime startDate, DateTime endDate)? + dateTimeRangeChange, + TResult? Function(String search)? searchChange, + TResult? Function(Order order)? setSelectedOrder, + TResult? Function(bool isRefresh, String status)? fetched, + }) { + return fetched?.call(isRefresh, status); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(DateTime startDate, DateTime endDate)? dateTimeRangeChange, + TResult Function(String search)? searchChange, + TResult Function(Order order)? setSelectedOrder, + TResult Function(bool isRefresh, String status)? fetched, + required TResult orElse(), + }) { + if (fetched != null) { + return fetched(isRefresh, status); + } + 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(_Fetched value) fetched, + }) { + return fetched(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_DateTimeRangeChange value)? dateTimeRangeChange, + TResult? Function(_SearchChange value)? searchChange, + TResult? Function(_SetSelectedOrder value)? setSelectedOrder, + TResult? Function(_Fetched value)? fetched, + }) { + return fetched?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_DateTimeRangeChange value)? dateTimeRangeChange, + TResult Function(_SearchChange value)? searchChange, + TResult Function(_SetSelectedOrder value)? setSelectedOrder, + TResult Function(_Fetched value)? fetched, + required TResult orElse(), + }) { + if (fetched != null) { + return fetched(this); + } + return orElse(); + } +} + +abstract class _Fetched implements OrderLoaderEvent { + const factory _Fetched({final bool isRefresh, required final String status}) = + _$FetchedImpl; + + bool get isRefresh; + String get status; + + /// Create a copy of OrderLoaderEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$FetchedImplCopyWith<_$FetchedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$OrderLoaderState { + List get orders => throw _privateConstructorUsedError; + Option get failureOption => 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 hasReachedMax => throw _privateConstructorUsedError; + int get page => throw _privateConstructorUsedError; + + /// Create a copy of OrderLoaderState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $OrderLoaderStateCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OrderLoaderStateCopyWith<$Res> { + factory $OrderLoaderStateCopyWith( + OrderLoaderState value, + $Res Function(OrderLoaderState) then, + ) = _$OrderLoaderStateCopyWithImpl<$Res, OrderLoaderState>; + @useResult + $Res call({ + List orders, + Option failureOption, + Order? selectedOrder, + String? search, + DateTime startDate, + DateTime endDate, + bool isFetching, + bool hasReachedMax, + int page, + }); + + $OrderCopyWith<$Res>? get selectedOrder; +} + +/// @nodoc +class _$OrderLoaderStateCopyWithImpl<$Res, $Val extends OrderLoaderState> + implements $OrderLoaderStateCopyWith<$Res> { + _$OrderLoaderStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of OrderLoaderState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? orders = null, + Object? failureOption = null, + Object? selectedOrder = freezed, + Object? search = freezed, + Object? startDate = null, + Object? endDate = null, + Object? isFetching = null, + Object? hasReachedMax = null, + Object? page = null, + }) { + return _then( + _value.copyWith( + orders: null == orders + ? _value.orders + : orders // ignore: cast_nullable_to_non_nullable + as List, + failureOption: null == failureOption + ? _value.failureOption + : failureOption // ignore: cast_nullable_to_non_nullable + as Option, + selectedOrder: freezed == selectedOrder + ? _value.selectedOrder + : selectedOrder // ignore: cast_nullable_to_non_nullable + as Order?, + search: freezed == search + ? _value.search + : search // ignore: cast_nullable_to_non_nullable + as String?, + startDate: null == startDate + ? _value.startDate + : startDate // ignore: cast_nullable_to_non_nullable + as DateTime, + endDate: null == endDate + ? _value.endDate + : endDate // ignore: cast_nullable_to_non_nullable + as DateTime, + 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 OrderLoaderState + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $OrderCopyWith<$Res>? get selectedOrder { + if (_value.selectedOrder == null) { + return null; + } + + return $OrderCopyWith<$Res>(_value.selectedOrder!, (value) { + return _then(_value.copyWith(selectedOrder: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$OrderLoaderStateImplCopyWith<$Res> + implements $OrderLoaderStateCopyWith<$Res> { + factory _$$OrderLoaderStateImplCopyWith( + _$OrderLoaderStateImpl value, + $Res Function(_$OrderLoaderStateImpl) then, + ) = __$$OrderLoaderStateImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + List orders, + Option failureOption, + Order? selectedOrder, + String? search, + DateTime startDate, + DateTime endDate, + bool isFetching, + bool hasReachedMax, + int page, + }); + + @override + $OrderCopyWith<$Res>? get selectedOrder; +} + +/// @nodoc +class __$$OrderLoaderStateImplCopyWithImpl<$Res> + extends _$OrderLoaderStateCopyWithImpl<$Res, _$OrderLoaderStateImpl> + implements _$$OrderLoaderStateImplCopyWith<$Res> { + __$$OrderLoaderStateImplCopyWithImpl( + _$OrderLoaderStateImpl _value, + $Res Function(_$OrderLoaderStateImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderLoaderState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? orders = null, + Object? failureOption = null, + Object? selectedOrder = freezed, + Object? search = freezed, + Object? startDate = null, + Object? endDate = null, + Object? isFetching = null, + Object? hasReachedMax = null, + Object? page = null, + }) { + return _then( + _$OrderLoaderStateImpl( + orders: null == orders + ? _value._orders + : orders // ignore: cast_nullable_to_non_nullable + as List, + failureOption: null == failureOption + ? _value.failureOption + : failureOption // ignore: cast_nullable_to_non_nullable + as Option, + selectedOrder: freezed == selectedOrder + ? _value.selectedOrder + : selectedOrder // ignore: cast_nullable_to_non_nullable + as Order?, + search: freezed == search + ? _value.search + : search // ignore: cast_nullable_to_non_nullable + as String?, + startDate: null == startDate + ? _value.startDate + : startDate // ignore: cast_nullable_to_non_nullable + as DateTime, + endDate: null == endDate + ? _value.endDate + : endDate // ignore: cast_nullable_to_non_nullable + as DateTime, + 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 _$OrderLoaderStateImpl implements _OrderLoaderState { + _$OrderLoaderStateImpl({ + required final List orders, + required this.failureOption, + this.selectedOrder, + this.search, + required this.startDate, + required this.endDate, + this.isFetching = false, + this.hasReachedMax = false, + this.page = 1, + }) : _orders = orders; + + final List _orders; + @override + List get orders { + if (_orders is EqualUnmodifiableListView) return _orders; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_orders); + } + + @override + final Option failureOption; + @override + final Order? selectedOrder; + @override + final String? search; + @override + final DateTime startDate; + @override + final DateTime endDate; + @override + @JsonKey() + final bool isFetching; + @override + @JsonKey() + final bool hasReachedMax; + @override + @JsonKey() + final int page; + + @override + String toString() { + return 'OrderLoaderState(orders: $orders, failureOption: $failureOption, selectedOrder: $selectedOrder, search: $search, startDate: $startDate, endDate: $endDate, isFetching: $isFetching, hasReachedMax: $hasReachedMax, page: $page)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$OrderLoaderStateImpl && + const DeepCollectionEquality().equals(other._orders, _orders) && + (identical(other.failureOption, failureOption) || + other.failureOption == failureOption) && + (identical(other.selectedOrder, selectedOrder) || + other.selectedOrder == selectedOrder) && + (identical(other.search, search) || other.search == search) && + (identical(other.startDate, startDate) || + other.startDate == startDate) && + (identical(other.endDate, endDate) || other.endDate == endDate) && + (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(_orders), + failureOption, + selectedOrder, + search, + startDate, + endDate, + isFetching, + hasReachedMax, + page, + ); + + /// Create a copy of OrderLoaderState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$OrderLoaderStateImplCopyWith<_$OrderLoaderStateImpl> get copyWith => + __$$OrderLoaderStateImplCopyWithImpl<_$OrderLoaderStateImpl>( + this, + _$identity, + ); +} + +abstract class _OrderLoaderState implements OrderLoaderState { + factory _OrderLoaderState({ + required final List orders, + required final Option failureOption, + final Order? selectedOrder, + final String? search, + required final DateTime startDate, + required final DateTime endDate, + final bool isFetching, + final bool hasReachedMax, + final int page, + }) = _$OrderLoaderStateImpl; + + @override + List get orders; + @override + Option get failureOption; + @override + Order? get selectedOrder; + @override + String? get search; + @override + DateTime get startDate; + @override + DateTime get endDate; + @override + bool get isFetching; + @override + bool get hasReachedMax; + @override + int get page; + + /// Create a copy of OrderLoaderState + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$OrderLoaderStateImplCopyWith<_$OrderLoaderStateImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/application/order/order_loader/order_loader_event.dart b/lib/application/order/order_loader/order_loader_event.dart new file mode 100644 index 0000000..1c7f2fb --- /dev/null +++ b/lib/application/order/order_loader/order_loader_event.dart @@ -0,0 +1,16 @@ +part of 'order_loader_bloc.dart'; + +@freezed +class OrderLoaderEvent with _$OrderLoaderEvent { + const factory OrderLoaderEvent.dateTimeRangeChange( + DateTime startDate, + DateTime endDate, + ) = _DateTimeRangeChange; + const factory OrderLoaderEvent.searchChange(String search) = _SearchChange; + const factory OrderLoaderEvent.setSelectedOrder(Order order) = + _SetSelectedOrder; + const factory OrderLoaderEvent.fetched({ + @Default(false) bool isRefresh, + required String status, + }) = _Fetched; +} diff --git a/lib/application/order/order_loader/order_loader_state.dart b/lib/application/order/order_loader/order_loader_state.dart new file mode 100644 index 0000000..de8a27c --- /dev/null +++ b/lib/application/order/order_loader/order_loader_state.dart @@ -0,0 +1,23 @@ +part of 'order_loader_bloc.dart'; + +@freezed +class OrderLoaderState with _$OrderLoaderState { + factory OrderLoaderState({ + required List orders, + required Option failureOption, + Order? selectedOrder, + String? search, + required DateTime startDate, + required DateTime endDate, + @Default(false) bool isFetching, + @Default(false) bool hasReachedMax, + @Default(1) int page, + }) = _OrderLoaderState; + + factory OrderLoaderState.initial() => OrderLoaderState( + orders: [], + failureOption: none(), + startDate: DateTime.now(), + endDate: DateTime.now(), + ); +} diff --git a/lib/common/extension/datetime_extension.dart b/lib/common/extension/datetime_extension.dart new file mode 100644 index 0000000..d374907 --- /dev/null +++ b/lib/common/extension/datetime_extension.dart @@ -0,0 +1,65 @@ +part of 'extension.dart'; + +const List _dayNames = [ + 'Senin', + 'Selasa', + 'Rabu', + 'Kamis', + 'Jumat', + 'Sabtu', + 'Minggu', +]; + +const List _monthNames = [ + 'Januari', + 'Februari', + 'Maret', + 'April', + 'Mei', + 'Juni', + 'Juli', + 'Agustus', + 'September', + 'Oktober', + 'November', + 'Desember', +]; + +extension DateTimeExt on DateTime { + String toFormattedDayDate() { + String dayName = _dayNames[weekday - 1]; + String day = this.day.toString(); + String month = _monthNames[this.month - 1]; + String year = this.year.toString(); + + return '$dayName, $day $month $year'; + } + + String toFormattedDate() { + String day = this.day.toString(); + String month = _monthNames[this.month - 1]; + String year = this.year.toString(); + + return '$day $month $year'; + } + + String toFormattedDateTime() { + String day = this.day.toString(); + String month = _monthNames[this.month - 1]; + String year = this.year.toString(); + String hour = this.hour.toString().padLeft( + 2, + '0', + ); // Menambahkan nol di depan jika jam hanya satu digit + String minute = this.minute.toString().padLeft( + 2, + '0', + ); // Menambahkan nol di depan jika menit hanya satu digit + String second = this.second.toString().padLeft( + 2, + '0', + ); // Menambahkan nol di depan jika detik hanya satu digit + + return '$day $month $year, $hour:$minute:$second'; + } +} diff --git a/lib/common/extension/extension.dart b/lib/common/extension/extension.dart index 39b1993..ebb80e1 100644 --- a/lib/common/extension/extension.dart +++ b/lib/common/extension/extension.dart @@ -7,3 +7,4 @@ part 'build_context_extension.dart'; part 'int_extension.dart'; part 'double_extension.dart'; part 'string_extension.dart'; +part 'datetime_extension.dart'; diff --git a/lib/common/url/api_path.dart b/lib/common/url/api_path.dart index 3ef1dda..fc0bfd7 100644 --- a/lib/common/url/api_path.dart +++ b/lib/common/url/api_path.dart @@ -6,4 +6,5 @@ class ApiPath { static const String tables = '/api/v1/tables'; static const String customers = '/api/v1/customers'; static const String paymentMethods = '/api/v1/payment-methods'; + static const String orders = '/api/v1/orders'; } diff --git a/lib/domain/order/entities/order_entity.dart b/lib/domain/order/entities/order_entity.dart new file mode 100644 index 0000000..79f1d5f --- /dev/null +++ b/lib/domain/order/entities/order_entity.dart @@ -0,0 +1,154 @@ +part of '../order.dart'; + +@freezed +class ListOrder with _$ListOrder { + const factory ListOrder({ + required List orders, + required int totalCount, + required int page, + required int limit, + required int totalPages, + }) = _ListOrder; + + factory ListOrder.empty() => + ListOrder(orders: [], totalCount: 0, page: 0, limit: 0, totalPages: 0); +} + +@freezed +class Order with _$Order { + const factory Order({ + required String id, + required String orderNumber, + required String outletId, + required String userId, + required String tableNumber, + required String orderType, + required String status, + required int subtotal, + required int taxAmount, + required int discountAmount, + required int totalAmount, + required num totalCost, + required int remainingAmount, + required String paymentStatus, + required int refundAmount, + required bool isVoid, + required bool isRefund, + required String notes, + required Map metadata, + required DateTime createdAt, + required DateTime updatedAt, + required List orderItems, + required List payments, + required int totalPaid, + required int paymentCount, + required String splitType, + }) = _Order; + + factory Order.empty() => Order( + id: '', + orderNumber: '', + outletId: '', + userId: '', + tableNumber: '', + orderType: '', + status: '', + subtotal: 0, + taxAmount: 0, + discountAmount: 0, + totalAmount: 0, + totalCost: 0, + remainingAmount: 0, + paymentStatus: '', + refundAmount: 0, + isVoid: false, + isRefund: false, + notes: '', + metadata: const {}, + createdAt: DateTime(1970), + updatedAt: DateTime(1970), + orderItems: const [], + payments: const [], + totalPaid: 0, + paymentCount: 0, + splitType: '', + ); +} + +@freezed +class OrderItem with _$OrderItem { + const factory OrderItem({ + required String id, + required String orderId, + required String productId, + required String productName, + required String productVariantId, + required String productVariantName, + required int quantity, + required int unitPrice, + required int totalPrice, + required List modifiers, + required String notes, + required String status, + required DateTime createdAt, + required DateTime updatedAt, + required String printerType, + required int paidQuantity, + }) = _OrderItem; + + factory OrderItem.empty() => OrderItem( + id: '', + orderId: '', + productId: '', + productName: '', + productVariantId: '', + productVariantName: '', + quantity: 0, + unitPrice: 0, + totalPrice: 0, + modifiers: const [], + notes: '', + status: '', + createdAt: DateTime(1970), + updatedAt: DateTime(1970), + printerType: '', + paidQuantity: 0, + ); +} + +@freezed +class PaymentOrder with _$PaymentOrder { + const factory PaymentOrder({ + required String id, + required String orderId, + required String paymentMethodId, + required String paymentMethodName, + required String paymentMethodType, + required int amount, + required String status, + required int splitNumber, + required int splitTotal, + required String splitDescription, + required int refundAmount, + required Map metadata, + required DateTime createdAt, + required DateTime updatedAt, + }) = _PaymentOrder; + + factory PaymentOrder.empty() => PaymentOrder( + id: '', + orderId: '', + paymentMethodId: '', + paymentMethodName: '', + paymentMethodType: '', + amount: 0, + status: '', + splitNumber: 0, + splitTotal: 0, + splitDescription: '', + refundAmount: 0, + metadata: const {}, + createdAt: DateTime(1970), + updatedAt: DateTime(1970), + ); +} diff --git a/lib/domain/order/failures/order_failure.dart b/lib/domain/order/failures/order_failure.dart new file mode 100644 index 0000000..9d3db6f --- /dev/null +++ b/lib/domain/order/failures/order_failure.dart @@ -0,0 +1,12 @@ +part of '../order.dart'; + +@freezed +sealed class OrderFailure with _$OrderFailure { + const factory OrderFailure.serverError(ApiFailure failure) = _ServerError; + const factory OrderFailure.unexpectedError() = _UnexpectedError; + const factory OrderFailure.empty() = _Empty; + const factory OrderFailure.localStorageError(String erroMessage) = + _LocalStorageError; + const factory OrderFailure.dynamicErrorMessage(String erroMessage) = + _DynamicErrorMessage; +} diff --git a/lib/domain/order/order.dart b/lib/domain/order/order.dart new file mode 100644 index 0000000..73e8ed4 --- /dev/null +++ b/lib/domain/order/order.dart @@ -0,0 +1,10 @@ +import 'package:dartz/dartz.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +import '../../common/api/api_failure.dart'; + +part 'order.freezed.dart'; + +part 'entities/order_entity.dart'; +part 'failures/order_failure.dart'; +part 'repositories/i_order_repository.dart'; diff --git a/lib/domain/order/order.freezed.dart b/lib/domain/order/order.freezed.dart new file mode 100644 index 0000000..38de4c1 --- /dev/null +++ b/lib/domain/order/order.freezed.dart @@ -0,0 +1,2705 @@ +// 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 'order.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(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 _$ListOrder { + List get orders => throw _privateConstructorUsedError; + int get totalCount => throw _privateConstructorUsedError; + int get page => throw _privateConstructorUsedError; + int get limit => throw _privateConstructorUsedError; + int get totalPages => throw _privateConstructorUsedError; + + /// Create a copy of ListOrder + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ListOrderCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ListOrderCopyWith<$Res> { + factory $ListOrderCopyWith(ListOrder value, $Res Function(ListOrder) then) = + _$ListOrderCopyWithImpl<$Res, ListOrder>; + @useResult + $Res call({ + List orders, + int totalCount, + int page, + int limit, + int totalPages, + }); +} + +/// @nodoc +class _$ListOrderCopyWithImpl<$Res, $Val extends ListOrder> + implements $ListOrderCopyWith<$Res> { + _$ListOrderCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of ListOrder + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? orders = null, + Object? totalCount = null, + Object? page = null, + Object? limit = null, + Object? totalPages = null, + }) { + return _then( + _value.copyWith( + orders: null == orders + ? _value.orders + : orders // ignore: cast_nullable_to_non_nullable + as List, + totalCount: null == totalCount + ? _value.totalCount + : totalCount // ignore: cast_nullable_to_non_nullable + as int, + page: null == page + ? _value.page + : page // ignore: cast_nullable_to_non_nullable + as int, + limit: null == limit + ? _value.limit + : limit // ignore: cast_nullable_to_non_nullable + as int, + totalPages: null == totalPages + ? _value.totalPages + : totalPages // ignore: cast_nullable_to_non_nullable + as int, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$ListOrderImplCopyWith<$Res> + implements $ListOrderCopyWith<$Res> { + factory _$$ListOrderImplCopyWith( + _$ListOrderImpl value, + $Res Function(_$ListOrderImpl) then, + ) = __$$ListOrderImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + List orders, + int totalCount, + int page, + int limit, + int totalPages, + }); +} + +/// @nodoc +class __$$ListOrderImplCopyWithImpl<$Res> + extends _$ListOrderCopyWithImpl<$Res, _$ListOrderImpl> + implements _$$ListOrderImplCopyWith<$Res> { + __$$ListOrderImplCopyWithImpl( + _$ListOrderImpl _value, + $Res Function(_$ListOrderImpl) _then, + ) : super(_value, _then); + + /// Create a copy of ListOrder + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? orders = null, + Object? totalCount = null, + Object? page = null, + Object? limit = null, + Object? totalPages = null, + }) { + return _then( + _$ListOrderImpl( + orders: null == orders + ? _value._orders + : orders // ignore: cast_nullable_to_non_nullable + as List, + totalCount: null == totalCount + ? _value.totalCount + : totalCount // ignore: cast_nullable_to_non_nullable + as int, + page: null == page + ? _value.page + : page // ignore: cast_nullable_to_non_nullable + as int, + limit: null == limit + ? _value.limit + : limit // ignore: cast_nullable_to_non_nullable + as int, + totalPages: null == totalPages + ? _value.totalPages + : totalPages // ignore: cast_nullable_to_non_nullable + as int, + ), + ); + } +} + +/// @nodoc + +class _$ListOrderImpl implements _ListOrder { + const _$ListOrderImpl({ + required final List orders, + required this.totalCount, + required this.page, + required this.limit, + required this.totalPages, + }) : _orders = orders; + + final List _orders; + @override + List get orders { + if (_orders is EqualUnmodifiableListView) return _orders; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_orders); + } + + @override + final int totalCount; + @override + final int page; + @override + final int limit; + @override + final int totalPages; + + @override + String toString() { + return 'ListOrder(orders: $orders, totalCount: $totalCount, page: $page, limit: $limit, totalPages: $totalPages)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ListOrderImpl && + const DeepCollectionEquality().equals(other._orders, _orders) && + (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)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_orders), + totalCount, + page, + limit, + totalPages, + ); + + /// Create a copy of ListOrder + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ListOrderImplCopyWith<_$ListOrderImpl> get copyWith => + __$$ListOrderImplCopyWithImpl<_$ListOrderImpl>(this, _$identity); +} + +abstract class _ListOrder implements ListOrder { + const factory _ListOrder({ + required final List orders, + required final int totalCount, + required final int page, + required final int limit, + required final int totalPages, + }) = _$ListOrderImpl; + + @override + List get orders; + @override + int get totalCount; + @override + int get page; + @override + int get limit; + @override + int get totalPages; + + /// Create a copy of ListOrder + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ListOrderImplCopyWith<_$ListOrderImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$Order { + String get id => throw _privateConstructorUsedError; + String get orderNumber => throw _privateConstructorUsedError; + String get outletId => throw _privateConstructorUsedError; + String get userId => throw _privateConstructorUsedError; + String get tableNumber => throw _privateConstructorUsedError; + String get orderType => throw _privateConstructorUsedError; + String get status => throw _privateConstructorUsedError; + int get subtotal => throw _privateConstructorUsedError; + int get taxAmount => throw _privateConstructorUsedError; + int get discountAmount => throw _privateConstructorUsedError; + int get totalAmount => throw _privateConstructorUsedError; + num get totalCost => throw _privateConstructorUsedError; + int get remainingAmount => throw _privateConstructorUsedError; + String get paymentStatus => throw _privateConstructorUsedError; + int get refundAmount => throw _privateConstructorUsedError; + bool get isVoid => throw _privateConstructorUsedError; + bool get isRefund => throw _privateConstructorUsedError; + String get notes => throw _privateConstructorUsedError; + Map get metadata => throw _privateConstructorUsedError; + DateTime get createdAt => throw _privateConstructorUsedError; + DateTime get updatedAt => throw _privateConstructorUsedError; + List get orderItems => throw _privateConstructorUsedError; + List get payments => throw _privateConstructorUsedError; + int get totalPaid => throw _privateConstructorUsedError; + int get paymentCount => throw _privateConstructorUsedError; + String get splitType => throw _privateConstructorUsedError; + + /// Create a copy of Order + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $OrderCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OrderCopyWith<$Res> { + factory $OrderCopyWith(Order value, $Res Function(Order) then) = + _$OrderCopyWithImpl<$Res, Order>; + @useResult + $Res call({ + String id, + String orderNumber, + String outletId, + String userId, + String tableNumber, + String orderType, + String status, + int subtotal, + int taxAmount, + int discountAmount, + int totalAmount, + num totalCost, + int remainingAmount, + String paymentStatus, + int refundAmount, + bool isVoid, + bool isRefund, + String notes, + Map metadata, + DateTime createdAt, + DateTime updatedAt, + List orderItems, + List payments, + int totalPaid, + int paymentCount, + String splitType, + }); +} + +/// @nodoc +class _$OrderCopyWithImpl<$Res, $Val extends Order> + implements $OrderCopyWith<$Res> { + _$OrderCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Order + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? orderNumber = null, + Object? outletId = null, + Object? userId = null, + Object? tableNumber = null, + Object? orderType = null, + Object? status = null, + Object? subtotal = null, + Object? taxAmount = null, + Object? discountAmount = null, + Object? totalAmount = null, + Object? totalCost = null, + Object? remainingAmount = null, + Object? paymentStatus = null, + Object? refundAmount = null, + Object? isVoid = null, + Object? isRefund = null, + Object? notes = null, + Object? metadata = null, + Object? createdAt = null, + Object? updatedAt = null, + Object? orderItems = null, + Object? payments = null, + Object? totalPaid = null, + Object? paymentCount = null, + Object? splitType = null, + }) { + return _then( + _value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + orderNumber: null == orderNumber + ? _value.orderNumber + : orderNumber // ignore: cast_nullable_to_non_nullable + as String, + outletId: null == outletId + ? _value.outletId + : outletId // ignore: cast_nullable_to_non_nullable + as String, + userId: null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as String, + tableNumber: null == tableNumber + ? _value.tableNumber + : tableNumber // ignore: cast_nullable_to_non_nullable + as String, + orderType: null == orderType + ? _value.orderType + : orderType // ignore: cast_nullable_to_non_nullable + as String, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String, + subtotal: null == subtotal + ? _value.subtotal + : subtotal // ignore: cast_nullable_to_non_nullable + as int, + taxAmount: null == taxAmount + ? _value.taxAmount + : taxAmount // ignore: cast_nullable_to_non_nullable + as int, + discountAmount: null == discountAmount + ? _value.discountAmount + : discountAmount // ignore: cast_nullable_to_non_nullable + as int, + totalAmount: null == totalAmount + ? _value.totalAmount + : totalAmount // ignore: cast_nullable_to_non_nullable + as int, + totalCost: null == totalCost + ? _value.totalCost + : totalCost // ignore: cast_nullable_to_non_nullable + as num, + remainingAmount: null == remainingAmount + ? _value.remainingAmount + : remainingAmount // ignore: cast_nullable_to_non_nullable + as int, + paymentStatus: null == paymentStatus + ? _value.paymentStatus + : paymentStatus // ignore: cast_nullable_to_non_nullable + as String, + refundAmount: null == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int, + isVoid: null == isVoid + ? _value.isVoid + : isVoid // ignore: cast_nullable_to_non_nullable + as bool, + isRefund: null == isRefund + ? _value.isRefund + : isRefund // ignore: cast_nullable_to_non_nullable + as bool, + notes: null == notes + ? _value.notes + : notes // ignore: cast_nullable_to_non_nullable + as String, + metadata: null == metadata + ? _value.metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as DateTime, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as DateTime, + orderItems: null == orderItems + ? _value.orderItems + : orderItems // ignore: cast_nullable_to_non_nullable + as List, + payments: null == payments + ? _value.payments + : payments // ignore: cast_nullable_to_non_nullable + as List, + totalPaid: null == totalPaid + ? _value.totalPaid + : totalPaid // ignore: cast_nullable_to_non_nullable + as int, + paymentCount: null == paymentCount + ? _value.paymentCount + : paymentCount // ignore: cast_nullable_to_non_nullable + as int, + splitType: null == splitType + ? _value.splitType + : splitType // ignore: cast_nullable_to_non_nullable + as String, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$OrderImplCopyWith<$Res> implements $OrderCopyWith<$Res> { + factory _$$OrderImplCopyWith( + _$OrderImpl value, + $Res Function(_$OrderImpl) then, + ) = __$$OrderImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + String id, + String orderNumber, + String outletId, + String userId, + String tableNumber, + String orderType, + String status, + int subtotal, + int taxAmount, + int discountAmount, + int totalAmount, + num totalCost, + int remainingAmount, + String paymentStatus, + int refundAmount, + bool isVoid, + bool isRefund, + String notes, + Map metadata, + DateTime createdAt, + DateTime updatedAt, + List orderItems, + List payments, + int totalPaid, + int paymentCount, + String splitType, + }); +} + +/// @nodoc +class __$$OrderImplCopyWithImpl<$Res> + extends _$OrderCopyWithImpl<$Res, _$OrderImpl> + implements _$$OrderImplCopyWith<$Res> { + __$$OrderImplCopyWithImpl( + _$OrderImpl _value, + $Res Function(_$OrderImpl) _then, + ) : super(_value, _then); + + /// Create a copy of Order + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? orderNumber = null, + Object? outletId = null, + Object? userId = null, + Object? tableNumber = null, + Object? orderType = null, + Object? status = null, + Object? subtotal = null, + Object? taxAmount = null, + Object? discountAmount = null, + Object? totalAmount = null, + Object? totalCost = null, + Object? remainingAmount = null, + Object? paymentStatus = null, + Object? refundAmount = null, + Object? isVoid = null, + Object? isRefund = null, + Object? notes = null, + Object? metadata = null, + Object? createdAt = null, + Object? updatedAt = null, + Object? orderItems = null, + Object? payments = null, + Object? totalPaid = null, + Object? paymentCount = null, + Object? splitType = null, + }) { + return _then( + _$OrderImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + orderNumber: null == orderNumber + ? _value.orderNumber + : orderNumber // ignore: cast_nullable_to_non_nullable + as String, + outletId: null == outletId + ? _value.outletId + : outletId // ignore: cast_nullable_to_non_nullable + as String, + userId: null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as String, + tableNumber: null == tableNumber + ? _value.tableNumber + : tableNumber // ignore: cast_nullable_to_non_nullable + as String, + orderType: null == orderType + ? _value.orderType + : orderType // ignore: cast_nullable_to_non_nullable + as String, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String, + subtotal: null == subtotal + ? _value.subtotal + : subtotal // ignore: cast_nullable_to_non_nullable + as int, + taxAmount: null == taxAmount + ? _value.taxAmount + : taxAmount // ignore: cast_nullable_to_non_nullable + as int, + discountAmount: null == discountAmount + ? _value.discountAmount + : discountAmount // ignore: cast_nullable_to_non_nullable + as int, + totalAmount: null == totalAmount + ? _value.totalAmount + : totalAmount // ignore: cast_nullable_to_non_nullable + as int, + totalCost: null == totalCost + ? _value.totalCost + : totalCost // ignore: cast_nullable_to_non_nullable + as num, + remainingAmount: null == remainingAmount + ? _value.remainingAmount + : remainingAmount // ignore: cast_nullable_to_non_nullable + as int, + paymentStatus: null == paymentStatus + ? _value.paymentStatus + : paymentStatus // ignore: cast_nullable_to_non_nullable + as String, + refundAmount: null == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int, + isVoid: null == isVoid + ? _value.isVoid + : isVoid // ignore: cast_nullable_to_non_nullable + as bool, + isRefund: null == isRefund + ? _value.isRefund + : isRefund // ignore: cast_nullable_to_non_nullable + as bool, + notes: null == notes + ? _value.notes + : notes // ignore: cast_nullable_to_non_nullable + as String, + metadata: null == metadata + ? _value._metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as DateTime, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as DateTime, + orderItems: null == orderItems + ? _value._orderItems + : orderItems // ignore: cast_nullable_to_non_nullable + as List, + payments: null == payments + ? _value._payments + : payments // ignore: cast_nullable_to_non_nullable + as List, + totalPaid: null == totalPaid + ? _value.totalPaid + : totalPaid // ignore: cast_nullable_to_non_nullable + as int, + paymentCount: null == paymentCount + ? _value.paymentCount + : paymentCount // ignore: cast_nullable_to_non_nullable + as int, + splitType: null == splitType + ? _value.splitType + : splitType // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$OrderImpl implements _Order { + const _$OrderImpl({ + required this.id, + required this.orderNumber, + required this.outletId, + required this.userId, + required this.tableNumber, + required this.orderType, + required this.status, + required this.subtotal, + required this.taxAmount, + required this.discountAmount, + required this.totalAmount, + required this.totalCost, + required this.remainingAmount, + required this.paymentStatus, + required this.refundAmount, + required this.isVoid, + required this.isRefund, + required this.notes, + required final Map metadata, + required this.createdAt, + required this.updatedAt, + required final List orderItems, + required final List payments, + required this.totalPaid, + required this.paymentCount, + required this.splitType, + }) : _metadata = metadata, + _orderItems = orderItems, + _payments = payments; + + @override + final String id; + @override + final String orderNumber; + @override + final String outletId; + @override + final String userId; + @override + final String tableNumber; + @override + final String orderType; + @override + final String status; + @override + final int subtotal; + @override + final int taxAmount; + @override + final int discountAmount; + @override + final int totalAmount; + @override + final num totalCost; + @override + final int remainingAmount; + @override + final String paymentStatus; + @override + final int refundAmount; + @override + final bool isVoid; + @override + final bool isRefund; + @override + final String notes; + final Map _metadata; + @override + Map get metadata { + if (_metadata is EqualUnmodifiableMapView) return _metadata; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_metadata); + } + + @override + final DateTime createdAt; + @override + final DateTime updatedAt; + final List _orderItems; + @override + List get orderItems { + if (_orderItems is EqualUnmodifiableListView) return _orderItems; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_orderItems); + } + + final List _payments; + @override + List get payments { + if (_payments is EqualUnmodifiableListView) return _payments; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_payments); + } + + @override + final int totalPaid; + @override + final int paymentCount; + @override + final String splitType; + + @override + String toString() { + return 'Order(id: $id, orderNumber: $orderNumber, outletId: $outletId, userId: $userId, tableNumber: $tableNumber, orderType: $orderType, status: $status, subtotal: $subtotal, taxAmount: $taxAmount, discountAmount: $discountAmount, totalAmount: $totalAmount, totalCost: $totalCost, remainingAmount: $remainingAmount, paymentStatus: $paymentStatus, refundAmount: $refundAmount, isVoid: $isVoid, isRefund: $isRefund, notes: $notes, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt, orderItems: $orderItems, payments: $payments, totalPaid: $totalPaid, paymentCount: $paymentCount, splitType: $splitType)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$OrderImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.orderNumber, orderNumber) || + other.orderNumber == orderNumber) && + (identical(other.outletId, outletId) || + other.outletId == outletId) && + (identical(other.userId, userId) || other.userId == userId) && + (identical(other.tableNumber, tableNumber) || + other.tableNumber == tableNumber) && + (identical(other.orderType, orderType) || + other.orderType == orderType) && + (identical(other.status, status) || other.status == status) && + (identical(other.subtotal, subtotal) || + other.subtotal == subtotal) && + (identical(other.taxAmount, taxAmount) || + other.taxAmount == taxAmount) && + (identical(other.discountAmount, discountAmount) || + other.discountAmount == discountAmount) && + (identical(other.totalAmount, totalAmount) || + other.totalAmount == totalAmount) && + (identical(other.totalCost, totalCost) || + other.totalCost == totalCost) && + (identical(other.remainingAmount, remainingAmount) || + other.remainingAmount == remainingAmount) && + (identical(other.paymentStatus, paymentStatus) || + other.paymentStatus == paymentStatus) && + (identical(other.refundAmount, refundAmount) || + other.refundAmount == refundAmount) && + (identical(other.isVoid, isVoid) || other.isVoid == isVoid) && + (identical(other.isRefund, isRefund) || + other.isRefund == isRefund) && + (identical(other.notes, notes) || other.notes == notes) && + const DeepCollectionEquality().equals(other._metadata, _metadata) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt) && + const DeepCollectionEquality().equals( + other._orderItems, + _orderItems, + ) && + const DeepCollectionEquality().equals(other._payments, _payments) && + (identical(other.totalPaid, totalPaid) || + other.totalPaid == totalPaid) && + (identical(other.paymentCount, paymentCount) || + other.paymentCount == paymentCount) && + (identical(other.splitType, splitType) || + other.splitType == splitType)); + } + + @override + int get hashCode => Object.hashAll([ + runtimeType, + id, + orderNumber, + outletId, + userId, + tableNumber, + orderType, + status, + subtotal, + taxAmount, + discountAmount, + totalAmount, + totalCost, + remainingAmount, + paymentStatus, + refundAmount, + isVoid, + isRefund, + notes, + const DeepCollectionEquality().hash(_metadata), + createdAt, + updatedAt, + const DeepCollectionEquality().hash(_orderItems), + const DeepCollectionEquality().hash(_payments), + totalPaid, + paymentCount, + splitType, + ]); + + /// Create a copy of Order + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$OrderImplCopyWith<_$OrderImpl> get copyWith => + __$$OrderImplCopyWithImpl<_$OrderImpl>(this, _$identity); +} + +abstract class _Order implements Order { + const factory _Order({ + required final String id, + required final String orderNumber, + required final String outletId, + required final String userId, + required final String tableNumber, + required final String orderType, + required final String status, + required final int subtotal, + required final int taxAmount, + required final int discountAmount, + required final int totalAmount, + required final num totalCost, + required final int remainingAmount, + required final String paymentStatus, + required final int refundAmount, + required final bool isVoid, + required final bool isRefund, + required final String notes, + required final Map metadata, + required final DateTime createdAt, + required final DateTime updatedAt, + required final List orderItems, + required final List payments, + required final int totalPaid, + required final int paymentCount, + required final String splitType, + }) = _$OrderImpl; + + @override + String get id; + @override + String get orderNumber; + @override + String get outletId; + @override + String get userId; + @override + String get tableNumber; + @override + String get orderType; + @override + String get status; + @override + int get subtotal; + @override + int get taxAmount; + @override + int get discountAmount; + @override + int get totalAmount; + @override + num get totalCost; + @override + int get remainingAmount; + @override + String get paymentStatus; + @override + int get refundAmount; + @override + bool get isVoid; + @override + bool get isRefund; + @override + String get notes; + @override + Map get metadata; + @override + DateTime get createdAt; + @override + DateTime get updatedAt; + @override + List get orderItems; + @override + List get payments; + @override + int get totalPaid; + @override + int get paymentCount; + @override + String get splitType; + + /// Create a copy of Order + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$OrderImplCopyWith<_$OrderImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$OrderItem { + String get id => throw _privateConstructorUsedError; + String get orderId => throw _privateConstructorUsedError; + String get productId => throw _privateConstructorUsedError; + String get productName => throw _privateConstructorUsedError; + String get productVariantId => throw _privateConstructorUsedError; + String get productVariantName => throw _privateConstructorUsedError; + int get quantity => throw _privateConstructorUsedError; + int get unitPrice => throw _privateConstructorUsedError; + int get totalPrice => throw _privateConstructorUsedError; + List get modifiers => throw _privateConstructorUsedError; + String get notes => throw _privateConstructorUsedError; + String get status => throw _privateConstructorUsedError; + DateTime get createdAt => throw _privateConstructorUsedError; + DateTime get updatedAt => throw _privateConstructorUsedError; + String get printerType => throw _privateConstructorUsedError; + int get paidQuantity => throw _privateConstructorUsedError; + + /// Create a copy of OrderItem + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $OrderItemCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OrderItemCopyWith<$Res> { + factory $OrderItemCopyWith(OrderItem value, $Res Function(OrderItem) then) = + _$OrderItemCopyWithImpl<$Res, OrderItem>; + @useResult + $Res call({ + String id, + String orderId, + String productId, + String productName, + String productVariantId, + String productVariantName, + int quantity, + int unitPrice, + int totalPrice, + List modifiers, + String notes, + String status, + DateTime createdAt, + DateTime updatedAt, + String printerType, + int paidQuantity, + }); +} + +/// @nodoc +class _$OrderItemCopyWithImpl<$Res, $Val extends OrderItem> + implements $OrderItemCopyWith<$Res> { + _$OrderItemCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of OrderItem + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? orderId = null, + Object? productId = null, + Object? productName = null, + Object? productVariantId = null, + Object? productVariantName = null, + Object? quantity = null, + Object? unitPrice = null, + Object? totalPrice = null, + Object? modifiers = null, + Object? notes = null, + Object? status = null, + Object? createdAt = null, + Object? updatedAt = null, + Object? printerType = null, + Object? paidQuantity = null, + }) { + return _then( + _value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + orderId: null == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String, + productId: null == productId + ? _value.productId + : productId // ignore: cast_nullable_to_non_nullable + as String, + productName: null == productName + ? _value.productName + : productName // ignore: cast_nullable_to_non_nullable + as String, + productVariantId: null == productVariantId + ? _value.productVariantId + : productVariantId // ignore: cast_nullable_to_non_nullable + as String, + productVariantName: null == productVariantName + ? _value.productVariantName + : productVariantName // ignore: cast_nullable_to_non_nullable + as String, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + unitPrice: null == unitPrice + ? _value.unitPrice + : unitPrice // ignore: cast_nullable_to_non_nullable + as int, + totalPrice: null == totalPrice + ? _value.totalPrice + : totalPrice // ignore: cast_nullable_to_non_nullable + as int, + modifiers: null == modifiers + ? _value.modifiers + : modifiers // ignore: cast_nullable_to_non_nullable + as List, + notes: null == notes + ? _value.notes + : notes // ignore: cast_nullable_to_non_nullable + as String, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as DateTime, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as DateTime, + printerType: null == printerType + ? _value.printerType + : printerType // ignore: cast_nullable_to_non_nullable + as String, + paidQuantity: null == paidQuantity + ? _value.paidQuantity + : paidQuantity // ignore: cast_nullable_to_non_nullable + as int, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$OrderItemImplCopyWith<$Res> + implements $OrderItemCopyWith<$Res> { + factory _$$OrderItemImplCopyWith( + _$OrderItemImpl value, + $Res Function(_$OrderItemImpl) then, + ) = __$$OrderItemImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + String id, + String orderId, + String productId, + String productName, + String productVariantId, + String productVariantName, + int quantity, + int unitPrice, + int totalPrice, + List modifiers, + String notes, + String status, + DateTime createdAt, + DateTime updatedAt, + String printerType, + int paidQuantity, + }); +} + +/// @nodoc +class __$$OrderItemImplCopyWithImpl<$Res> + extends _$OrderItemCopyWithImpl<$Res, _$OrderItemImpl> + implements _$$OrderItemImplCopyWith<$Res> { + __$$OrderItemImplCopyWithImpl( + _$OrderItemImpl _value, + $Res Function(_$OrderItemImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderItem + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? orderId = null, + Object? productId = null, + Object? productName = null, + Object? productVariantId = null, + Object? productVariantName = null, + Object? quantity = null, + Object? unitPrice = null, + Object? totalPrice = null, + Object? modifiers = null, + Object? notes = null, + Object? status = null, + Object? createdAt = null, + Object? updatedAt = null, + Object? printerType = null, + Object? paidQuantity = null, + }) { + return _then( + _$OrderItemImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + orderId: null == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String, + productId: null == productId + ? _value.productId + : productId // ignore: cast_nullable_to_non_nullable + as String, + productName: null == productName + ? _value.productName + : productName // ignore: cast_nullable_to_non_nullable + as String, + productVariantId: null == productVariantId + ? _value.productVariantId + : productVariantId // ignore: cast_nullable_to_non_nullable + as String, + productVariantName: null == productVariantName + ? _value.productVariantName + : productVariantName // ignore: cast_nullable_to_non_nullable + as String, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + unitPrice: null == unitPrice + ? _value.unitPrice + : unitPrice // ignore: cast_nullable_to_non_nullable + as int, + totalPrice: null == totalPrice + ? _value.totalPrice + : totalPrice // ignore: cast_nullable_to_non_nullable + as int, + modifiers: null == modifiers + ? _value._modifiers + : modifiers // ignore: cast_nullable_to_non_nullable + as List, + notes: null == notes + ? _value.notes + : notes // ignore: cast_nullable_to_non_nullable + as String, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as DateTime, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as DateTime, + printerType: null == printerType + ? _value.printerType + : printerType // ignore: cast_nullable_to_non_nullable + as String, + paidQuantity: null == paidQuantity + ? _value.paidQuantity + : paidQuantity // ignore: cast_nullable_to_non_nullable + as int, + ), + ); + } +} + +/// @nodoc + +class _$OrderItemImpl implements _OrderItem { + const _$OrderItemImpl({ + required this.id, + required this.orderId, + required this.productId, + required this.productName, + required this.productVariantId, + required this.productVariantName, + required this.quantity, + required this.unitPrice, + required this.totalPrice, + required final List modifiers, + required this.notes, + required this.status, + required this.createdAt, + required this.updatedAt, + required this.printerType, + required this.paidQuantity, + }) : _modifiers = modifiers; + + @override + final String id; + @override + final String orderId; + @override + final String productId; + @override + final String productName; + @override + final String productVariantId; + @override + final String productVariantName; + @override + final int quantity; + @override + final int unitPrice; + @override + final int totalPrice; + final List _modifiers; + @override + List get modifiers { + if (_modifiers is EqualUnmodifiableListView) return _modifiers; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_modifiers); + } + + @override + final String notes; + @override + final String status; + @override + final DateTime createdAt; + @override + final DateTime updatedAt; + @override + final String printerType; + @override + final int paidQuantity; + + @override + String toString() { + return 'OrderItem(id: $id, orderId: $orderId, productId: $productId, productName: $productName, productVariantId: $productVariantId, productVariantName: $productVariantName, quantity: $quantity, unitPrice: $unitPrice, totalPrice: $totalPrice, modifiers: $modifiers, notes: $notes, status: $status, createdAt: $createdAt, updatedAt: $updatedAt, printerType: $printerType, paidQuantity: $paidQuantity)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$OrderItemImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.orderId, orderId) || other.orderId == orderId) && + (identical(other.productId, productId) || + other.productId == productId) && + (identical(other.productName, productName) || + other.productName == productName) && + (identical(other.productVariantId, productVariantId) || + other.productVariantId == productVariantId) && + (identical(other.productVariantName, productVariantName) || + other.productVariantName == productVariantName) && + (identical(other.quantity, quantity) || + other.quantity == quantity) && + (identical(other.unitPrice, unitPrice) || + other.unitPrice == unitPrice) && + (identical(other.totalPrice, totalPrice) || + other.totalPrice == totalPrice) && + const DeepCollectionEquality().equals( + other._modifiers, + _modifiers, + ) && + (identical(other.notes, notes) || other.notes == notes) && + (identical(other.status, status) || other.status == status) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt) && + (identical(other.printerType, printerType) || + other.printerType == printerType) && + (identical(other.paidQuantity, paidQuantity) || + other.paidQuantity == paidQuantity)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + id, + orderId, + productId, + productName, + productVariantId, + productVariantName, + quantity, + unitPrice, + totalPrice, + const DeepCollectionEquality().hash(_modifiers), + notes, + status, + createdAt, + updatedAt, + printerType, + paidQuantity, + ); + + /// Create a copy of OrderItem + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$OrderItemImplCopyWith<_$OrderItemImpl> get copyWith => + __$$OrderItemImplCopyWithImpl<_$OrderItemImpl>(this, _$identity); +} + +abstract class _OrderItem implements OrderItem { + const factory _OrderItem({ + required final String id, + required final String orderId, + required final String productId, + required final String productName, + required final String productVariantId, + required final String productVariantName, + required final int quantity, + required final int unitPrice, + required final int totalPrice, + required final List modifiers, + required final String notes, + required final String status, + required final DateTime createdAt, + required final DateTime updatedAt, + required final String printerType, + required final int paidQuantity, + }) = _$OrderItemImpl; + + @override + String get id; + @override + String get orderId; + @override + String get productId; + @override + String get productName; + @override + String get productVariantId; + @override + String get productVariantName; + @override + int get quantity; + @override + int get unitPrice; + @override + int get totalPrice; + @override + List get modifiers; + @override + String get notes; + @override + String get status; + @override + DateTime get createdAt; + @override + DateTime get updatedAt; + @override + String get printerType; + @override + int get paidQuantity; + + /// Create a copy of OrderItem + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$OrderItemImplCopyWith<_$OrderItemImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$PaymentOrder { + String get id => throw _privateConstructorUsedError; + String get orderId => throw _privateConstructorUsedError; + String get paymentMethodId => throw _privateConstructorUsedError; + String get paymentMethodName => throw _privateConstructorUsedError; + String get paymentMethodType => throw _privateConstructorUsedError; + int get amount => throw _privateConstructorUsedError; + String get status => throw _privateConstructorUsedError; + int get splitNumber => throw _privateConstructorUsedError; + int get splitTotal => throw _privateConstructorUsedError; + String get splitDescription => throw _privateConstructorUsedError; + int get refundAmount => throw _privateConstructorUsedError; + Map get metadata => throw _privateConstructorUsedError; + DateTime get createdAt => throw _privateConstructorUsedError; + DateTime get updatedAt => throw _privateConstructorUsedError; + + /// Create a copy of PaymentOrder + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PaymentOrderCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PaymentOrderCopyWith<$Res> { + factory $PaymentOrderCopyWith( + PaymentOrder value, + $Res Function(PaymentOrder) then, + ) = _$PaymentOrderCopyWithImpl<$Res, PaymentOrder>; + @useResult + $Res call({ + String id, + String orderId, + String paymentMethodId, + String paymentMethodName, + String paymentMethodType, + int amount, + String status, + int splitNumber, + int splitTotal, + String splitDescription, + int refundAmount, + Map metadata, + DateTime createdAt, + DateTime updatedAt, + }); +} + +/// @nodoc +class _$PaymentOrderCopyWithImpl<$Res, $Val extends PaymentOrder> + implements $PaymentOrderCopyWith<$Res> { + _$PaymentOrderCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PaymentOrder + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? orderId = null, + Object? paymentMethodId = null, + Object? paymentMethodName = null, + Object? paymentMethodType = null, + Object? amount = null, + Object? status = null, + Object? splitNumber = null, + Object? splitTotal = null, + Object? splitDescription = null, + Object? refundAmount = null, + Object? metadata = null, + Object? createdAt = null, + Object? updatedAt = null, + }) { + return _then( + _value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + orderId: null == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodId: null == paymentMethodId + ? _value.paymentMethodId + : paymentMethodId // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodName: null == paymentMethodName + ? _value.paymentMethodName + : paymentMethodName // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodType: null == paymentMethodType + ? _value.paymentMethodType + : paymentMethodType // ignore: cast_nullable_to_non_nullable + as String, + amount: null == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String, + splitNumber: null == splitNumber + ? _value.splitNumber + : splitNumber // ignore: cast_nullable_to_non_nullable + as int, + splitTotal: null == splitTotal + ? _value.splitTotal + : splitTotal // ignore: cast_nullable_to_non_nullable + as int, + splitDescription: null == splitDescription + ? _value.splitDescription + : splitDescription // ignore: cast_nullable_to_non_nullable + as String, + refundAmount: null == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int, + metadata: null == metadata + ? _value.metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as DateTime, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as DateTime, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$PaymentOrderImplCopyWith<$Res> + implements $PaymentOrderCopyWith<$Res> { + factory _$$PaymentOrderImplCopyWith( + _$PaymentOrderImpl value, + $Res Function(_$PaymentOrderImpl) then, + ) = __$$PaymentOrderImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + String id, + String orderId, + String paymentMethodId, + String paymentMethodName, + String paymentMethodType, + int amount, + String status, + int splitNumber, + int splitTotal, + String splitDescription, + int refundAmount, + Map metadata, + DateTime createdAt, + DateTime updatedAt, + }); +} + +/// @nodoc +class __$$PaymentOrderImplCopyWithImpl<$Res> + extends _$PaymentOrderCopyWithImpl<$Res, _$PaymentOrderImpl> + implements _$$PaymentOrderImplCopyWith<$Res> { + __$$PaymentOrderImplCopyWithImpl( + _$PaymentOrderImpl _value, + $Res Function(_$PaymentOrderImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PaymentOrder + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? orderId = null, + Object? paymentMethodId = null, + Object? paymentMethodName = null, + Object? paymentMethodType = null, + Object? amount = null, + Object? status = null, + Object? splitNumber = null, + Object? splitTotal = null, + Object? splitDescription = null, + Object? refundAmount = null, + Object? metadata = null, + Object? createdAt = null, + Object? updatedAt = null, + }) { + return _then( + _$PaymentOrderImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + orderId: null == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodId: null == paymentMethodId + ? _value.paymentMethodId + : paymentMethodId // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodName: null == paymentMethodName + ? _value.paymentMethodName + : paymentMethodName // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodType: null == paymentMethodType + ? _value.paymentMethodType + : paymentMethodType // ignore: cast_nullable_to_non_nullable + as String, + amount: null == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String, + splitNumber: null == splitNumber + ? _value.splitNumber + : splitNumber // ignore: cast_nullable_to_non_nullable + as int, + splitTotal: null == splitTotal + ? _value.splitTotal + : splitTotal // ignore: cast_nullable_to_non_nullable + as int, + splitDescription: null == splitDescription + ? _value.splitDescription + : splitDescription // ignore: cast_nullable_to_non_nullable + as String, + refundAmount: null == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int, + metadata: null == metadata + ? _value._metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as DateTime, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as DateTime, + ), + ); + } +} + +/// @nodoc + +class _$PaymentOrderImpl implements _PaymentOrder { + const _$PaymentOrderImpl({ + required this.id, + required this.orderId, + required this.paymentMethodId, + required this.paymentMethodName, + required this.paymentMethodType, + required this.amount, + required this.status, + required this.splitNumber, + required this.splitTotal, + required this.splitDescription, + required this.refundAmount, + required final Map metadata, + required this.createdAt, + required this.updatedAt, + }) : _metadata = metadata; + + @override + final String id; + @override + final String orderId; + @override + final String paymentMethodId; + @override + final String paymentMethodName; + @override + final String paymentMethodType; + @override + final int amount; + @override + final String status; + @override + final int splitNumber; + @override + final int splitTotal; + @override + final String splitDescription; + @override + final int refundAmount; + final Map _metadata; + @override + Map get metadata { + if (_metadata is EqualUnmodifiableMapView) return _metadata; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_metadata); + } + + @override + final DateTime createdAt; + @override + final DateTime updatedAt; + + @override + String toString() { + return 'PaymentOrder(id: $id, orderId: $orderId, paymentMethodId: $paymentMethodId, paymentMethodName: $paymentMethodName, paymentMethodType: $paymentMethodType, amount: $amount, status: $status, splitNumber: $splitNumber, splitTotal: $splitTotal, splitDescription: $splitDescription, refundAmount: $refundAmount, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentOrderImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.orderId, orderId) || other.orderId == orderId) && + (identical(other.paymentMethodId, paymentMethodId) || + other.paymentMethodId == paymentMethodId) && + (identical(other.paymentMethodName, paymentMethodName) || + other.paymentMethodName == paymentMethodName) && + (identical(other.paymentMethodType, paymentMethodType) || + other.paymentMethodType == paymentMethodType) && + (identical(other.amount, amount) || other.amount == amount) && + (identical(other.status, status) || other.status == status) && + (identical(other.splitNumber, splitNumber) || + other.splitNumber == splitNumber) && + (identical(other.splitTotal, splitTotal) || + other.splitTotal == splitTotal) && + (identical(other.splitDescription, splitDescription) || + other.splitDescription == splitDescription) && + (identical(other.refundAmount, refundAmount) || + other.refundAmount == refundAmount) && + const DeepCollectionEquality().equals(other._metadata, _metadata) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + id, + orderId, + paymentMethodId, + paymentMethodName, + paymentMethodType, + amount, + status, + splitNumber, + splitTotal, + splitDescription, + refundAmount, + const DeepCollectionEquality().hash(_metadata), + createdAt, + updatedAt, + ); + + /// Create a copy of PaymentOrder + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PaymentOrderImplCopyWith<_$PaymentOrderImpl> get copyWith => + __$$PaymentOrderImplCopyWithImpl<_$PaymentOrderImpl>(this, _$identity); +} + +abstract class _PaymentOrder implements PaymentOrder { + const factory _PaymentOrder({ + required final String id, + required final String orderId, + required final String paymentMethodId, + required final String paymentMethodName, + required final String paymentMethodType, + required final int amount, + required final String status, + required final int splitNumber, + required final int splitTotal, + required final String splitDescription, + required final int refundAmount, + required final Map metadata, + required final DateTime createdAt, + required final DateTime updatedAt, + }) = _$PaymentOrderImpl; + + @override + String get id; + @override + String get orderId; + @override + String get paymentMethodId; + @override + String get paymentMethodName; + @override + String get paymentMethodType; + @override + int get amount; + @override + String get status; + @override + int get splitNumber; + @override + int get splitTotal; + @override + String get splitDescription; + @override + int get refundAmount; + @override + Map get metadata; + @override + DateTime get createdAt; + @override + DateTime get updatedAt; + + /// Create a copy of PaymentOrder + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PaymentOrderImplCopyWith<_$PaymentOrderImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$OrderFailure { + @optionalTypeArgs + TResult when({ + required TResult Function(ApiFailure failure) serverError, + required TResult Function() unexpectedError, + required TResult Function() empty, + required TResult Function(String erroMessage) localStorageError, + required TResult Function(String erroMessage) dynamicErrorMessage, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(ApiFailure failure)? serverError, + TResult? Function()? unexpectedError, + TResult? Function()? empty, + TResult? Function(String erroMessage)? localStorageError, + TResult? Function(String erroMessage)? dynamicErrorMessage, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(ApiFailure failure)? serverError, + TResult Function()? unexpectedError, + TResult Function()? empty, + TResult Function(String erroMessage)? localStorageError, + TResult Function(String erroMessage)? dynamicErrorMessage, + required TResult orElse(), + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(_ServerError value) serverError, + required TResult Function(_UnexpectedError value) unexpectedError, + required TResult Function(_Empty value) empty, + required TResult Function(_LocalStorageError value) localStorageError, + required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_ServerError value)? serverError, + TResult? Function(_UnexpectedError value)? unexpectedError, + TResult? Function(_Empty value)? empty, + TResult? Function(_LocalStorageError value)? localStorageError, + TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_ServerError value)? serverError, + TResult Function(_UnexpectedError value)? unexpectedError, + TResult Function(_Empty value)? empty, + TResult Function(_LocalStorageError value)? localStorageError, + TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, + required TResult orElse(), + }) => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OrderFailureCopyWith<$Res> { + factory $OrderFailureCopyWith( + OrderFailure value, + $Res Function(OrderFailure) then, + ) = _$OrderFailureCopyWithImpl<$Res, OrderFailure>; +} + +/// @nodoc +class _$OrderFailureCopyWithImpl<$Res, $Val extends OrderFailure> + implements $OrderFailureCopyWith<$Res> { + _$OrderFailureCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$ServerErrorImplCopyWith<$Res> { + factory _$$ServerErrorImplCopyWith( + _$ServerErrorImpl value, + $Res Function(_$ServerErrorImpl) then, + ) = __$$ServerErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({ApiFailure failure}); + + $ApiFailureCopyWith<$Res> get failure; +} + +/// @nodoc +class __$$ServerErrorImplCopyWithImpl<$Res> + extends _$OrderFailureCopyWithImpl<$Res, _$ServerErrorImpl> + implements _$$ServerErrorImplCopyWith<$Res> { + __$$ServerErrorImplCopyWithImpl( + _$ServerErrorImpl _value, + $Res Function(_$ServerErrorImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? failure = null}) { + return _then( + _$ServerErrorImpl( + null == failure + ? _value.failure + : failure // ignore: cast_nullable_to_non_nullable + as ApiFailure, + ), + ); + } + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ApiFailureCopyWith<$Res> get failure { + return $ApiFailureCopyWith<$Res>(_value.failure, (value) { + return _then(_value.copyWith(failure: value)); + }); + } +} + +/// @nodoc + +class _$ServerErrorImpl implements _ServerError { + const _$ServerErrorImpl(this.failure); + + @override + final ApiFailure failure; + + @override + String toString() { + return 'OrderFailure.serverError(failure: $failure)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ServerErrorImpl && + (identical(other.failure, failure) || other.failure == failure)); + } + + @override + int get hashCode => Object.hash(runtimeType, failure); + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ServerErrorImplCopyWith<_$ServerErrorImpl> get copyWith => + __$$ServerErrorImplCopyWithImpl<_$ServerErrorImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(ApiFailure failure) serverError, + required TResult Function() unexpectedError, + required TResult Function() empty, + required TResult Function(String erroMessage) localStorageError, + required TResult Function(String erroMessage) dynamicErrorMessage, + }) { + return serverError(failure); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(ApiFailure failure)? serverError, + TResult? Function()? unexpectedError, + TResult? Function()? empty, + TResult? Function(String erroMessage)? localStorageError, + TResult? Function(String erroMessage)? dynamicErrorMessage, + }) { + return serverError?.call(failure); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(ApiFailure failure)? serverError, + TResult Function()? unexpectedError, + TResult Function()? empty, + TResult Function(String erroMessage)? localStorageError, + TResult Function(String erroMessage)? dynamicErrorMessage, + required TResult orElse(), + }) { + if (serverError != null) { + return serverError(failure); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_ServerError value) serverError, + required TResult Function(_UnexpectedError value) unexpectedError, + required TResult Function(_Empty value) empty, + required TResult Function(_LocalStorageError value) localStorageError, + required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, + }) { + return serverError(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_ServerError value)? serverError, + TResult? Function(_UnexpectedError value)? unexpectedError, + TResult? Function(_Empty value)? empty, + TResult? Function(_LocalStorageError value)? localStorageError, + TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, + }) { + return serverError?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_ServerError value)? serverError, + TResult Function(_UnexpectedError value)? unexpectedError, + TResult Function(_Empty value)? empty, + TResult Function(_LocalStorageError value)? localStorageError, + TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, + required TResult orElse(), + }) { + if (serverError != null) { + return serverError(this); + } + return orElse(); + } +} + +abstract class _ServerError implements OrderFailure { + const factory _ServerError(final ApiFailure failure) = _$ServerErrorImpl; + + ApiFailure get failure; + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ServerErrorImplCopyWith<_$ServerErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$UnexpectedErrorImplCopyWith<$Res> { + factory _$$UnexpectedErrorImplCopyWith( + _$UnexpectedErrorImpl value, + $Res Function(_$UnexpectedErrorImpl) then, + ) = __$$UnexpectedErrorImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$UnexpectedErrorImplCopyWithImpl<$Res> + extends _$OrderFailureCopyWithImpl<$Res, _$UnexpectedErrorImpl> + implements _$$UnexpectedErrorImplCopyWith<$Res> { + __$$UnexpectedErrorImplCopyWithImpl( + _$UnexpectedErrorImpl _value, + $Res Function(_$UnexpectedErrorImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$UnexpectedErrorImpl implements _UnexpectedError { + const _$UnexpectedErrorImpl(); + + @override + String toString() { + return 'OrderFailure.unexpectedError()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$UnexpectedErrorImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(ApiFailure failure) serverError, + required TResult Function() unexpectedError, + required TResult Function() empty, + required TResult Function(String erroMessage) localStorageError, + required TResult Function(String erroMessage) dynamicErrorMessage, + }) { + return unexpectedError(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(ApiFailure failure)? serverError, + TResult? Function()? unexpectedError, + TResult? Function()? empty, + TResult? Function(String erroMessage)? localStorageError, + TResult? Function(String erroMessage)? dynamicErrorMessage, + }) { + return unexpectedError?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(ApiFailure failure)? serverError, + TResult Function()? unexpectedError, + TResult Function()? empty, + TResult Function(String erroMessage)? localStorageError, + TResult Function(String erroMessage)? dynamicErrorMessage, + required TResult orElse(), + }) { + if (unexpectedError != null) { + return unexpectedError(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_ServerError value) serverError, + required TResult Function(_UnexpectedError value) unexpectedError, + required TResult Function(_Empty value) empty, + required TResult Function(_LocalStorageError value) localStorageError, + required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, + }) { + return unexpectedError(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_ServerError value)? serverError, + TResult? Function(_UnexpectedError value)? unexpectedError, + TResult? Function(_Empty value)? empty, + TResult? Function(_LocalStorageError value)? localStorageError, + TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, + }) { + return unexpectedError?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_ServerError value)? serverError, + TResult Function(_UnexpectedError value)? unexpectedError, + TResult Function(_Empty value)? empty, + TResult Function(_LocalStorageError value)? localStorageError, + TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, + required TResult orElse(), + }) { + if (unexpectedError != null) { + return unexpectedError(this); + } + return orElse(); + } +} + +abstract class _UnexpectedError implements OrderFailure { + const factory _UnexpectedError() = _$UnexpectedErrorImpl; +} + +/// @nodoc +abstract class _$$EmptyImplCopyWith<$Res> { + factory _$$EmptyImplCopyWith( + _$EmptyImpl value, + $Res Function(_$EmptyImpl) then, + ) = __$$EmptyImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$EmptyImplCopyWithImpl<$Res> + extends _$OrderFailureCopyWithImpl<$Res, _$EmptyImpl> + implements _$$EmptyImplCopyWith<$Res> { + __$$EmptyImplCopyWithImpl( + _$EmptyImpl _value, + $Res Function(_$EmptyImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$EmptyImpl implements _Empty { + const _$EmptyImpl(); + + @override + String toString() { + return 'OrderFailure.empty()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$EmptyImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(ApiFailure failure) serverError, + required TResult Function() unexpectedError, + required TResult Function() empty, + required TResult Function(String erroMessage) localStorageError, + required TResult Function(String erroMessage) dynamicErrorMessage, + }) { + return empty(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(ApiFailure failure)? serverError, + TResult? Function()? unexpectedError, + TResult? Function()? empty, + TResult? Function(String erroMessage)? localStorageError, + TResult? Function(String erroMessage)? dynamicErrorMessage, + }) { + return empty?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(ApiFailure failure)? serverError, + TResult Function()? unexpectedError, + TResult Function()? empty, + TResult Function(String erroMessage)? localStorageError, + TResult Function(String erroMessage)? dynamicErrorMessage, + required TResult orElse(), + }) { + if (empty != null) { + return empty(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_ServerError value) serverError, + required TResult Function(_UnexpectedError value) unexpectedError, + required TResult Function(_Empty value) empty, + required TResult Function(_LocalStorageError value) localStorageError, + required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, + }) { + return empty(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_ServerError value)? serverError, + TResult? Function(_UnexpectedError value)? unexpectedError, + TResult? Function(_Empty value)? empty, + TResult? Function(_LocalStorageError value)? localStorageError, + TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, + }) { + return empty?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_ServerError value)? serverError, + TResult Function(_UnexpectedError value)? unexpectedError, + TResult Function(_Empty value)? empty, + TResult Function(_LocalStorageError value)? localStorageError, + TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, + required TResult orElse(), + }) { + if (empty != null) { + return empty(this); + } + return orElse(); + } +} + +abstract class _Empty implements OrderFailure { + const factory _Empty() = _$EmptyImpl; +} + +/// @nodoc +abstract class _$$LocalStorageErrorImplCopyWith<$Res> { + factory _$$LocalStorageErrorImplCopyWith( + _$LocalStorageErrorImpl value, + $Res Function(_$LocalStorageErrorImpl) then, + ) = __$$LocalStorageErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String erroMessage}); +} + +/// @nodoc +class __$$LocalStorageErrorImplCopyWithImpl<$Res> + extends _$OrderFailureCopyWithImpl<$Res, _$LocalStorageErrorImpl> + implements _$$LocalStorageErrorImplCopyWith<$Res> { + __$$LocalStorageErrorImplCopyWithImpl( + _$LocalStorageErrorImpl _value, + $Res Function(_$LocalStorageErrorImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? erroMessage = null}) { + return _then( + _$LocalStorageErrorImpl( + null == erroMessage + ? _value.erroMessage + : erroMessage // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$LocalStorageErrorImpl implements _LocalStorageError { + const _$LocalStorageErrorImpl(this.erroMessage); + + @override + final String erroMessage; + + @override + String toString() { + return 'OrderFailure.localStorageError(erroMessage: $erroMessage)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$LocalStorageErrorImpl && + (identical(other.erroMessage, erroMessage) || + other.erroMessage == erroMessage)); + } + + @override + int get hashCode => Object.hash(runtimeType, erroMessage); + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$LocalStorageErrorImplCopyWith<_$LocalStorageErrorImpl> get copyWith => + __$$LocalStorageErrorImplCopyWithImpl<_$LocalStorageErrorImpl>( + this, + _$identity, + ); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(ApiFailure failure) serverError, + required TResult Function() unexpectedError, + required TResult Function() empty, + required TResult Function(String erroMessage) localStorageError, + required TResult Function(String erroMessage) dynamicErrorMessage, + }) { + return localStorageError(erroMessage); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(ApiFailure failure)? serverError, + TResult? Function()? unexpectedError, + TResult? Function()? empty, + TResult? Function(String erroMessage)? localStorageError, + TResult? Function(String erroMessage)? dynamicErrorMessage, + }) { + return localStorageError?.call(erroMessage); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(ApiFailure failure)? serverError, + TResult Function()? unexpectedError, + TResult Function()? empty, + TResult Function(String erroMessage)? localStorageError, + TResult Function(String erroMessage)? dynamicErrorMessage, + required TResult orElse(), + }) { + if (localStorageError != null) { + return localStorageError(erroMessage); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_ServerError value) serverError, + required TResult Function(_UnexpectedError value) unexpectedError, + required TResult Function(_Empty value) empty, + required TResult Function(_LocalStorageError value) localStorageError, + required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, + }) { + return localStorageError(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_ServerError value)? serverError, + TResult? Function(_UnexpectedError value)? unexpectedError, + TResult? Function(_Empty value)? empty, + TResult? Function(_LocalStorageError value)? localStorageError, + TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, + }) { + return localStorageError?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_ServerError value)? serverError, + TResult Function(_UnexpectedError value)? unexpectedError, + TResult Function(_Empty value)? empty, + TResult Function(_LocalStorageError value)? localStorageError, + TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, + required TResult orElse(), + }) { + if (localStorageError != null) { + return localStorageError(this); + } + return orElse(); + } +} + +abstract class _LocalStorageError implements OrderFailure { + const factory _LocalStorageError(final String erroMessage) = + _$LocalStorageErrorImpl; + + String get erroMessage; + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$LocalStorageErrorImplCopyWith<_$LocalStorageErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$DynamicErrorMessageImplCopyWith<$Res> { + factory _$$DynamicErrorMessageImplCopyWith( + _$DynamicErrorMessageImpl value, + $Res Function(_$DynamicErrorMessageImpl) then, + ) = __$$DynamicErrorMessageImplCopyWithImpl<$Res>; + @useResult + $Res call({String erroMessage}); +} + +/// @nodoc +class __$$DynamicErrorMessageImplCopyWithImpl<$Res> + extends _$OrderFailureCopyWithImpl<$Res, _$DynamicErrorMessageImpl> + implements _$$DynamicErrorMessageImplCopyWith<$Res> { + __$$DynamicErrorMessageImplCopyWithImpl( + _$DynamicErrorMessageImpl _value, + $Res Function(_$DynamicErrorMessageImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? erroMessage = null}) { + return _then( + _$DynamicErrorMessageImpl( + null == erroMessage + ? _value.erroMessage + : erroMessage // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$DynamicErrorMessageImpl implements _DynamicErrorMessage { + const _$DynamicErrorMessageImpl(this.erroMessage); + + @override + final String erroMessage; + + @override + String toString() { + return 'OrderFailure.dynamicErrorMessage(erroMessage: $erroMessage)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DynamicErrorMessageImpl && + (identical(other.erroMessage, erroMessage) || + other.erroMessage == erroMessage)); + } + + @override + int get hashCode => Object.hash(runtimeType, erroMessage); + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DynamicErrorMessageImplCopyWith<_$DynamicErrorMessageImpl> get copyWith => + __$$DynamicErrorMessageImplCopyWithImpl<_$DynamicErrorMessageImpl>( + this, + _$identity, + ); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(ApiFailure failure) serverError, + required TResult Function() unexpectedError, + required TResult Function() empty, + required TResult Function(String erroMessage) localStorageError, + required TResult Function(String erroMessage) dynamicErrorMessage, + }) { + return dynamicErrorMessage(erroMessage); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(ApiFailure failure)? serverError, + TResult? Function()? unexpectedError, + TResult? Function()? empty, + TResult? Function(String erroMessage)? localStorageError, + TResult? Function(String erroMessage)? dynamicErrorMessage, + }) { + return dynamicErrorMessage?.call(erroMessage); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(ApiFailure failure)? serverError, + TResult Function()? unexpectedError, + TResult Function()? empty, + TResult Function(String erroMessage)? localStorageError, + TResult Function(String erroMessage)? dynamicErrorMessage, + required TResult orElse(), + }) { + if (dynamicErrorMessage != null) { + return dynamicErrorMessage(erroMessage); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_ServerError value) serverError, + required TResult Function(_UnexpectedError value) unexpectedError, + required TResult Function(_Empty value) empty, + required TResult Function(_LocalStorageError value) localStorageError, + required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, + }) { + return dynamicErrorMessage(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_ServerError value)? serverError, + TResult? Function(_UnexpectedError value)? unexpectedError, + TResult? Function(_Empty value)? empty, + TResult? Function(_LocalStorageError value)? localStorageError, + TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, + }) { + return dynamicErrorMessage?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_ServerError value)? serverError, + TResult Function(_UnexpectedError value)? unexpectedError, + TResult Function(_Empty value)? empty, + TResult Function(_LocalStorageError value)? localStorageError, + TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, + required TResult orElse(), + }) { + if (dynamicErrorMessage != null) { + return dynamicErrorMessage(this); + } + return orElse(); + } +} + +abstract class _DynamicErrorMessage implements OrderFailure { + const factory _DynamicErrorMessage(final String erroMessage) = + _$DynamicErrorMessageImpl; + + String get erroMessage; + + /// Create a copy of OrderFailure + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DynamicErrorMessageImplCopyWith<_$DynamicErrorMessageImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/domain/order/repositories/i_order_repository.dart b/lib/domain/order/repositories/i_order_repository.dart new file mode 100644 index 0000000..2be8539 --- /dev/null +++ b/lib/domain/order/repositories/i_order_repository.dart @@ -0,0 +1,12 @@ +part of '../order.dart'; + +abstract class IOrderRepository { + Future> getOrders({ + int page = 1, + int limit = 10, + String status = 'completed', + required DateTime startDate, + required DateTime endDate, + String? search, + }); +} diff --git a/lib/infrastructure/order/datasources/remote_data_provider.dart b/lib/infrastructure/order/datasources/remote_data_provider.dart new file mode 100644 index 0000000..66d59d4 --- /dev/null +++ b/lib/infrastructure/order/datasources/remote_data_provider.dart @@ -0,0 +1,61 @@ +import 'dart:developer'; + +import 'package:data_channel/data_channel.dart'; +import 'package:injectable/injectable.dart'; +import 'package:intl/intl.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/order/order.dart'; +import '../order_dtos.dart'; + +@injectable +class OrderRemoteDataProvider { + final ApiClient _apiClient; + final _logName = 'OrderRemoteDataProvider'; + OrderRemoteDataProvider(this._apiClient); + + Future> fetchOrders({ + int page = 1, + int limit = 10, + String status = 'completed', + required DateTime startDate, + required DateTime endDate, + String? search, + }) async { + try { + Map params = { + 'page': page, + 'limit': limit, + 'status': status, + 'date_from': DateFormat('dd-MM-yyyy').format(startDate), + 'date_to': DateFormat('dd-MM-yyyy').format(endDate), + }; + + if (search != null && search.isNotEmpty) { + params['search'] = search; + } + + final response = await _apiClient.get( + ApiPath.orders, + params: params, + headers: getAuthorizationHeader(), + ); + + if (response.data['success'] == false) { + return DC.error(OrderFailure.unexpectedError()); + } + + final orders = ListOrderDto.fromJson( + response.data['data'] as Map, + ); + + return DC.data(orders); + } on ApiFailure catch (e, s) { + log('fetchOrderError', name: _logName, error: e, stackTrace: s); + return DC.error(OrderFailure.serverError(e)); + } + } +} diff --git a/lib/infrastructure/order/dtos/order_dto.dart b/lib/infrastructure/order/dtos/order_dto.dart new file mode 100644 index 0000000..fba1391 --- /dev/null +++ b/lib/infrastructure/order/dtos/order_dto.dart @@ -0,0 +1,182 @@ +part of '../order_dtos.dart'; + +@freezed +class ListOrderDto with _$ListOrderDto { + const ListOrderDto._(); + + const factory ListOrderDto({ + @JsonKey(name: "orders") List? orders, + @JsonKey(name: 'total_count') int? totalCount, + @JsonKey(name: 'page') int? page, + @JsonKey(name: 'limit') int? limit, + @JsonKey(name: 'total_pages') int? totalPages, + }) = _ListOrderDto; + + factory ListOrderDto.fromJson(Map json) => + _$ListOrderDtoFromJson(json); + + ListOrder toDomain() => ListOrder( + orders: orders?.map((e) => e.toDomain()).toList() ?? [], + totalCount: totalCount ?? 0, + page: page ?? 0, + limit: limit ?? 0, + totalPages: totalPages ?? 0, + ); +} + +@freezed +class OrderDto with _$OrderDto { + const OrderDto._(); + + const factory OrderDto({ + @JsonKey(name: "id") String? id, + @JsonKey(name: "order_number") String? orderNumber, + @JsonKey(name: "outlet_id") String? outletId, + @JsonKey(name: "user_id") String? userId, + @JsonKey(name: "table_number") String? tableNumber, + @JsonKey(name: "order_type") String? orderType, + @JsonKey(name: "status") String? status, + @JsonKey(name: "subtotal") int? subtotal, + @JsonKey(name: "tax_amount") int? taxAmount, + @JsonKey(name: "discount_amount") int? discountAmount, + @JsonKey(name: "total_amount") int? totalAmount, + @JsonKey(name: "total_cost") num? totalCost, + @JsonKey(name: "remaining_amount") int? remainingAmount, + @JsonKey(name: "payment_status") String? paymentStatus, + @JsonKey(name: "refund_amount") int? refundAmount, + @JsonKey(name: "is_void") bool? isVoid, + @JsonKey(name: "is_refund") bool? isRefund, + @JsonKey(name: "notes") String? notes, + @JsonKey(name: "metadata") Map? metadata, + @JsonKey(name: "created_at") String? createdAt, + @JsonKey(name: "updated_at") String? updatedAt, + @JsonKey(name: "order_items") List? orderItems, + @JsonKey(name: "payments") List? payments, + @JsonKey(name: "total_paid") int? totalPaid, + @JsonKey(name: "payment_count") int? paymentCount, + @JsonKey(name: "split_type") String? splitType, + }) = _OrderDto; + + factory OrderDto.fromJson(Map json) => + _$OrderDtoFromJson(json); + + // Optional: mapper ke domain entity + Order toDomain() => Order( + id: id ?? '', + orderNumber: orderNumber ?? '', + outletId: outletId ?? '', + userId: userId ?? '', + tableNumber: tableNumber ?? '', + orderType: orderType ?? '', + status: status ?? '', + subtotal: subtotal ?? 0, + taxAmount: taxAmount ?? 0, + discountAmount: discountAmount ?? 0, + totalAmount: totalAmount ?? 0, + totalCost: totalCost ?? 0, + remainingAmount: remainingAmount ?? 0, + paymentStatus: paymentStatus ?? '', + refundAmount: refundAmount ?? 0, + isVoid: isVoid ?? false, + isRefund: isRefund ?? false, + notes: notes ?? '', + metadata: metadata ?? const {}, + createdAt: createdAt != null ? DateTime.parse(createdAt!) : DateTime(1970), + updatedAt: updatedAt != null ? DateTime.parse(updatedAt!) : DateTime(1970), + orderItems: orderItems?.map((e) => e.toDomain()).toList() ?? const [], + payments: payments?.map((e) => e.toDomain()).toList() ?? const [], + totalPaid: totalPaid ?? 0, + paymentCount: paymentCount ?? 0, + splitType: splitType ?? '', + ); +} + +@freezed +class OrderItemDto with _$OrderItemDto { + const OrderItemDto._(); + + const factory OrderItemDto({ + @JsonKey(name: "id") String? id, + @JsonKey(name: "order_id") String? orderId, + @JsonKey(name: "product_id") String? productId, + @JsonKey(name: "product_name") String? productName, + @JsonKey(name: "product_variant_id") String? productVariantId, + @JsonKey(name: "product_variant_name") String? productVariantName, + @JsonKey(name: "quantity") int? quantity, + @JsonKey(name: "unit_price") int? unitPrice, + @JsonKey(name: "total_price") int? totalPrice, + @JsonKey(name: "modifiers") List? modifiers, + @JsonKey(name: "notes") String? notes, + @JsonKey(name: "status") String? status, + @JsonKey(name: "created_at") String? createdAt, + @JsonKey(name: "updated_at") String? updatedAt, + @JsonKey(name: "printer_type") String? printerType, + @JsonKey(name: "paid_quantity") int? paidQuantity, + }) = _OrderItemDto; + + factory OrderItemDto.fromJson(Map json) => + _$OrderItemDtoFromJson(json); + + // Optional mapper to domain entity + OrderItem toDomain() => OrderItem( + id: id ?? '', + orderId: orderId ?? '', + productId: productId ?? '', + productName: productName ?? '', + productVariantId: productVariantId ?? '', + productVariantName: productVariantName ?? '', + quantity: quantity ?? 0, + unitPrice: unitPrice ?? 0, + totalPrice: totalPrice ?? 0, + modifiers: modifiers ?? [], + notes: notes ?? '', + status: status ?? '', + createdAt: createdAt != null ? DateTime.parse(createdAt!) : DateTime(1970), + updatedAt: updatedAt != null ? DateTime.parse(updatedAt!) : DateTime(1970), + printerType: printerType ?? '', + paidQuantity: paidQuantity ?? 0, + ); +} + +@freezed +class PaymentOrderDto with _$PaymentOrderDto { + const PaymentOrderDto._(); + + const factory PaymentOrderDto({ + @JsonKey(name: "id") String? id, + @JsonKey(name: "order_id") String? orderId, + @JsonKey(name: "payment_method_id") String? paymentMethodId, + @JsonKey(name: "payment_method_name") String? paymentMethodName, + @JsonKey(name: "payment_method_type") String? paymentMethodType, + @JsonKey(name: "amount") int? amount, + @JsonKey(name: "status") String? status, + @JsonKey(name: "split_number") int? splitNumber, + @JsonKey(name: "split_total") int? splitTotal, + @JsonKey(name: "split_description") String? splitDescription, + @JsonKey(name: "refund_amount") int? refundAmount, + @JsonKey(name: "metadata") Map? metadata, + @JsonKey(name: "created_at") String? createdAt, + @JsonKey(name: "updated_at") String? updatedAt, + }) = _PaymentOrderDto; + + factory PaymentOrderDto.fromJson(Map json) => + _$PaymentOrderDtoFromJson(json); + + // Optional mapper ke domain entity + PaymentOrder toDomain() => PaymentOrder( + id: id ?? '', + orderId: orderId ?? '', + paymentMethodId: paymentMethodId ?? '', + paymentMethodName: paymentMethodName ?? '', + paymentMethodType: paymentMethodType ?? '', + amount: amount ?? 0, + status: status ?? '', + splitNumber: splitNumber ?? 0, + splitTotal: splitTotal ?? 0, + splitDescription: splitDescription ?? '', + refundAmount: refundAmount ?? 0, + metadata: metadata ?? const {}, + createdAt: createdAt != null ? DateTime.parse(createdAt!) : DateTime(1970), + updatedAt: updatedAt != null ? DateTime.parse(updatedAt!) : DateTime(1970), + ); +} diff --git a/lib/infrastructure/order/order_dtos.dart b/lib/infrastructure/order/order_dtos.dart new file mode 100644 index 0000000..426f2b5 --- /dev/null +++ b/lib/infrastructure/order/order_dtos.dart @@ -0,0 +1,8 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +import '../../domain/order/order.dart'; + +part 'order_dtos.freezed.dart'; +part 'order_dtos.g.dart'; + +part 'dtos/order_dto.dart'; diff --git a/lib/infrastructure/order/order_dtos.freezed.dart b/lib/infrastructure/order/order_dtos.freezed.dart new file mode 100644 index 0000000..6ff3d83 --- /dev/null +++ b/lib/infrastructure/order/order_dtos.freezed.dart @@ -0,0 +1,2165 @@ +// 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 'order_dtos.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(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', +); + +ListOrderDto _$ListOrderDtoFromJson(Map json) { + return _ListOrderDto.fromJson(json); +} + +/// @nodoc +mixin _$ListOrderDto { + @JsonKey(name: "orders") + List? get orders => 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 ListOrderDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of ListOrderDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ListOrderDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ListOrderDtoCopyWith<$Res> { + factory $ListOrderDtoCopyWith( + ListOrderDto value, + $Res Function(ListOrderDto) then, + ) = _$ListOrderDtoCopyWithImpl<$Res, ListOrderDto>; + @useResult + $Res call({ + @JsonKey(name: "orders") List? orders, + @JsonKey(name: 'total_count') int? totalCount, + @JsonKey(name: 'page') int? page, + @JsonKey(name: 'limit') int? limit, + @JsonKey(name: 'total_pages') int? totalPages, + }); +} + +/// @nodoc +class _$ListOrderDtoCopyWithImpl<$Res, $Val extends ListOrderDto> + implements $ListOrderDtoCopyWith<$Res> { + _$ListOrderDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of ListOrderDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? orders = freezed, + Object? totalCount = freezed, + Object? page = freezed, + Object? limit = freezed, + Object? totalPages = freezed, + }) { + return _then( + _value.copyWith( + orders: freezed == orders + ? _value.orders + : orders // ignore: cast_nullable_to_non_nullable + as List?, + 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 _$$ListOrderDtoImplCopyWith<$Res> + implements $ListOrderDtoCopyWith<$Res> { + factory _$$ListOrderDtoImplCopyWith( + _$ListOrderDtoImpl value, + $Res Function(_$ListOrderDtoImpl) then, + ) = __$$ListOrderDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: "orders") List? orders, + @JsonKey(name: 'total_count') int? totalCount, + @JsonKey(name: 'page') int? page, + @JsonKey(name: 'limit') int? limit, + @JsonKey(name: 'total_pages') int? totalPages, + }); +} + +/// @nodoc +class __$$ListOrderDtoImplCopyWithImpl<$Res> + extends _$ListOrderDtoCopyWithImpl<$Res, _$ListOrderDtoImpl> + implements _$$ListOrderDtoImplCopyWith<$Res> { + __$$ListOrderDtoImplCopyWithImpl( + _$ListOrderDtoImpl _value, + $Res Function(_$ListOrderDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of ListOrderDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? orders = freezed, + Object? totalCount = freezed, + Object? page = freezed, + Object? limit = freezed, + Object? totalPages = freezed, + }) { + return _then( + _$ListOrderDtoImpl( + orders: freezed == orders + ? _value._orders + : orders // ignore: cast_nullable_to_non_nullable + as List?, + 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 _$ListOrderDtoImpl extends _ListOrderDto { + const _$ListOrderDtoImpl({ + @JsonKey(name: "orders") final List? orders, + @JsonKey(name: 'total_count') this.totalCount, + @JsonKey(name: 'page') this.page, + @JsonKey(name: 'limit') this.limit, + @JsonKey(name: 'total_pages') this.totalPages, + }) : _orders = orders, + super._(); + + factory _$ListOrderDtoImpl.fromJson(Map json) => + _$$ListOrderDtoImplFromJson(json); + + final List? _orders; + @override + @JsonKey(name: "orders") + List? get orders { + final value = _orders; + if (value == null) return null; + if (_orders is EqualUnmodifiableListView) return _orders; + // 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() { + return 'ListOrderDto(orders: $orders, totalCount: $totalCount, page: $page, limit: $limit, totalPages: $totalPages)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ListOrderDtoImpl && + const DeepCollectionEquality().equals(other._orders, _orders) && + (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(_orders), + totalCount, + page, + limit, + totalPages, + ); + + /// Create a copy of ListOrderDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ListOrderDtoImplCopyWith<_$ListOrderDtoImpl> get copyWith => + __$$ListOrderDtoImplCopyWithImpl<_$ListOrderDtoImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ListOrderDtoImplToJson(this); + } +} + +abstract class _ListOrderDto extends ListOrderDto { + const factory _ListOrderDto({ + @JsonKey(name: "orders") final List? orders, + @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, + }) = _$ListOrderDtoImpl; + const _ListOrderDto._() : super._(); + + factory _ListOrderDto.fromJson(Map json) = + _$ListOrderDtoImpl.fromJson; + + @override + @JsonKey(name: "orders") + List? get orders; + @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 ListOrderDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ListOrderDtoImplCopyWith<_$ListOrderDtoImpl> get copyWith => + throw _privateConstructorUsedError; +} + +OrderDto _$OrderDtoFromJson(Map json) { + return _OrderDto.fromJson(json); +} + +/// @nodoc +mixin _$OrderDto { + @JsonKey(name: "id") + String? get id => throw _privateConstructorUsedError; + @JsonKey(name: "order_number") + String? get orderNumber => throw _privateConstructorUsedError; + @JsonKey(name: "outlet_id") + String? get outletId => throw _privateConstructorUsedError; + @JsonKey(name: "user_id") + String? get userId => throw _privateConstructorUsedError; + @JsonKey(name: "table_number") + String? get tableNumber => throw _privateConstructorUsedError; + @JsonKey(name: "order_type") + String? get orderType => throw _privateConstructorUsedError; + @JsonKey(name: "status") + String? get status => throw _privateConstructorUsedError; + @JsonKey(name: "subtotal") + int? get subtotal => throw _privateConstructorUsedError; + @JsonKey(name: "tax_amount") + int? get taxAmount => throw _privateConstructorUsedError; + @JsonKey(name: "discount_amount") + int? get discountAmount => throw _privateConstructorUsedError; + @JsonKey(name: "total_amount") + int? get totalAmount => throw _privateConstructorUsedError; + @JsonKey(name: "total_cost") + num? get totalCost => throw _privateConstructorUsedError; + @JsonKey(name: "remaining_amount") + int? get remainingAmount => throw _privateConstructorUsedError; + @JsonKey(name: "payment_status") + String? get paymentStatus => throw _privateConstructorUsedError; + @JsonKey(name: "refund_amount") + int? get refundAmount => throw _privateConstructorUsedError; + @JsonKey(name: "is_void") + bool? get isVoid => throw _privateConstructorUsedError; + @JsonKey(name: "is_refund") + bool? get isRefund => throw _privateConstructorUsedError; + @JsonKey(name: "notes") + String? get notes => throw _privateConstructorUsedError; + @JsonKey(name: "metadata") + Map? get metadata => throw _privateConstructorUsedError; + @JsonKey(name: "created_at") + String? get createdAt => throw _privateConstructorUsedError; + @JsonKey(name: "updated_at") + String? get updatedAt => throw _privateConstructorUsedError; + @JsonKey(name: "order_items") + List? get orderItems => throw _privateConstructorUsedError; + @JsonKey(name: "payments") + List? get payments => throw _privateConstructorUsedError; + @JsonKey(name: "total_paid") + int? get totalPaid => throw _privateConstructorUsedError; + @JsonKey(name: "payment_count") + int? get paymentCount => throw _privateConstructorUsedError; + @JsonKey(name: "split_type") + String? get splitType => throw _privateConstructorUsedError; + + /// Serializes this OrderDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of OrderDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $OrderDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OrderDtoCopyWith<$Res> { + factory $OrderDtoCopyWith(OrderDto value, $Res Function(OrderDto) then) = + _$OrderDtoCopyWithImpl<$Res, OrderDto>; + @useResult + $Res call({ + @JsonKey(name: "id") String? id, + @JsonKey(name: "order_number") String? orderNumber, + @JsonKey(name: "outlet_id") String? outletId, + @JsonKey(name: "user_id") String? userId, + @JsonKey(name: "table_number") String? tableNumber, + @JsonKey(name: "order_type") String? orderType, + @JsonKey(name: "status") String? status, + @JsonKey(name: "subtotal") int? subtotal, + @JsonKey(name: "tax_amount") int? taxAmount, + @JsonKey(name: "discount_amount") int? discountAmount, + @JsonKey(name: "total_amount") int? totalAmount, + @JsonKey(name: "total_cost") num? totalCost, + @JsonKey(name: "remaining_amount") int? remainingAmount, + @JsonKey(name: "payment_status") String? paymentStatus, + @JsonKey(name: "refund_amount") int? refundAmount, + @JsonKey(name: "is_void") bool? isVoid, + @JsonKey(name: "is_refund") bool? isRefund, + @JsonKey(name: "notes") String? notes, + @JsonKey(name: "metadata") Map? metadata, + @JsonKey(name: "created_at") String? createdAt, + @JsonKey(name: "updated_at") String? updatedAt, + @JsonKey(name: "order_items") List? orderItems, + @JsonKey(name: "payments") List? payments, + @JsonKey(name: "total_paid") int? totalPaid, + @JsonKey(name: "payment_count") int? paymentCount, + @JsonKey(name: "split_type") String? splitType, + }); +} + +/// @nodoc +class _$OrderDtoCopyWithImpl<$Res, $Val extends OrderDto> + implements $OrderDtoCopyWith<$Res> { + _$OrderDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of OrderDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? orderNumber = freezed, + Object? outletId = freezed, + Object? userId = freezed, + Object? tableNumber = freezed, + Object? orderType = freezed, + Object? status = freezed, + Object? subtotal = freezed, + Object? taxAmount = freezed, + Object? discountAmount = freezed, + Object? totalAmount = freezed, + Object? totalCost = freezed, + Object? remainingAmount = freezed, + Object? paymentStatus = freezed, + Object? refundAmount = freezed, + Object? isVoid = freezed, + Object? isRefund = freezed, + Object? notes = freezed, + Object? metadata = freezed, + Object? createdAt = freezed, + Object? updatedAt = freezed, + Object? orderItems = freezed, + Object? payments = freezed, + Object? totalPaid = freezed, + Object? paymentCount = freezed, + Object? splitType = freezed, + }) { + return _then( + _value.copyWith( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + orderNumber: freezed == orderNumber + ? _value.orderNumber + : orderNumber // ignore: cast_nullable_to_non_nullable + as String?, + outletId: freezed == outletId + ? _value.outletId + : outletId // ignore: cast_nullable_to_non_nullable + as String?, + userId: freezed == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as String?, + tableNumber: freezed == tableNumber + ? _value.tableNumber + : tableNumber // ignore: cast_nullable_to_non_nullable + as String?, + orderType: freezed == orderType + ? _value.orderType + : orderType // ignore: cast_nullable_to_non_nullable + as String?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + subtotal: freezed == subtotal + ? _value.subtotal + : subtotal // ignore: cast_nullable_to_non_nullable + as int?, + taxAmount: freezed == taxAmount + ? _value.taxAmount + : taxAmount // ignore: cast_nullable_to_non_nullable + as int?, + discountAmount: freezed == discountAmount + ? _value.discountAmount + : discountAmount // ignore: cast_nullable_to_non_nullable + as int?, + totalAmount: freezed == totalAmount + ? _value.totalAmount + : totalAmount // ignore: cast_nullable_to_non_nullable + as int?, + totalCost: freezed == totalCost + ? _value.totalCost + : totalCost // ignore: cast_nullable_to_non_nullable + as num?, + remainingAmount: freezed == remainingAmount + ? _value.remainingAmount + : remainingAmount // ignore: cast_nullable_to_non_nullable + as int?, + paymentStatus: freezed == paymentStatus + ? _value.paymentStatus + : paymentStatus // ignore: cast_nullable_to_non_nullable + as String?, + refundAmount: freezed == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int?, + isVoid: freezed == isVoid + ? _value.isVoid + : isVoid // ignore: cast_nullable_to_non_nullable + as bool?, + isRefund: freezed == isRefund + ? _value.isRefund + : isRefund // ignore: cast_nullable_to_non_nullable + as bool?, + notes: freezed == notes + ? _value.notes + : notes // ignore: cast_nullable_to_non_nullable + as String?, + metadata: freezed == metadata + ? _value.metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map?, + 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?, + orderItems: freezed == orderItems + ? _value.orderItems + : orderItems // ignore: cast_nullable_to_non_nullable + as List?, + payments: freezed == payments + ? _value.payments + : payments // ignore: cast_nullable_to_non_nullable + as List?, + totalPaid: freezed == totalPaid + ? _value.totalPaid + : totalPaid // ignore: cast_nullable_to_non_nullable + as int?, + paymentCount: freezed == paymentCount + ? _value.paymentCount + : paymentCount // ignore: cast_nullable_to_non_nullable + as int?, + splitType: freezed == splitType + ? _value.splitType + : splitType // ignore: cast_nullable_to_non_nullable + as String?, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$OrderDtoImplCopyWith<$Res> + implements $OrderDtoCopyWith<$Res> { + factory _$$OrderDtoImplCopyWith( + _$OrderDtoImpl value, + $Res Function(_$OrderDtoImpl) then, + ) = __$$OrderDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: "id") String? id, + @JsonKey(name: "order_number") String? orderNumber, + @JsonKey(name: "outlet_id") String? outletId, + @JsonKey(name: "user_id") String? userId, + @JsonKey(name: "table_number") String? tableNumber, + @JsonKey(name: "order_type") String? orderType, + @JsonKey(name: "status") String? status, + @JsonKey(name: "subtotal") int? subtotal, + @JsonKey(name: "tax_amount") int? taxAmount, + @JsonKey(name: "discount_amount") int? discountAmount, + @JsonKey(name: "total_amount") int? totalAmount, + @JsonKey(name: "total_cost") num? totalCost, + @JsonKey(name: "remaining_amount") int? remainingAmount, + @JsonKey(name: "payment_status") String? paymentStatus, + @JsonKey(name: "refund_amount") int? refundAmount, + @JsonKey(name: "is_void") bool? isVoid, + @JsonKey(name: "is_refund") bool? isRefund, + @JsonKey(name: "notes") String? notes, + @JsonKey(name: "metadata") Map? metadata, + @JsonKey(name: "created_at") String? createdAt, + @JsonKey(name: "updated_at") String? updatedAt, + @JsonKey(name: "order_items") List? orderItems, + @JsonKey(name: "payments") List? payments, + @JsonKey(name: "total_paid") int? totalPaid, + @JsonKey(name: "payment_count") int? paymentCount, + @JsonKey(name: "split_type") String? splitType, + }); +} + +/// @nodoc +class __$$OrderDtoImplCopyWithImpl<$Res> + extends _$OrderDtoCopyWithImpl<$Res, _$OrderDtoImpl> + implements _$$OrderDtoImplCopyWith<$Res> { + __$$OrderDtoImplCopyWithImpl( + _$OrderDtoImpl _value, + $Res Function(_$OrderDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? orderNumber = freezed, + Object? outletId = freezed, + Object? userId = freezed, + Object? tableNumber = freezed, + Object? orderType = freezed, + Object? status = freezed, + Object? subtotal = freezed, + Object? taxAmount = freezed, + Object? discountAmount = freezed, + Object? totalAmount = freezed, + Object? totalCost = freezed, + Object? remainingAmount = freezed, + Object? paymentStatus = freezed, + Object? refundAmount = freezed, + Object? isVoid = freezed, + Object? isRefund = freezed, + Object? notes = freezed, + Object? metadata = freezed, + Object? createdAt = freezed, + Object? updatedAt = freezed, + Object? orderItems = freezed, + Object? payments = freezed, + Object? totalPaid = freezed, + Object? paymentCount = freezed, + Object? splitType = freezed, + }) { + return _then( + _$OrderDtoImpl( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + orderNumber: freezed == orderNumber + ? _value.orderNumber + : orderNumber // ignore: cast_nullable_to_non_nullable + as String?, + outletId: freezed == outletId + ? _value.outletId + : outletId // ignore: cast_nullable_to_non_nullable + as String?, + userId: freezed == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as String?, + tableNumber: freezed == tableNumber + ? _value.tableNumber + : tableNumber // ignore: cast_nullable_to_non_nullable + as String?, + orderType: freezed == orderType + ? _value.orderType + : orderType // ignore: cast_nullable_to_non_nullable + as String?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + subtotal: freezed == subtotal + ? _value.subtotal + : subtotal // ignore: cast_nullable_to_non_nullable + as int?, + taxAmount: freezed == taxAmount + ? _value.taxAmount + : taxAmount // ignore: cast_nullable_to_non_nullable + as int?, + discountAmount: freezed == discountAmount + ? _value.discountAmount + : discountAmount // ignore: cast_nullable_to_non_nullable + as int?, + totalAmount: freezed == totalAmount + ? _value.totalAmount + : totalAmount // ignore: cast_nullable_to_non_nullable + as int?, + totalCost: freezed == totalCost + ? _value.totalCost + : totalCost // ignore: cast_nullable_to_non_nullable + as num?, + remainingAmount: freezed == remainingAmount + ? _value.remainingAmount + : remainingAmount // ignore: cast_nullable_to_non_nullable + as int?, + paymentStatus: freezed == paymentStatus + ? _value.paymentStatus + : paymentStatus // ignore: cast_nullable_to_non_nullable + as String?, + refundAmount: freezed == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int?, + isVoid: freezed == isVoid + ? _value.isVoid + : isVoid // ignore: cast_nullable_to_non_nullable + as bool?, + isRefund: freezed == isRefund + ? _value.isRefund + : isRefund // ignore: cast_nullable_to_non_nullable + as bool?, + notes: freezed == notes + ? _value.notes + : notes // ignore: cast_nullable_to_non_nullable + as String?, + metadata: freezed == metadata + ? _value._metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map?, + 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?, + orderItems: freezed == orderItems + ? _value._orderItems + : orderItems // ignore: cast_nullable_to_non_nullable + as List?, + payments: freezed == payments + ? _value._payments + : payments // ignore: cast_nullable_to_non_nullable + as List?, + totalPaid: freezed == totalPaid + ? _value.totalPaid + : totalPaid // ignore: cast_nullable_to_non_nullable + as int?, + paymentCount: freezed == paymentCount + ? _value.paymentCount + : paymentCount // ignore: cast_nullable_to_non_nullable + as int?, + splitType: freezed == splitType + ? _value.splitType + : splitType // ignore: cast_nullable_to_non_nullable + as String?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$OrderDtoImpl extends _OrderDto { + const _$OrderDtoImpl({ + @JsonKey(name: "id") this.id, + @JsonKey(name: "order_number") this.orderNumber, + @JsonKey(name: "outlet_id") this.outletId, + @JsonKey(name: "user_id") this.userId, + @JsonKey(name: "table_number") this.tableNumber, + @JsonKey(name: "order_type") this.orderType, + @JsonKey(name: "status") this.status, + @JsonKey(name: "subtotal") this.subtotal, + @JsonKey(name: "tax_amount") this.taxAmount, + @JsonKey(name: "discount_amount") this.discountAmount, + @JsonKey(name: "total_amount") this.totalAmount, + @JsonKey(name: "total_cost") this.totalCost, + @JsonKey(name: "remaining_amount") this.remainingAmount, + @JsonKey(name: "payment_status") this.paymentStatus, + @JsonKey(name: "refund_amount") this.refundAmount, + @JsonKey(name: "is_void") this.isVoid, + @JsonKey(name: "is_refund") this.isRefund, + @JsonKey(name: "notes") this.notes, + @JsonKey(name: "metadata") final Map? metadata, + @JsonKey(name: "created_at") this.createdAt, + @JsonKey(name: "updated_at") this.updatedAt, + @JsonKey(name: "order_items") final List? orderItems, + @JsonKey(name: "payments") final List? payments, + @JsonKey(name: "total_paid") this.totalPaid, + @JsonKey(name: "payment_count") this.paymentCount, + @JsonKey(name: "split_type") this.splitType, + }) : _metadata = metadata, + _orderItems = orderItems, + _payments = payments, + super._(); + + factory _$OrderDtoImpl.fromJson(Map json) => + _$$OrderDtoImplFromJson(json); + + @override + @JsonKey(name: "id") + final String? id; + @override + @JsonKey(name: "order_number") + final String? orderNumber; + @override + @JsonKey(name: "outlet_id") + final String? outletId; + @override + @JsonKey(name: "user_id") + final String? userId; + @override + @JsonKey(name: "table_number") + final String? tableNumber; + @override + @JsonKey(name: "order_type") + final String? orderType; + @override + @JsonKey(name: "status") + final String? status; + @override + @JsonKey(name: "subtotal") + final int? subtotal; + @override + @JsonKey(name: "tax_amount") + final int? taxAmount; + @override + @JsonKey(name: "discount_amount") + final int? discountAmount; + @override + @JsonKey(name: "total_amount") + final int? totalAmount; + @override + @JsonKey(name: "total_cost") + final num? totalCost; + @override + @JsonKey(name: "remaining_amount") + final int? remainingAmount; + @override + @JsonKey(name: "payment_status") + final String? paymentStatus; + @override + @JsonKey(name: "refund_amount") + final int? refundAmount; + @override + @JsonKey(name: "is_void") + final bool? isVoid; + @override + @JsonKey(name: "is_refund") + final bool? isRefund; + @override + @JsonKey(name: "notes") + final String? notes; + final Map? _metadata; + @override + @JsonKey(name: "metadata") + Map? 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; + final List? _orderItems; + @override + @JsonKey(name: "order_items") + List? get orderItems { + final value = _orderItems; + if (value == null) return null; + if (_orderItems is EqualUnmodifiableListView) return _orderItems; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + final List? _payments; + @override + @JsonKey(name: "payments") + List? get payments { + final value = _payments; + if (value == null) return null; + if (_payments is EqualUnmodifiableListView) return _payments; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + @JsonKey(name: "total_paid") + final int? totalPaid; + @override + @JsonKey(name: "payment_count") + final int? paymentCount; + @override + @JsonKey(name: "split_type") + final String? splitType; + + @override + String toString() { + return 'OrderDto(id: $id, orderNumber: $orderNumber, outletId: $outletId, userId: $userId, tableNumber: $tableNumber, orderType: $orderType, status: $status, subtotal: $subtotal, taxAmount: $taxAmount, discountAmount: $discountAmount, totalAmount: $totalAmount, totalCost: $totalCost, remainingAmount: $remainingAmount, paymentStatus: $paymentStatus, refundAmount: $refundAmount, isVoid: $isVoid, isRefund: $isRefund, notes: $notes, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt, orderItems: $orderItems, payments: $payments, totalPaid: $totalPaid, paymentCount: $paymentCount, splitType: $splitType)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$OrderDtoImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.orderNumber, orderNumber) || + other.orderNumber == orderNumber) && + (identical(other.outletId, outletId) || + other.outletId == outletId) && + (identical(other.userId, userId) || other.userId == userId) && + (identical(other.tableNumber, tableNumber) || + other.tableNumber == tableNumber) && + (identical(other.orderType, orderType) || + other.orderType == orderType) && + (identical(other.status, status) || other.status == status) && + (identical(other.subtotal, subtotal) || + other.subtotal == subtotal) && + (identical(other.taxAmount, taxAmount) || + other.taxAmount == taxAmount) && + (identical(other.discountAmount, discountAmount) || + other.discountAmount == discountAmount) && + (identical(other.totalAmount, totalAmount) || + other.totalAmount == totalAmount) && + (identical(other.totalCost, totalCost) || + other.totalCost == totalCost) && + (identical(other.remainingAmount, remainingAmount) || + other.remainingAmount == remainingAmount) && + (identical(other.paymentStatus, paymentStatus) || + other.paymentStatus == paymentStatus) && + (identical(other.refundAmount, refundAmount) || + other.refundAmount == refundAmount) && + (identical(other.isVoid, isVoid) || other.isVoid == isVoid) && + (identical(other.isRefund, isRefund) || + other.isRefund == isRefund) && + (identical(other.notes, notes) || other.notes == notes) && + const DeepCollectionEquality().equals(other._metadata, _metadata) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt) && + const DeepCollectionEquality().equals( + other._orderItems, + _orderItems, + ) && + const DeepCollectionEquality().equals(other._payments, _payments) && + (identical(other.totalPaid, totalPaid) || + other.totalPaid == totalPaid) && + (identical(other.paymentCount, paymentCount) || + other.paymentCount == paymentCount) && + (identical(other.splitType, splitType) || + other.splitType == splitType)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hashAll([ + runtimeType, + id, + orderNumber, + outletId, + userId, + tableNumber, + orderType, + status, + subtotal, + taxAmount, + discountAmount, + totalAmount, + totalCost, + remainingAmount, + paymentStatus, + refundAmount, + isVoid, + isRefund, + notes, + const DeepCollectionEquality().hash(_metadata), + createdAt, + updatedAt, + const DeepCollectionEquality().hash(_orderItems), + const DeepCollectionEquality().hash(_payments), + totalPaid, + paymentCount, + splitType, + ]); + + /// Create a copy of OrderDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$OrderDtoImplCopyWith<_$OrderDtoImpl> get copyWith => + __$$OrderDtoImplCopyWithImpl<_$OrderDtoImpl>(this, _$identity); + + @override + Map toJson() { + return _$$OrderDtoImplToJson(this); + } +} + +abstract class _OrderDto extends OrderDto { + const factory _OrderDto({ + @JsonKey(name: "id") final String? id, + @JsonKey(name: "order_number") final String? orderNumber, + @JsonKey(name: "outlet_id") final String? outletId, + @JsonKey(name: "user_id") final String? userId, + @JsonKey(name: "table_number") final String? tableNumber, + @JsonKey(name: "order_type") final String? orderType, + @JsonKey(name: "status") final String? status, + @JsonKey(name: "subtotal") final int? subtotal, + @JsonKey(name: "tax_amount") final int? taxAmount, + @JsonKey(name: "discount_amount") final int? discountAmount, + @JsonKey(name: "total_amount") final int? totalAmount, + @JsonKey(name: "total_cost") final num? totalCost, + @JsonKey(name: "remaining_amount") final int? remainingAmount, + @JsonKey(name: "payment_status") final String? paymentStatus, + @JsonKey(name: "refund_amount") final int? refundAmount, + @JsonKey(name: "is_void") final bool? isVoid, + @JsonKey(name: "is_refund") final bool? isRefund, + @JsonKey(name: "notes") final String? notes, + @JsonKey(name: "metadata") final Map? metadata, + @JsonKey(name: "created_at") final String? createdAt, + @JsonKey(name: "updated_at") final String? updatedAt, + @JsonKey(name: "order_items") final List? orderItems, + @JsonKey(name: "payments") final List? payments, + @JsonKey(name: "total_paid") final int? totalPaid, + @JsonKey(name: "payment_count") final int? paymentCount, + @JsonKey(name: "split_type") final String? splitType, + }) = _$OrderDtoImpl; + const _OrderDto._() : super._(); + + factory _OrderDto.fromJson(Map json) = + _$OrderDtoImpl.fromJson; + + @override + @JsonKey(name: "id") + String? get id; + @override + @JsonKey(name: "order_number") + String? get orderNumber; + @override + @JsonKey(name: "outlet_id") + String? get outletId; + @override + @JsonKey(name: "user_id") + String? get userId; + @override + @JsonKey(name: "table_number") + String? get tableNumber; + @override + @JsonKey(name: "order_type") + String? get orderType; + @override + @JsonKey(name: "status") + String? get status; + @override + @JsonKey(name: "subtotal") + int? get subtotal; + @override + @JsonKey(name: "tax_amount") + int? get taxAmount; + @override + @JsonKey(name: "discount_amount") + int? get discountAmount; + @override + @JsonKey(name: "total_amount") + int? get totalAmount; + @override + @JsonKey(name: "total_cost") + num? get totalCost; + @override + @JsonKey(name: "remaining_amount") + int? get remainingAmount; + @override + @JsonKey(name: "payment_status") + String? get paymentStatus; + @override + @JsonKey(name: "refund_amount") + int? get refundAmount; + @override + @JsonKey(name: "is_void") + bool? get isVoid; + @override + @JsonKey(name: "is_refund") + bool? get isRefund; + @override + @JsonKey(name: "notes") + String? get notes; + @override + @JsonKey(name: "metadata") + Map? get metadata; + @override + @JsonKey(name: "created_at") + String? get createdAt; + @override + @JsonKey(name: "updated_at") + String? get updatedAt; + @override + @JsonKey(name: "order_items") + List? get orderItems; + @override + @JsonKey(name: "payments") + List? get payments; + @override + @JsonKey(name: "total_paid") + int? get totalPaid; + @override + @JsonKey(name: "payment_count") + int? get paymentCount; + @override + @JsonKey(name: "split_type") + String? get splitType; + + /// Create a copy of OrderDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$OrderDtoImplCopyWith<_$OrderDtoImpl> get copyWith => + throw _privateConstructorUsedError; +} + +OrderItemDto _$OrderItemDtoFromJson(Map json) { + return _OrderItemDto.fromJson(json); +} + +/// @nodoc +mixin _$OrderItemDto { + @JsonKey(name: "id") + String? get id => throw _privateConstructorUsedError; + @JsonKey(name: "order_id") + String? get orderId => throw _privateConstructorUsedError; + @JsonKey(name: "product_id") + String? get productId => throw _privateConstructorUsedError; + @JsonKey(name: "product_name") + String? get productName => throw _privateConstructorUsedError; + @JsonKey(name: "product_variant_id") + String? get productVariantId => throw _privateConstructorUsedError; + @JsonKey(name: "product_variant_name") + String? get productVariantName => throw _privateConstructorUsedError; + @JsonKey(name: "quantity") + int? get quantity => throw _privateConstructorUsedError; + @JsonKey(name: "unit_price") + int? get unitPrice => throw _privateConstructorUsedError; + @JsonKey(name: "total_price") + int? get totalPrice => throw _privateConstructorUsedError; + @JsonKey(name: "modifiers") + List? get modifiers => throw _privateConstructorUsedError; + @JsonKey(name: "notes") + String? get notes => throw _privateConstructorUsedError; + @JsonKey(name: "status") + String? get status => throw _privateConstructorUsedError; + @JsonKey(name: "created_at") + String? get createdAt => throw _privateConstructorUsedError; + @JsonKey(name: "updated_at") + String? get updatedAt => throw _privateConstructorUsedError; + @JsonKey(name: "printer_type") + String? get printerType => throw _privateConstructorUsedError; + @JsonKey(name: "paid_quantity") + int? get paidQuantity => throw _privateConstructorUsedError; + + /// Serializes this OrderItemDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of OrderItemDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $OrderItemDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OrderItemDtoCopyWith<$Res> { + factory $OrderItemDtoCopyWith( + OrderItemDto value, + $Res Function(OrderItemDto) then, + ) = _$OrderItemDtoCopyWithImpl<$Res, OrderItemDto>; + @useResult + $Res call({ + @JsonKey(name: "id") String? id, + @JsonKey(name: "order_id") String? orderId, + @JsonKey(name: "product_id") String? productId, + @JsonKey(name: "product_name") String? productName, + @JsonKey(name: "product_variant_id") String? productVariantId, + @JsonKey(name: "product_variant_name") String? productVariantName, + @JsonKey(name: "quantity") int? quantity, + @JsonKey(name: "unit_price") int? unitPrice, + @JsonKey(name: "total_price") int? totalPrice, + @JsonKey(name: "modifiers") List? modifiers, + @JsonKey(name: "notes") String? notes, + @JsonKey(name: "status") String? status, + @JsonKey(name: "created_at") String? createdAt, + @JsonKey(name: "updated_at") String? updatedAt, + @JsonKey(name: "printer_type") String? printerType, + @JsonKey(name: "paid_quantity") int? paidQuantity, + }); +} + +/// @nodoc +class _$OrderItemDtoCopyWithImpl<$Res, $Val extends OrderItemDto> + implements $OrderItemDtoCopyWith<$Res> { + _$OrderItemDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of OrderItemDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? orderId = freezed, + Object? productId = freezed, + Object? productName = freezed, + Object? productVariantId = freezed, + Object? productVariantName = freezed, + Object? quantity = freezed, + Object? unitPrice = freezed, + Object? totalPrice = freezed, + Object? modifiers = freezed, + Object? notes = freezed, + Object? status = freezed, + Object? createdAt = freezed, + Object? updatedAt = freezed, + Object? printerType = freezed, + Object? paidQuantity = freezed, + }) { + return _then( + _value.copyWith( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + orderId: freezed == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String?, + productId: freezed == productId + ? _value.productId + : productId // ignore: cast_nullable_to_non_nullable + as String?, + productName: freezed == productName + ? _value.productName + : productName // ignore: cast_nullable_to_non_nullable + as String?, + productVariantId: freezed == productVariantId + ? _value.productVariantId + : productVariantId // ignore: cast_nullable_to_non_nullable + as String?, + productVariantName: freezed == productVariantName + ? _value.productVariantName + : productVariantName // ignore: cast_nullable_to_non_nullable + as String?, + quantity: freezed == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int?, + unitPrice: freezed == unitPrice + ? _value.unitPrice + : unitPrice // ignore: cast_nullable_to_non_nullable + as int?, + totalPrice: freezed == totalPrice + ? _value.totalPrice + : totalPrice // ignore: cast_nullable_to_non_nullable + as int?, + modifiers: freezed == modifiers + ? _value.modifiers + : modifiers // ignore: cast_nullable_to_non_nullable + as List?, + notes: freezed == notes + ? _value.notes + : notes // ignore: cast_nullable_to_non_nullable + as String?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + 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?, + printerType: freezed == printerType + ? _value.printerType + : printerType // ignore: cast_nullable_to_non_nullable + as String?, + paidQuantity: freezed == paidQuantity + ? _value.paidQuantity + : paidQuantity // ignore: cast_nullable_to_non_nullable + as int?, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$OrderItemDtoImplCopyWith<$Res> + implements $OrderItemDtoCopyWith<$Res> { + factory _$$OrderItemDtoImplCopyWith( + _$OrderItemDtoImpl value, + $Res Function(_$OrderItemDtoImpl) then, + ) = __$$OrderItemDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: "id") String? id, + @JsonKey(name: "order_id") String? orderId, + @JsonKey(name: "product_id") String? productId, + @JsonKey(name: "product_name") String? productName, + @JsonKey(name: "product_variant_id") String? productVariantId, + @JsonKey(name: "product_variant_name") String? productVariantName, + @JsonKey(name: "quantity") int? quantity, + @JsonKey(name: "unit_price") int? unitPrice, + @JsonKey(name: "total_price") int? totalPrice, + @JsonKey(name: "modifiers") List? modifiers, + @JsonKey(name: "notes") String? notes, + @JsonKey(name: "status") String? status, + @JsonKey(name: "created_at") String? createdAt, + @JsonKey(name: "updated_at") String? updatedAt, + @JsonKey(name: "printer_type") String? printerType, + @JsonKey(name: "paid_quantity") int? paidQuantity, + }); +} + +/// @nodoc +class __$$OrderItemDtoImplCopyWithImpl<$Res> + extends _$OrderItemDtoCopyWithImpl<$Res, _$OrderItemDtoImpl> + implements _$$OrderItemDtoImplCopyWith<$Res> { + __$$OrderItemDtoImplCopyWithImpl( + _$OrderItemDtoImpl _value, + $Res Function(_$OrderItemDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderItemDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? orderId = freezed, + Object? productId = freezed, + Object? productName = freezed, + Object? productVariantId = freezed, + Object? productVariantName = freezed, + Object? quantity = freezed, + Object? unitPrice = freezed, + Object? totalPrice = freezed, + Object? modifiers = freezed, + Object? notes = freezed, + Object? status = freezed, + Object? createdAt = freezed, + Object? updatedAt = freezed, + Object? printerType = freezed, + Object? paidQuantity = freezed, + }) { + return _then( + _$OrderItemDtoImpl( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + orderId: freezed == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String?, + productId: freezed == productId + ? _value.productId + : productId // ignore: cast_nullable_to_non_nullable + as String?, + productName: freezed == productName + ? _value.productName + : productName // ignore: cast_nullable_to_non_nullable + as String?, + productVariantId: freezed == productVariantId + ? _value.productVariantId + : productVariantId // ignore: cast_nullable_to_non_nullable + as String?, + productVariantName: freezed == productVariantName + ? _value.productVariantName + : productVariantName // ignore: cast_nullable_to_non_nullable + as String?, + quantity: freezed == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int?, + unitPrice: freezed == unitPrice + ? _value.unitPrice + : unitPrice // ignore: cast_nullable_to_non_nullable + as int?, + totalPrice: freezed == totalPrice + ? _value.totalPrice + : totalPrice // ignore: cast_nullable_to_non_nullable + as int?, + modifiers: freezed == modifiers + ? _value._modifiers + : modifiers // ignore: cast_nullable_to_non_nullable + as List?, + notes: freezed == notes + ? _value.notes + : notes // ignore: cast_nullable_to_non_nullable + as String?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + 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?, + printerType: freezed == printerType + ? _value.printerType + : printerType // ignore: cast_nullable_to_non_nullable + as String?, + paidQuantity: freezed == paidQuantity + ? _value.paidQuantity + : paidQuantity // ignore: cast_nullable_to_non_nullable + as int?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$OrderItemDtoImpl extends _OrderItemDto { + const _$OrderItemDtoImpl({ + @JsonKey(name: "id") this.id, + @JsonKey(name: "order_id") this.orderId, + @JsonKey(name: "product_id") this.productId, + @JsonKey(name: "product_name") this.productName, + @JsonKey(name: "product_variant_id") this.productVariantId, + @JsonKey(name: "product_variant_name") this.productVariantName, + @JsonKey(name: "quantity") this.quantity, + @JsonKey(name: "unit_price") this.unitPrice, + @JsonKey(name: "total_price") this.totalPrice, + @JsonKey(name: "modifiers") final List? modifiers, + @JsonKey(name: "notes") this.notes, + @JsonKey(name: "status") this.status, + @JsonKey(name: "created_at") this.createdAt, + @JsonKey(name: "updated_at") this.updatedAt, + @JsonKey(name: "printer_type") this.printerType, + @JsonKey(name: "paid_quantity") this.paidQuantity, + }) : _modifiers = modifiers, + super._(); + + factory _$OrderItemDtoImpl.fromJson(Map json) => + _$$OrderItemDtoImplFromJson(json); + + @override + @JsonKey(name: "id") + final String? id; + @override + @JsonKey(name: "order_id") + final String? orderId; + @override + @JsonKey(name: "product_id") + final String? productId; + @override + @JsonKey(name: "product_name") + final String? productName; + @override + @JsonKey(name: "product_variant_id") + final String? productVariantId; + @override + @JsonKey(name: "product_variant_name") + final String? productVariantName; + @override + @JsonKey(name: "quantity") + final int? quantity; + @override + @JsonKey(name: "unit_price") + final int? unitPrice; + @override + @JsonKey(name: "total_price") + final int? totalPrice; + final List? _modifiers; + @override + @JsonKey(name: "modifiers") + List? get modifiers { + final value = _modifiers; + if (value == null) return null; + if (_modifiers is EqualUnmodifiableListView) return _modifiers; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + @JsonKey(name: "notes") + final String? notes; + @override + @JsonKey(name: "status") + final String? status; + @override + @JsonKey(name: "created_at") + final String? createdAt; + @override + @JsonKey(name: "updated_at") + final String? updatedAt; + @override + @JsonKey(name: "printer_type") + final String? printerType; + @override + @JsonKey(name: "paid_quantity") + final int? paidQuantity; + + @override + String toString() { + return 'OrderItemDto(id: $id, orderId: $orderId, productId: $productId, productName: $productName, productVariantId: $productVariantId, productVariantName: $productVariantName, quantity: $quantity, unitPrice: $unitPrice, totalPrice: $totalPrice, modifiers: $modifiers, notes: $notes, status: $status, createdAt: $createdAt, updatedAt: $updatedAt, printerType: $printerType, paidQuantity: $paidQuantity)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$OrderItemDtoImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.orderId, orderId) || other.orderId == orderId) && + (identical(other.productId, productId) || + other.productId == productId) && + (identical(other.productName, productName) || + other.productName == productName) && + (identical(other.productVariantId, productVariantId) || + other.productVariantId == productVariantId) && + (identical(other.productVariantName, productVariantName) || + other.productVariantName == productVariantName) && + (identical(other.quantity, quantity) || + other.quantity == quantity) && + (identical(other.unitPrice, unitPrice) || + other.unitPrice == unitPrice) && + (identical(other.totalPrice, totalPrice) || + other.totalPrice == totalPrice) && + const DeepCollectionEquality().equals( + other._modifiers, + _modifiers, + ) && + (identical(other.notes, notes) || other.notes == notes) && + (identical(other.status, status) || other.status == status) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt) && + (identical(other.printerType, printerType) || + other.printerType == printerType) && + (identical(other.paidQuantity, paidQuantity) || + other.paidQuantity == paidQuantity)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + id, + orderId, + productId, + productName, + productVariantId, + productVariantName, + quantity, + unitPrice, + totalPrice, + const DeepCollectionEquality().hash(_modifiers), + notes, + status, + createdAt, + updatedAt, + printerType, + paidQuantity, + ); + + /// Create a copy of OrderItemDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$OrderItemDtoImplCopyWith<_$OrderItemDtoImpl> get copyWith => + __$$OrderItemDtoImplCopyWithImpl<_$OrderItemDtoImpl>(this, _$identity); + + @override + Map toJson() { + return _$$OrderItemDtoImplToJson(this); + } +} + +abstract class _OrderItemDto extends OrderItemDto { + const factory _OrderItemDto({ + @JsonKey(name: "id") final String? id, + @JsonKey(name: "order_id") final String? orderId, + @JsonKey(name: "product_id") final String? productId, + @JsonKey(name: "product_name") final String? productName, + @JsonKey(name: "product_variant_id") final String? productVariantId, + @JsonKey(name: "product_variant_name") final String? productVariantName, + @JsonKey(name: "quantity") final int? quantity, + @JsonKey(name: "unit_price") final int? unitPrice, + @JsonKey(name: "total_price") final int? totalPrice, + @JsonKey(name: "modifiers") final List? modifiers, + @JsonKey(name: "notes") final String? notes, + @JsonKey(name: "status") final String? status, + @JsonKey(name: "created_at") final String? createdAt, + @JsonKey(name: "updated_at") final String? updatedAt, + @JsonKey(name: "printer_type") final String? printerType, + @JsonKey(name: "paid_quantity") final int? paidQuantity, + }) = _$OrderItemDtoImpl; + const _OrderItemDto._() : super._(); + + factory _OrderItemDto.fromJson(Map json) = + _$OrderItemDtoImpl.fromJson; + + @override + @JsonKey(name: "id") + String? get id; + @override + @JsonKey(name: "order_id") + String? get orderId; + @override + @JsonKey(name: "product_id") + String? get productId; + @override + @JsonKey(name: "product_name") + String? get productName; + @override + @JsonKey(name: "product_variant_id") + String? get productVariantId; + @override + @JsonKey(name: "product_variant_name") + String? get productVariantName; + @override + @JsonKey(name: "quantity") + int? get quantity; + @override + @JsonKey(name: "unit_price") + int? get unitPrice; + @override + @JsonKey(name: "total_price") + int? get totalPrice; + @override + @JsonKey(name: "modifiers") + List? get modifiers; + @override + @JsonKey(name: "notes") + String? get notes; + @override + @JsonKey(name: "status") + String? get status; + @override + @JsonKey(name: "created_at") + String? get createdAt; + @override + @JsonKey(name: "updated_at") + String? get updatedAt; + @override + @JsonKey(name: "printer_type") + String? get printerType; + @override + @JsonKey(name: "paid_quantity") + int? get paidQuantity; + + /// Create a copy of OrderItemDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$OrderItemDtoImplCopyWith<_$OrderItemDtoImpl> get copyWith => + throw _privateConstructorUsedError; +} + +PaymentOrderDto _$PaymentOrderDtoFromJson(Map json) { + return _PaymentOrderDto.fromJson(json); +} + +/// @nodoc +mixin _$PaymentOrderDto { + @JsonKey(name: "id") + String? get id => throw _privateConstructorUsedError; + @JsonKey(name: "order_id") + String? get orderId => throw _privateConstructorUsedError; + @JsonKey(name: "payment_method_id") + String? get paymentMethodId => throw _privateConstructorUsedError; + @JsonKey(name: "payment_method_name") + String? get paymentMethodName => throw _privateConstructorUsedError; + @JsonKey(name: "payment_method_type") + String? get paymentMethodType => throw _privateConstructorUsedError; + @JsonKey(name: "amount") + int? get amount => throw _privateConstructorUsedError; + @JsonKey(name: "status") + String? get status => throw _privateConstructorUsedError; + @JsonKey(name: "split_number") + int? get splitNumber => throw _privateConstructorUsedError; + @JsonKey(name: "split_total") + int? get splitTotal => throw _privateConstructorUsedError; + @JsonKey(name: "split_description") + String? get splitDescription => throw _privateConstructorUsedError; + @JsonKey(name: "refund_amount") + int? get refundAmount => throw _privateConstructorUsedError; + @JsonKey(name: "metadata") + Map? get metadata => throw _privateConstructorUsedError; + @JsonKey(name: "created_at") + String? get createdAt => throw _privateConstructorUsedError; + @JsonKey(name: "updated_at") + String? get updatedAt => throw _privateConstructorUsedError; + + /// Serializes this PaymentOrderDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of PaymentOrderDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PaymentOrderDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PaymentOrderDtoCopyWith<$Res> { + factory $PaymentOrderDtoCopyWith( + PaymentOrderDto value, + $Res Function(PaymentOrderDto) then, + ) = _$PaymentOrderDtoCopyWithImpl<$Res, PaymentOrderDto>; + @useResult + $Res call({ + @JsonKey(name: "id") String? id, + @JsonKey(name: "order_id") String? orderId, + @JsonKey(name: "payment_method_id") String? paymentMethodId, + @JsonKey(name: "payment_method_name") String? paymentMethodName, + @JsonKey(name: "payment_method_type") String? paymentMethodType, + @JsonKey(name: "amount") int? amount, + @JsonKey(name: "status") String? status, + @JsonKey(name: "split_number") int? splitNumber, + @JsonKey(name: "split_total") int? splitTotal, + @JsonKey(name: "split_description") String? splitDescription, + @JsonKey(name: "refund_amount") int? refundAmount, + @JsonKey(name: "metadata") Map? metadata, + @JsonKey(name: "created_at") String? createdAt, + @JsonKey(name: "updated_at") String? updatedAt, + }); +} + +/// @nodoc +class _$PaymentOrderDtoCopyWithImpl<$Res, $Val extends PaymentOrderDto> + implements $PaymentOrderDtoCopyWith<$Res> { + _$PaymentOrderDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PaymentOrderDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? orderId = freezed, + Object? paymentMethodId = freezed, + Object? paymentMethodName = freezed, + Object? paymentMethodType = freezed, + Object? amount = freezed, + Object? status = freezed, + Object? splitNumber = freezed, + Object? splitTotal = freezed, + Object? splitDescription = freezed, + Object? refundAmount = 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?, + orderId: freezed == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodId: freezed == paymentMethodId + ? _value.paymentMethodId + : paymentMethodId // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodName: freezed == paymentMethodName + ? _value.paymentMethodName + : paymentMethodName // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodType: freezed == paymentMethodType + ? _value.paymentMethodType + : paymentMethodType // ignore: cast_nullable_to_non_nullable + as String?, + amount: freezed == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + splitNumber: freezed == splitNumber + ? _value.splitNumber + : splitNumber // ignore: cast_nullable_to_non_nullable + as int?, + splitTotal: freezed == splitTotal + ? _value.splitTotal + : splitTotal // ignore: cast_nullable_to_non_nullable + as int?, + splitDescription: freezed == splitDescription + ? _value.splitDescription + : splitDescription // ignore: cast_nullable_to_non_nullable + as String?, + refundAmount: freezed == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int?, + metadata: freezed == metadata + ? _value.metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map?, + 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 _$$PaymentOrderDtoImplCopyWith<$Res> + implements $PaymentOrderDtoCopyWith<$Res> { + factory _$$PaymentOrderDtoImplCopyWith( + _$PaymentOrderDtoImpl value, + $Res Function(_$PaymentOrderDtoImpl) then, + ) = __$$PaymentOrderDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: "id") String? id, + @JsonKey(name: "order_id") String? orderId, + @JsonKey(name: "payment_method_id") String? paymentMethodId, + @JsonKey(name: "payment_method_name") String? paymentMethodName, + @JsonKey(name: "payment_method_type") String? paymentMethodType, + @JsonKey(name: "amount") int? amount, + @JsonKey(name: "status") String? status, + @JsonKey(name: "split_number") int? splitNumber, + @JsonKey(name: "split_total") int? splitTotal, + @JsonKey(name: "split_description") String? splitDescription, + @JsonKey(name: "refund_amount") int? refundAmount, + @JsonKey(name: "metadata") Map? metadata, + @JsonKey(name: "created_at") String? createdAt, + @JsonKey(name: "updated_at") String? updatedAt, + }); +} + +/// @nodoc +class __$$PaymentOrderDtoImplCopyWithImpl<$Res> + extends _$PaymentOrderDtoCopyWithImpl<$Res, _$PaymentOrderDtoImpl> + implements _$$PaymentOrderDtoImplCopyWith<$Res> { + __$$PaymentOrderDtoImplCopyWithImpl( + _$PaymentOrderDtoImpl _value, + $Res Function(_$PaymentOrderDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PaymentOrderDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? orderId = freezed, + Object? paymentMethodId = freezed, + Object? paymentMethodName = freezed, + Object? paymentMethodType = freezed, + Object? amount = freezed, + Object? status = freezed, + Object? splitNumber = freezed, + Object? splitTotal = freezed, + Object? splitDescription = freezed, + Object? refundAmount = freezed, + Object? metadata = freezed, + Object? createdAt = freezed, + Object? updatedAt = freezed, + }) { + return _then( + _$PaymentOrderDtoImpl( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + orderId: freezed == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodId: freezed == paymentMethodId + ? _value.paymentMethodId + : paymentMethodId // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodName: freezed == paymentMethodName + ? _value.paymentMethodName + : paymentMethodName // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodType: freezed == paymentMethodType + ? _value.paymentMethodType + : paymentMethodType // ignore: cast_nullable_to_non_nullable + as String?, + amount: freezed == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + splitNumber: freezed == splitNumber + ? _value.splitNumber + : splitNumber // ignore: cast_nullable_to_non_nullable + as int?, + splitTotal: freezed == splitTotal + ? _value.splitTotal + : splitTotal // ignore: cast_nullable_to_non_nullable + as int?, + splitDescription: freezed == splitDescription + ? _value.splitDescription + : splitDescription // ignore: cast_nullable_to_non_nullable + as String?, + refundAmount: freezed == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int?, + metadata: freezed == metadata + ? _value._metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map?, + 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 _$PaymentOrderDtoImpl extends _PaymentOrderDto { + const _$PaymentOrderDtoImpl({ + @JsonKey(name: "id") this.id, + @JsonKey(name: "order_id") this.orderId, + @JsonKey(name: "payment_method_id") this.paymentMethodId, + @JsonKey(name: "payment_method_name") this.paymentMethodName, + @JsonKey(name: "payment_method_type") this.paymentMethodType, + @JsonKey(name: "amount") this.amount, + @JsonKey(name: "status") this.status, + @JsonKey(name: "split_number") this.splitNumber, + @JsonKey(name: "split_total") this.splitTotal, + @JsonKey(name: "split_description") this.splitDescription, + @JsonKey(name: "refund_amount") this.refundAmount, + @JsonKey(name: "metadata") final Map? metadata, + @JsonKey(name: "created_at") this.createdAt, + @JsonKey(name: "updated_at") this.updatedAt, + }) : _metadata = metadata, + super._(); + + factory _$PaymentOrderDtoImpl.fromJson(Map json) => + _$$PaymentOrderDtoImplFromJson(json); + + @override + @JsonKey(name: "id") + final String? id; + @override + @JsonKey(name: "order_id") + final String? orderId; + @override + @JsonKey(name: "payment_method_id") + final String? paymentMethodId; + @override + @JsonKey(name: "payment_method_name") + final String? paymentMethodName; + @override + @JsonKey(name: "payment_method_type") + final String? paymentMethodType; + @override + @JsonKey(name: "amount") + final int? amount; + @override + @JsonKey(name: "status") + final String? status; + @override + @JsonKey(name: "split_number") + final int? splitNumber; + @override + @JsonKey(name: "split_total") + final int? splitTotal; + @override + @JsonKey(name: "split_description") + final String? splitDescription; + @override + @JsonKey(name: "refund_amount") + final int? refundAmount; + final Map? _metadata; + @override + @JsonKey(name: "metadata") + Map? 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() { + return 'PaymentOrderDto(id: $id, orderId: $orderId, paymentMethodId: $paymentMethodId, paymentMethodName: $paymentMethodName, paymentMethodType: $paymentMethodType, amount: $amount, status: $status, splitNumber: $splitNumber, splitTotal: $splitTotal, splitDescription: $splitDescription, refundAmount: $refundAmount, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentOrderDtoImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.orderId, orderId) || other.orderId == orderId) && + (identical(other.paymentMethodId, paymentMethodId) || + other.paymentMethodId == paymentMethodId) && + (identical(other.paymentMethodName, paymentMethodName) || + other.paymentMethodName == paymentMethodName) && + (identical(other.paymentMethodType, paymentMethodType) || + other.paymentMethodType == paymentMethodType) && + (identical(other.amount, amount) || other.amount == amount) && + (identical(other.status, status) || other.status == status) && + (identical(other.splitNumber, splitNumber) || + other.splitNumber == splitNumber) && + (identical(other.splitTotal, splitTotal) || + other.splitTotal == splitTotal) && + (identical(other.splitDescription, splitDescription) || + other.splitDescription == splitDescription) && + (identical(other.refundAmount, refundAmount) || + other.refundAmount == refundAmount) && + 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, + orderId, + paymentMethodId, + paymentMethodName, + paymentMethodType, + amount, + status, + splitNumber, + splitTotal, + splitDescription, + refundAmount, + const DeepCollectionEquality().hash(_metadata), + createdAt, + updatedAt, + ); + + /// Create a copy of PaymentOrderDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PaymentOrderDtoImplCopyWith<_$PaymentOrderDtoImpl> get copyWith => + __$$PaymentOrderDtoImplCopyWithImpl<_$PaymentOrderDtoImpl>( + this, + _$identity, + ); + + @override + Map toJson() { + return _$$PaymentOrderDtoImplToJson(this); + } +} + +abstract class _PaymentOrderDto extends PaymentOrderDto { + const factory _PaymentOrderDto({ + @JsonKey(name: "id") final String? id, + @JsonKey(name: "order_id") final String? orderId, + @JsonKey(name: "payment_method_id") final String? paymentMethodId, + @JsonKey(name: "payment_method_name") final String? paymentMethodName, + @JsonKey(name: "payment_method_type") final String? paymentMethodType, + @JsonKey(name: "amount") final int? amount, + @JsonKey(name: "status") final String? status, + @JsonKey(name: "split_number") final int? splitNumber, + @JsonKey(name: "split_total") final int? splitTotal, + @JsonKey(name: "split_description") final String? splitDescription, + @JsonKey(name: "refund_amount") final int? refundAmount, + @JsonKey(name: "metadata") final Map? metadata, + @JsonKey(name: "created_at") final String? createdAt, + @JsonKey(name: "updated_at") final String? updatedAt, + }) = _$PaymentOrderDtoImpl; + const _PaymentOrderDto._() : super._(); + + factory _PaymentOrderDto.fromJson(Map json) = + _$PaymentOrderDtoImpl.fromJson; + + @override + @JsonKey(name: "id") + String? get id; + @override + @JsonKey(name: "order_id") + String? get orderId; + @override + @JsonKey(name: "payment_method_id") + String? get paymentMethodId; + @override + @JsonKey(name: "payment_method_name") + String? get paymentMethodName; + @override + @JsonKey(name: "payment_method_type") + String? get paymentMethodType; + @override + @JsonKey(name: "amount") + int? get amount; + @override + @JsonKey(name: "status") + String? get status; + @override + @JsonKey(name: "split_number") + int? get splitNumber; + @override + @JsonKey(name: "split_total") + int? get splitTotal; + @override + @JsonKey(name: "split_description") + String? get splitDescription; + @override + @JsonKey(name: "refund_amount") + int? get refundAmount; + @override + @JsonKey(name: "metadata") + Map? get metadata; + @override + @JsonKey(name: "created_at") + String? get createdAt; + @override + @JsonKey(name: "updated_at") + String? get updatedAt; + + /// Create a copy of PaymentOrderDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PaymentOrderDtoImplCopyWith<_$PaymentOrderDtoImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/infrastructure/order/order_dtos.g.dart b/lib/infrastructure/order/order_dtos.g.dart new file mode 100644 index 0000000..c740040 --- /dev/null +++ b/lib/infrastructure/order/order_dtos.g.dart @@ -0,0 +1,169 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'order_dtos.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$ListOrderDtoImpl _$$ListOrderDtoImplFromJson(Map json) => + _$ListOrderDtoImpl( + orders: (json['orders'] as List?) + ?.map((e) => OrderDto.fromJson(e as Map)) + .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 _$$ListOrderDtoImplToJson(_$ListOrderDtoImpl instance) => + { + 'orders': instance.orders, + 'total_count': instance.totalCount, + 'page': instance.page, + 'limit': instance.limit, + 'total_pages': instance.totalPages, + }; + +_$OrderDtoImpl _$$OrderDtoImplFromJson(Map json) => + _$OrderDtoImpl( + id: json['id'] as String?, + orderNumber: json['order_number'] as String?, + outletId: json['outlet_id'] as String?, + userId: json['user_id'] as String?, + tableNumber: json['table_number'] as String?, + orderType: json['order_type'] as String?, + status: json['status'] as String?, + subtotal: (json['subtotal'] as num?)?.toInt(), + taxAmount: (json['tax_amount'] as num?)?.toInt(), + discountAmount: (json['discount_amount'] as num?)?.toInt(), + totalAmount: (json['total_amount'] as num?)?.toInt(), + totalCost: json['total_cost'] as num?, + remainingAmount: (json['remaining_amount'] as num?)?.toInt(), + paymentStatus: json['payment_status'] as String?, + refundAmount: (json['refund_amount'] as num?)?.toInt(), + isVoid: json['is_void'] as bool?, + isRefund: json['is_refund'] as bool?, + notes: json['notes'] as String?, + metadata: json['metadata'] as Map?, + createdAt: json['created_at'] as String?, + updatedAt: json['updated_at'] as String?, + orderItems: (json['order_items'] as List?) + ?.map((e) => OrderItemDto.fromJson(e as Map)) + .toList(), + payments: (json['payments'] as List?) + ?.map((e) => PaymentOrderDto.fromJson(e as Map)) + .toList(), + totalPaid: (json['total_paid'] as num?)?.toInt(), + paymentCount: (json['payment_count'] as num?)?.toInt(), + splitType: json['split_type'] as String?, + ); + +Map _$$OrderDtoImplToJson(_$OrderDtoImpl instance) => + { + 'id': instance.id, + 'order_number': instance.orderNumber, + 'outlet_id': instance.outletId, + 'user_id': instance.userId, + 'table_number': instance.tableNumber, + 'order_type': instance.orderType, + 'status': instance.status, + 'subtotal': instance.subtotal, + 'tax_amount': instance.taxAmount, + 'discount_amount': instance.discountAmount, + 'total_amount': instance.totalAmount, + 'total_cost': instance.totalCost, + 'remaining_amount': instance.remainingAmount, + 'payment_status': instance.paymentStatus, + 'refund_amount': instance.refundAmount, + 'is_void': instance.isVoid, + 'is_refund': instance.isRefund, + 'notes': instance.notes, + 'metadata': instance.metadata, + 'created_at': instance.createdAt, + 'updated_at': instance.updatedAt, + 'order_items': instance.orderItems, + 'payments': instance.payments, + 'total_paid': instance.totalPaid, + 'payment_count': instance.paymentCount, + 'split_type': instance.splitType, + }; + +_$OrderItemDtoImpl _$$OrderItemDtoImplFromJson(Map json) => + _$OrderItemDtoImpl( + id: json['id'] as String?, + orderId: json['order_id'] as String?, + productId: json['product_id'] as String?, + productName: json['product_name'] as String?, + productVariantId: json['product_variant_id'] as String?, + productVariantName: json['product_variant_name'] as String?, + quantity: (json['quantity'] as num?)?.toInt(), + unitPrice: (json['unit_price'] as num?)?.toInt(), + totalPrice: (json['total_price'] as num?)?.toInt(), + modifiers: json['modifiers'] as List?, + notes: json['notes'] as String?, + status: json['status'] as String?, + createdAt: json['created_at'] as String?, + updatedAt: json['updated_at'] as String?, + printerType: json['printer_type'] as String?, + paidQuantity: (json['paid_quantity'] as num?)?.toInt(), + ); + +Map _$$OrderItemDtoImplToJson(_$OrderItemDtoImpl instance) => + { + 'id': instance.id, + 'order_id': instance.orderId, + 'product_id': instance.productId, + 'product_name': instance.productName, + 'product_variant_id': instance.productVariantId, + 'product_variant_name': instance.productVariantName, + 'quantity': instance.quantity, + 'unit_price': instance.unitPrice, + 'total_price': instance.totalPrice, + 'modifiers': instance.modifiers, + 'notes': instance.notes, + 'status': instance.status, + 'created_at': instance.createdAt, + 'updated_at': instance.updatedAt, + 'printer_type': instance.printerType, + 'paid_quantity': instance.paidQuantity, + }; + +_$PaymentOrderDtoImpl _$$PaymentOrderDtoImplFromJson( + Map json, +) => _$PaymentOrderDtoImpl( + id: json['id'] as String?, + orderId: json['order_id'] as String?, + paymentMethodId: json['payment_method_id'] as String?, + paymentMethodName: json['payment_method_name'] as String?, + paymentMethodType: json['payment_method_type'] as String?, + amount: (json['amount'] as num?)?.toInt(), + status: json['status'] as String?, + splitNumber: (json['split_number'] as num?)?.toInt(), + splitTotal: (json['split_total'] as num?)?.toInt(), + splitDescription: json['split_description'] as String?, + refundAmount: (json['refund_amount'] as num?)?.toInt(), + metadata: json['metadata'] as Map?, + createdAt: json['created_at'] as String?, + updatedAt: json['updated_at'] as String?, +); + +Map _$$PaymentOrderDtoImplToJson( + _$PaymentOrderDtoImpl instance, +) => { + 'id': instance.id, + 'order_id': instance.orderId, + 'payment_method_id': instance.paymentMethodId, + 'payment_method_name': instance.paymentMethodName, + 'payment_method_type': instance.paymentMethodType, + 'amount': instance.amount, + 'status': instance.status, + 'split_number': instance.splitNumber, + 'split_total': instance.splitTotal, + 'split_description': instance.splitDescription, + 'refund_amount': instance.refundAmount, + 'metadata': instance.metadata, + 'created_at': instance.createdAt, + 'updated_at': instance.updatedAt, +}; diff --git a/lib/infrastructure/order/repositories/order_repository.dart b/lib/infrastructure/order/repositories/order_repository.dart new file mode 100644 index 0000000..a1b1736 --- /dev/null +++ b/lib/infrastructure/order/repositories/order_repository.dart @@ -0,0 +1,46 @@ +import 'dart:developer'; + +import 'package:dartz/dartz.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../domain/order/order.dart'; +import '../datasources/remote_data_provider.dart'; + +@Injectable(as: IOrderRepository) +class OrderRepository implements IOrderRepository { + final OrderRemoteDataProvider _dataProvider; + final _logName = 'OrderRepository'; + + OrderRepository(this._dataProvider); + + @override + Future> getOrders({ + int page = 1, + int limit = 10, + String status = 'completed', + required DateTime startDate, + required DateTime endDate, + String? search, + }) async { + try { + final result = await _dataProvider.fetchOrders( + page: page, + limit: limit, + status: status, + startDate: startDate, + endDate: endDate, + search: search, + ); + + if (result.hasError) { + return left(result.error!); + } + + final orders = result.data!.toDomain(); + return right(orders); + } catch (e) { + log('getOrdersError', name: _logName, error: e); + return left(const OrderFailure.unexpectedError()); + } + } +} diff --git a/lib/injection.config.dart b/lib/injection.config.dart index ea19122..22ce8e2 100644 --- a/lib/injection.config.dart +++ b/lib/injection.config.dart @@ -20,6 +20,8 @@ import 'package:apskel_pos_flutter_v2/application/customer/customer_loader/custo as _i683; import 'package:apskel_pos_flutter_v2/application/order/order_form/order_form_bloc.dart' as _i702; +import 'package:apskel_pos_flutter_v2/application/order/order_loader/order_loader_bloc.dart' + as _i94; import 'package:apskel_pos_flutter_v2/application/outlet/outlet_loader/outlet_loader_bloc.dart' as _i76; import 'package:apskel_pos_flutter_v2/application/payment_method/payment_method_loader/payment_method_loader_bloc.dart' @@ -45,6 +47,7 @@ import 'package:apskel_pos_flutter_v2/common/network/network_client.dart' 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/order/order.dart' as _i299; import 'package:apskel_pos_flutter_v2/domain/outlet/outlet.dart' as _i552; import 'package:apskel_pos_flutter_v2/domain/payment_method/payment_method.dart' as _i297; @@ -67,6 +70,10 @@ import 'package:apskel_pos_flutter_v2/infrastructure/customer/datasources/remote as _i841; import 'package:apskel_pos_flutter_v2/infrastructure/customer/repositories/customer_repository.dart' as _i385; +import 'package:apskel_pos_flutter_v2/infrastructure/order/datasources/remote_data_provider.dart' + as _i360; +import 'package:apskel_pos_flutter_v2/infrastructure/order/repositories/order_repository.dart' + as _i851; 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' @@ -161,6 +168,9 @@ extension GetItInjectableX on _i174.GetIt { gh.factory<_i833.PaymentMethodRemoteDataProvider>( () => _i833.PaymentMethodRemoteDataProvider(gh<_i457.ApiClient>()), ); + gh.factory<_i360.OrderRemoteDataProvider>( + () => _i360.OrderRemoteDataProvider(gh<_i457.ApiClient>()), + ); gh.factory<_i776.IAuthRepository>( () => _i941.AuthRepository( gh<_i370.AuthRemoteDataProvider>(), @@ -179,6 +189,9 @@ extension GetItInjectableX on _i174.GetIt { gh<_i693.OutletLocalDatasource>(), ), ); + gh.factory<_i299.IOrderRepository>( + () => _i851.OrderRepository(gh<_i360.OrderRemoteDataProvider>()), + ); gh.factory<_i248.TableFormBloc>( () => _i248.TableFormBloc(gh<_i983.ITableRepository>()), ); @@ -211,6 +224,9 @@ extension GetItInjectableX on _i174.GetIt { gh.factory<_i143.ICustomerRepository>( () => _i385.CustomerRepository(gh<_i841.CustomerRemoteDataProvider>()), ); + gh.factory<_i94.OrderLoaderBloc>( + () => _i94.OrderLoaderBloc(gh<_i299.IOrderRepository>()), + ); gh.factory<_i683.CustomerLoaderBloc>( () => _i683.CustomerLoaderBloc(gh<_i143.ICustomerRepository>()), ); diff --git a/lib/presentation/app_widget.dart b/lib/presentation/app_widget.dart index b365032..c1bf2a5 100644 --- a/lib/presentation/app_widget.dart +++ b/lib/presentation/app_widget.dart @@ -6,6 +6,7 @@ import '../application/category/category_loader/category_loader_bloc.dart'; import '../application/checkout/checkout_form/checkout_form_bloc.dart'; import '../application/customer/customer_loader/customer_loader_bloc.dart'; import '../application/order/order_form/order_form_bloc.dart'; +import '../application/order/order_loader/order_loader_bloc.dart'; import '../application/outlet/outlet_loader/outlet_loader_bloc.dart'; import '../application/payment_method/payment_method_loader/payment_method_loader_bloc.dart'; import '../application/product/product_loader/product_loader_bloc.dart'; @@ -40,6 +41,7 @@ class _AppWidgetState extends State { BlocProvider(create: (context) => getIt()), BlocProvider(create: (context) => getIt()), BlocProvider(create: (context) => getIt()), + BlocProvider(create: (context) => getIt()), BlocProvider(create: (context) => getIt()), ], child: MaterialApp.router( diff --git a/lib/presentation/components/card/order_card.dart b/lib/presentation/components/card/order_card.dart new file mode 100644 index 0000000..55319ac --- /dev/null +++ b/lib/presentation/components/card/order_card.dart @@ -0,0 +1,207 @@ +import 'package:flutter/material.dart'; + +import '../../../common/extension/extension.dart'; +import '../../../common/theme/theme.dart'; +import '../../../domain/order/order.dart'; + +class OrderCard extends StatelessWidget { + final Order order; + final bool isActive; + + const OrderCard({super.key, required this.order, required this.isActive}); + + @override + Widget build(BuildContext context) { + return Container( + margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + 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: Padding( + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Expanded( + child: Text( + order.orderNumber, + style: AppStyle.sm.copyWith(fontWeight: FontWeight.w600), + ), + ), + if (order.isRefund == true) + Container( + padding: const EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + decoration: BoxDecoration( + color: Colors.red.withOpacity(0.15), + borderRadius: BorderRadius.circular(16), + ), + child: Text( + 'Refund', + style: AppStyle.xs.copyWith( + color: AppColor.error, + fontWeight: FontWeight.w600, + fontSize: 10, + letterSpacing: 0.5, + ), + ), + ), + if (order.isVoid == true) + Container( + padding: const EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + decoration: BoxDecoration( + color: Colors.red.withOpacity(0.15), + borderRadius: BorderRadius.circular(16), + ), + child: Text( + 'Void', + style: AppStyle.xs.copyWith( + color: AppColor.error, + fontWeight: FontWeight.w600, + fontSize: 10, + letterSpacing: 0.5, + ), + ), + ), + ], + ), + const SizedBox(height: 12), + Row( + children: [ + CircleAvatar( + radius: 22, + backgroundColor: AppColor.primary, + child: Icon(Icons.person, color: Colors.white), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + order.metadata['customer_name'] == "" + ? "Anonim" + : order.metadata['customer_name'], + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + if (order.orderType == "dineIn") ...[ + const SizedBox(height: 4), + Row( + children: [ + Icon( + Icons.table_bar, + size: 16, + color: AppColor.textSecondary, + ), + const SizedBox(width: 4), + Text( + 'Meja ${order.tableNumber}', + style: AppStyle.md.copyWith( + color: AppColor.textSecondary, + ), + ), + ], + ), + ], + ], + ), + ), + _buildStatus(), + ], + ), + const SizedBox(height: 16), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + order.status == 'pending' + ? ((order.totalAmount) - (order.totalPaid)) + .currencyFormatRpV2 + : (order.totalAmount).currencyFormatRpV2, + style: AppStyle.xl.copyWith( + fontSize: 18, + fontWeight: FontWeight.bold, + color: AppColor.primary, + ), + ), + Text( + (order.createdAt).toFormattedDateTime(), + style: TextStyle(color: AppColor.black), + ), + ], + ), + ], + ), + ), + ); + } + + Widget _buildStatus() { + switch (order.status) { + case 'pending': + return Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), + decoration: BoxDecoration( + color: AppColor.warning.withOpacity(0.15), + borderRadius: BorderRadius.circular(16), + ), + child: Text( + (order.status).toUpperCase(), + style: AppStyle.sm.copyWith( + color: AppColor.warning, + fontWeight: FontWeight.w600, + letterSpacing: 0.5, + ), + ), + ); + case 'completed': + return Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), + decoration: BoxDecoration( + color: AppColor.success.withOpacity(0.15), + borderRadius: BorderRadius.circular(16), + ), + child: Text( + (order.status).toUpperCase(), + style: TextStyle( + color: AppColor.success, + fontWeight: FontWeight.w600, + fontSize: 12, + letterSpacing: 0.5, + ), + ), + ); + default: + return Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), + decoration: BoxDecoration( + color: AppColor.textSecondary.withOpacity(0.15), + borderRadius: BorderRadius.circular(16), + ), + child: Text( + (order.status).toUpperCase(), + style: TextStyle( + color: AppColor.textSecondary, + fontWeight: FontWeight.w600, + fontSize: 12, + letterSpacing: 0.5, + ), + ), + ); + } + } +} diff --git a/lib/presentation/components/error/order_loader_error_state_widget.dart b/lib/presentation/components/error/order_loader_error_state_widget.dart new file mode 100644 index 0000000..8f716f8 --- /dev/null +++ b/lib/presentation/components/error/order_loader_error_state_widget.dart @@ -0,0 +1,67 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import '../../../application/order/order_loader/order_loader_bloc.dart'; +import '../../../domain/order/order.dart'; +import '../card/error_card.dart'; + +class OrderLoaderErrorStateWidget extends StatelessWidget { + final OrderFailure failure; + final String status; + const OrderLoaderErrorStateWidget({ + super.key, + required this.failure, + required this.status, + }); + + @override + Widget build(BuildContext context) { + return failure.maybeMap( + orElse: () => ErrorCard( + title: 'Pesanan', + message: 'Terjadi kesalahan saat memuat pesanan', + onTap: () { + context.read().add( + OrderLoaderEvent.fetched(status: status, isRefresh: true), + ); + }, + ), + dynamicErrorMessage: (value) => ErrorCard( + title: 'Pesanan', + message: value.erroMessage, + onTap: () { + context.read().add( + OrderLoaderEvent.fetched(status: status, isRefresh: true), + ); + }, + ), + empty: (value) => ErrorCard( + title: 'Pesanan', + message: 'Data Pesanan Kosong', + onTap: () { + context.read().add( + OrderLoaderEvent.fetched(status: status, isRefresh: true), + ); + }, + ), + serverError: (value) => ErrorCard( + title: 'Pesanan', + message: 'Terjadi kesalahan saat memuat pesanan', + onTap: () { + context.read().add( + OrderLoaderEvent.fetched(status: status, isRefresh: true), + ); + }, + ), + unexpectedError: (value) => ErrorCard( + title: 'Pesanan', + message: 'Terjadi kesalahan saat memuat pesanan', + onTap: () { + context.read().add( + OrderLoaderEvent.fetched(status: status, isRefresh: true), + ); + }, + ), + ); + } +} diff --git a/lib/presentation/components/field/text_field.dart b/lib/presentation/components/field/text_field.dart index 4720b80..beec9af 100644 --- a/lib/presentation/components/field/text_field.dart +++ b/lib/presentation/components/field/text_field.dart @@ -52,6 +52,7 @@ class AppTextFormField extends StatelessWidget { maxLines: maxLines, validator: validator, decoration: InputDecoration( + contentPadding: EdgeInsets.symmetric(vertical: 0, horizontal: 12), prefixIcon: prefixIcon, suffixIcon: suffixIcon, hintText: label, diff --git a/lib/presentation/components/page/page_title.dart b/lib/presentation/components/page/page_title.dart index 2f0e4bd..fbc9cf9 100644 --- a/lib/presentation/components/page/page_title.dart +++ b/lib/presentation/components/page/page_title.dart @@ -10,54 +10,70 @@ class PageTitle extends StatelessWidget { final String? subtitle; final bool isBack; final List? actionWidget; + final Widget? bottom; const PageTitle({ super.key, required this.title, this.subtitle, this.isBack = true, this.actionWidget, + this.bottom, }); @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.router.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), - ), - ], - ], + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + 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), ), ), - if (actionWidget != null) ...actionWidget!, - ], - ), + child: Row( + children: [ + if (isBack) ...[ + GestureDetector( + onTap: () => context.router.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!, + ], + ), + ), + bottom ?? const SizedBox.shrink(), + ], ); } } diff --git a/lib/presentation/components/picker/date_range_picker.dart b/lib/presentation/components/picker/date_range_picker.dart new file mode 100644 index 0000000..66b2ca6 --- /dev/null +++ b/lib/presentation/components/picker/date_range_picker.dart @@ -0,0 +1,411 @@ +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_datepicker/datepicker.dart'; + +import '../../../common/theme/theme.dart'; + +class DateRangePickerModal { + static Future show({ + required BuildContext context, + String title = 'Pilih Rentang Tanggal', + DateTime? initialStartDate, + DateTime? initialEndDate, + DateTime? minDate, + DateTime? maxDate, + String confirmText = 'Pilih', + String cancelText = 'Batal', + Color primaryColor = AppColor.primary, + Function(DateTime? startDate, DateTime? endDate)? onChanged, + }) async { + return await showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) => _DateRangePickerDialog( + title: title, + initialStartDate: initialStartDate, + initialEndDate: initialEndDate, + minDate: minDate, + maxDate: maxDate, + confirmText: confirmText, + cancelText: cancelText, + primaryColor: primaryColor, + onChanged: onChanged, + ), + ); + } +} + +class _DateRangePickerDialog extends StatefulWidget { + final String title; + final DateTime? initialStartDate; + final DateTime? initialEndDate; + final DateTime? minDate; + final DateTime? maxDate; + final String confirmText; + final String cancelText; + final Color primaryColor; + final Function(DateTime? startDate, DateTime? endDate)? onChanged; + + const _DateRangePickerDialog({ + required this.title, + this.initialStartDate, + this.initialEndDate, + this.minDate, + this.maxDate, + required this.confirmText, + required this.cancelText, + required this.primaryColor, + this.onChanged, + }); + + @override + State<_DateRangePickerDialog> createState() => _DateRangePickerDialogState(); +} + +class _DateRangePickerDialogState extends State<_DateRangePickerDialog> + with TickerProviderStateMixin { + DateRangePickerSelectionChangedArgs? _selectionChangedArgs; + late AnimationController _animationController; + late Animation _scaleAnimation; + late Animation _fadeAnimation; + + @override + void initState() { + super.initState(); + _animationController = AnimationController( + duration: const Duration(milliseconds: 300), + vsync: this, + ); + _scaleAnimation = Tween(begin: 0.8, end: 1.0).animate( + CurvedAnimation(parent: _animationController, curve: Curves.elasticOut), + ); + _fadeAnimation = Tween(begin: 0.0, end: 1.0).animate( + CurvedAnimation(parent: _animationController, curve: Curves.easeInOut), + ); + _animationController.forward(); + } + + @override + void dispose() { + _animationController.dispose(); + super.dispose(); + } + + void _onSelectionChanged(DateRangePickerSelectionChangedArgs args) { + setState(() { + _selectionChangedArgs = args; + }); + + // Note: onChanged callback is now called only when confirm button is pressed + // This allows users to see real-time selection without triggering callbacks + } + + String _getSelectionText() { + if (_selectionChangedArgs?.value is PickerDateRange) { + final PickerDateRange range = _selectionChangedArgs!.value; + if (range.startDate != null && range.endDate != null) { + return '${_formatDate(range.startDate!)} - ${_formatDate(range.endDate!)}'; + } else if (range.startDate != null) { + return _formatDate(range.startDate!); + } + } + return 'Belum ada tanggal dipilih'; + } + + String _formatDate(DateTime date) { + final months = [ + 'Jan', + 'Feb', + 'Mar', + 'Apr', + 'Mei', + 'Jun', + 'Jul', + 'Agu', + 'Sep', + 'Okt', + 'Nov', + 'Des', + ]; + return '${date.day} ${months[date.month - 1]} ${date.year}'; + } + + bool get _isValidSelection { + if (_selectionChangedArgs?.value is PickerDateRange) { + final PickerDateRange range = _selectionChangedArgs!.value; + return range.startDate != null && range.endDate != null; + } + return false; + } + + @override + Widget build(BuildContext context) { + return AnimatedBuilder( + animation: _animationController, + builder: (context, child) { + return FadeTransition( + opacity: _fadeAnimation, + child: ScaleTransition( + scale: _scaleAnimation, + child: Dialog( + backgroundColor: Colors.transparent, + elevation: 0, + insetPadding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 24, + ), + child: Container( + width: MediaQuery.of(context).size.width, + constraints: BoxConstraints( + maxWidth: 400, + maxHeight: MediaQuery.of(context).size.height * 0.85, + ), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.1), + blurRadius: 20, + offset: const Offset(0, 10), + ), + ], + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + // Header + Container( + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + widget.primaryColor, + widget.primaryColor.withOpacity(0.8), + ], + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(20), + topRight: Radius.circular(20), + ), + ), + child: Row( + children: [ + Icon( + Icons.calendar_today_rounded, + color: Colors.white, + size: 24, + ), + const SizedBox(width: 12), + Expanded( + child: Text( + widget.title, + style: const TextStyle( + color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ), + + // Scrollable Content + Flexible( + child: SingleChildScrollView( + child: Column( + children: [ + // Selection Info + Container( + width: double.infinity, + padding: const EdgeInsets.all(12), + margin: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: widget.primaryColor.withOpacity(0.1), + borderRadius: BorderRadius.circular(12), + border: Border.all( + color: widget.primaryColor.withOpacity(0.2), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Tanggal Terpilih:', + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w500, + color: widget.primaryColor, + ), + ), + const SizedBox(height: 4), + Text( + _getSelectionText(), + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + color: Colors.black87, + ), + ), + ], + ), + ), + + // Date Picker + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), + child: Container( + height: 320, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + border: Border.all( + color: Colors.grey.withOpacity(0.2), + ), + ), + child: SfDateRangePicker( + onSelectionChanged: _onSelectionChanged, + selectionMode: + DateRangePickerSelectionMode.range, + initialSelectedRange: + (widget.initialStartDate != null && + widget.initialEndDate != null) + ? PickerDateRange( + widget.initialStartDate, + widget.initialEndDate, + ) + : null, + minDate: widget.minDate, + maxDate: widget.maxDate, + startRangeSelectionColor: widget.primaryColor, + endRangeSelectionColor: widget.primaryColor, + rangeSelectionColor: widget.primaryColor + .withOpacity(0.2), + todayHighlightColor: widget.primaryColor, + headerStyle: DateRangePickerHeaderStyle( + backgroundColor: Colors.transparent, + textAlign: TextAlign.center, + textStyle: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + color: Colors.black87, + ), + ), + monthViewSettings: + DateRangePickerMonthViewSettings( + viewHeaderStyle: + DateRangePickerViewHeaderStyle( + backgroundColor: Colors.grey + .withOpacity(0.1), + textStyle: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: widget.primaryColor, + ), + ), + ), + selectionTextStyle: const TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 14, + ), + rangeTextStyle: TextStyle( + color: widget.primaryColor, + fontWeight: FontWeight.w500, + fontSize: 14, + ), + ), + ), + ), + ], + ), + ), + ), + + // Action Buttons + Padding( + padding: const EdgeInsets.all(20), + child: Row( + children: [ + Expanded( + child: OutlinedButton( + onPressed: () => Navigator.of(context).pop(), + style: OutlinedButton.styleFrom( + padding: const EdgeInsets.symmetric( + vertical: 14, + ), + side: BorderSide(color: Colors.grey.shade400), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + child: Text( + widget.cancelText, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + color: Colors.grey, + ), + ), + ), + ), + const SizedBox(width: 16), + Expanded( + child: ElevatedButton( + onPressed: _isValidSelection + ? () { + // Call onChanged when confirm button is pressed + if (widget.onChanged != null && + _selectionChangedArgs?.value + is PickerDateRange) { + final PickerDateRange range = + _selectionChangedArgs!.value; + widget.onChanged!( + range.startDate, + range.endDate, + ); + } + Navigator.of( + context, + ).pop(_selectionChangedArgs); + } + : null, + style: ElevatedButton.styleFrom( + backgroundColor: widget.primaryColor, + padding: const EdgeInsets.symmetric( + vertical: 14, + ), + elevation: 2, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + disabledBackgroundColor: Colors.grey.shade300, + ), + child: Text( + widget.confirmText, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + color: _isValidSelection + ? Colors.white + : Colors.grey.shade600, + ), + ), + ), + ), + ], + ), + ), + ], + ), + ), + ), + ), + ); + }, + ); + } +} diff --git a/lib/presentation/pages/main/pages/home/widgets/home_right_title.dart b/lib/presentation/pages/main/pages/home/widgets/home_right_title.dart index aec6cb0..c90420a 100644 --- a/lib/presentation/pages/main/pages/home/widgets/home_right_title.dart +++ b/lib/presentation/pages/main/pages/home/widgets/home_right_title.dart @@ -30,7 +30,11 @@ class HomeRightTitle extends StatelessWidget { children: [ Expanded( child: Row( - children: [_buildButton('Daftar Pesanan', Icons.list, () {})], + children: [ + _buildButton('Daftar Pesanan', Icons.list, () { + context.router.push(OrderRoute(status: 'pending')); + }), + ], ), ), Expanded( diff --git a/lib/presentation/pages/order/order_page.dart b/lib/presentation/pages/order/order_page.dart new file mode 100644 index 0000000..c534e77 --- /dev/null +++ b/lib/presentation/pages/order/order_page.dart @@ -0,0 +1,71 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import '../../../application/order/order_loader/order_loader_bloc.dart'; +import '../../../common/theme/theme.dart'; +import '../../../injection.dart'; +import 'widgets/order_left_panel.dart'; +import 'widgets/order_right_panel.dart'; + +@RoutePage() +class OrderPage extends StatelessWidget implements AutoRouteWrapper { + final String status; + const OrderPage({super.key, required this.status}); + + @override + Widget build(BuildContext context) { + return MultiBlocListener( + listeners: [ + BlocListener( + listenWhen: (previous, current) => + previous.startDate != current.startDate || + previous.endDate != current.endDate, + listener: (context, state) { + context.read().add( + OrderLoaderEvent.fetched(status: status, isRefresh: true), + ); + }, + ), + BlocListener( + listenWhen: (previous, current) => previous.search != current.search, + listener: (context, state) { + context.read().add( + OrderLoaderEvent.fetched(status: status, isRefresh: true), + ); + }, + ), + ], + child: SafeArea( + child: Scaffold( + backgroundColor: AppColor.background, + body: BlocBuilder( + builder: (context, state) { + return Row( + children: [ + Expanded( + flex: 2, + child: Material( + color: AppColor.white, + child: OrderLeftPanel(state: state, status: status), + ), + ), + Expanded(flex: 4, child: OrderRightPanel(state: state)), + ], + ); + }, + ), + ), + ), + ); + } + + @override + Widget wrappedRoute(BuildContext context) => BlocProvider( + create: (context) => + getIt() + ..add(OrderLoaderEvent.fetched(status: status, isRefresh: true)), + child: this, + ); +} diff --git a/lib/presentation/pages/order/widgets/order_information.dart b/lib/presentation/pages/order/widgets/order_information.dart new file mode 100644 index 0000000..34ee492 --- /dev/null +++ b/lib/presentation/pages/order/widgets/order_information.dart @@ -0,0 +1,130 @@ +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 OrderInformation extends StatelessWidget { + final Order? order; + const OrderInformation({super.key, this.order}); + + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: AppColor.primary, + borderRadius: BorderRadius.circular(8), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + order?.orderNumber ?? "", + style: const TextStyle( + color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + _buildStatus(), + ], + ), + const SizedBox(height: 8), + Row( + children: [ + if (order?.orderType == 'dineIn') ...[ + _buildRowItem( + Icons.table_restaurant_outlined, + 'Meja ${order?.tableNumber}', + ), + const SizedBox(width: 16), + ], + _buildRowItem(Icons.restaurant_outlined, '${order?.orderType}'), + ], + ), + const SizedBox(height: 8), + Text( + 'Pelanggan: ${order?.metadata['customer_name'] ?? ""}', + style: const TextStyle(color: Colors.white, fontSize: 14), + ), + Text( + 'Dibuat: ${order?.createdAt.toFormattedDateTime() ?? ""}', + style: const TextStyle(color: Colors.white70, fontSize: 12), + ), + ], + ), + ); + } + + Row _buildRowItem(IconData icon, String title) { + return Row( + children: [ + Icon(icon, color: Colors.white70, size: 16), + const SpaceWidth(4), + Text( + title, + style: const TextStyle(color: Colors.white70, fontSize: 14), + ), + ], + ); + } + + Container _buildStatus() { + switch (order?.status) { + case 'pending': + return Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4), + decoration: BoxDecoration( + color: Colors.orange, + borderRadius: BorderRadius.circular(12), + ), + child: Text( + (order?.status ?? "").toUpperCase(), + style: TextStyle( + color: Colors.white, + fontSize: 12, + fontWeight: FontWeight.bold, + ), + ), + ); + case 'completed': + return Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4), + decoration: BoxDecoration( + color: Colors.greenAccent, + borderRadius: BorderRadius.circular(12), + ), + child: Text( + (order?.status ?? "").toUpperCase(), + style: TextStyle( + color: Colors.white, + fontSize: 12, + fontWeight: FontWeight.bold, + ), + ), + ); + default: + return Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4), + decoration: BoxDecoration( + color: Colors.grey, + borderRadius: BorderRadius.circular(12), + ), + child: Text( + (order?.status ?? "").toUpperCase(), + style: TextStyle( + color: Colors.white, + fontSize: 12, + fontWeight: FontWeight.bold, + ), + ), + ); + } + } +} diff --git a/lib/presentation/pages/order/widgets/order_left_panel.dart b/lib/presentation/pages/order/widgets/order_left_panel.dart new file mode 100644 index 0000000..e37ca87 --- /dev/null +++ b/lib/presentation/pages/order/widgets/order_left_panel.dart @@ -0,0 +1,71 @@ +import 'package:flutter/widgets.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import '../../../../application/order/order_loader/order_loader_bloc.dart'; +import '../../../../common/theme/theme.dart'; +import '../../../components/card/order_card.dart'; +import '../../../components/error/order_loader_error_state_widget.dart'; +import '../../../components/loader/loader_with_text.dart'; +import 'order_title.dart'; + +class OrderLeftPanel extends StatelessWidget { + final String status; + final OrderLoaderState state; + const OrderLeftPanel({super.key, required this.state, required this.status}); + + @override + Widget build(BuildContext context) { + return Column( + children: [ + OrderTitle( + startDate: state.startDate, + endDate: state.endDate, + title: status == 'pending' ? "Pending Pesanan" : "Daftar Pesanan", + onChanged: (value) { + Future.delayed(const Duration(milliseconds: 800), () { + context.read().add( + OrderLoaderEvent.searchChange(value), + ); + }); + }, + onDateRangeChanged: (start, end) { + context.read().add( + OrderLoaderEvent.dateTimeRangeChange(start!, end!), + ); + }, + ), + Expanded( + child: state.failureOption.fold(() { + if (state.isFetching) { + return Center(child: LoaderWithText()); + } + + if (state.orders.isEmpty) { + return Center( + child: Text( + "Belum ada transaksi saat ini. ", + style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold), + ), + ); + } + + return ListView.builder( + itemCount: state.orders.length, + itemBuilder: (context, index) => GestureDetector( + onTap: () { + context.read().add( + OrderLoaderEvent.setSelectedOrder(state.orders[index]), + ); + }, + child: OrderCard( + order: state.orders[index], + isActive: state.orders[index] == state.selectedOrder, + ), + ), + ); + }, (f) => OrderLoaderErrorStateWidget(failure: f, status: status)), + ), + ], + ); + } +} diff --git a/lib/presentation/pages/order/widgets/order_list.dart b/lib/presentation/pages/order/widgets/order_list.dart new file mode 100644 index 0000000..e4936e5 --- /dev/null +++ b/lib/presentation/pages/order/widgets/order_list.dart @@ -0,0 +1,357 @@ +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 OrderList extends StatelessWidget { + final Order? order; + const OrderList({super.key, this.order}); + + @override + Widget build(BuildContext context) { + return Container( + margin: const EdgeInsets.only(top: 16), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(16), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _buildHeader(context), + const SpaceHeight(8), + _buildItemsList(context), + const SpaceHeight(8), + ], + ), + ); + } + + Widget _buildHeader(BuildContext context) { + return Container( + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + AppColor.primary.withOpacity(0.1), + AppColor.primary.withOpacity(0.05), + ], + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(16), + topRight: Radius.circular(16), + ), + border: Border( + bottom: BorderSide( + color: AppColor.primary.withOpacity(0.1), + width: 1, + ), + ), + ), + child: Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Daftar Pembelian', + style: AppStyle.xl.copyWith( + fontWeight: FontWeight.w700, + letterSpacing: -0.5, + ), + ), + const SizedBox(height: 4), + Text( + '${order?.orderItems.length ?? 0} item', + style: TextStyle( + color: Colors.grey.shade600, + fontSize: 14, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), + decoration: BoxDecoration( + color: AppColor.primary.withOpacity(0.1), + borderRadius: BorderRadius.circular(20), + border: Border.all(color: AppColor.primary.withOpacity(0.2)), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + Icons.shopping_cart_outlined, + size: 16, + color: AppColor.primary, + ), + const SizedBox(width: 4), + Text( + 'Order', + style: AppStyle.sm.copyWith( + fontSize: 12, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), + ], + ), + ); + } + + Widget _buildItemsList(BuildContext context) { + return Column( + children: List.generate(order?.orderItems.length ?? 0, (index) { + final item = order!.orderItems[index]; + return _buildItem(context, item, index); + }).toList(), + ); + } + + Widget _buildItem(BuildContext context, OrderItem product, int index) { + return AnimatedContainer( + duration: const Duration(milliseconds: 200), + margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(12), + border: Border.all(color: Colors.grey.shade200, width: 1), + ), + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Text( + product.productName, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + letterSpacing: -0.2, + ), + ), + ), + _buildStatusBadge(product.status), + ], + ), + if (product.productVariantName != '') ...[ + const SizedBox(height: 4), + Container( + padding: const EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + decoration: BoxDecoration( + color: Colors.grey.shade100, + borderRadius: BorderRadius.circular(6), + ), + child: Text( + product.productVariantName, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w500, + color: Colors.grey.shade700, + ), + ), + ), + ], + const SizedBox(height: 12), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Harga Satuan', + style: TextStyle( + fontSize: 12, + color: Colors.grey.shade600, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 2), + Text( + (product.unitPrice) + .toString() + .currencyFormatRpV2, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 6, + ), + decoration: BoxDecoration( + color: AppColor.primary.withOpacity(0.1), + borderRadius: BorderRadius.circular(8), + ), + child: Text( + 'x${product.quantity}', + style: AppStyle.md.copyWith( + fontWeight: FontWeight.w600, + color: AppColor.primary, + ), + ), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + 'Total', + style: AppStyle.sm.copyWith( + color: Colors.grey.shade600, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 2), + Text( + (product.totalPrice) + .toString() + .currencyFormatRpV2, + style: AppStyle.lg.copyWith( + fontWeight: FontWeight.w700, + color: AppColor.primary, + ), + ), + ], + ), + ], + ), + ], + ), + ), + ], + ), + if (order?.splitType == 'ITEM' && order?.status == 'pending') ...[ + SpaceHeight(6), + Align( + alignment: Alignment.centerRight, + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 4, + ), + decoration: BoxDecoration( + color: AppColor.primary.withOpacity(0.2), + borderRadius: BorderRadius.circular(8), + border: Border.all(color: AppColor.primary), + ), + child: RichText( + text: TextSpan( + children: [ + TextSpan( + text: '${product.paidQuantity} ', + style: AppStyle.sm.copyWith( + fontWeight: FontWeight.w600, + color: AppColor.primary, + ), + ), + TextSpan( + text: 'dari ', + style: AppStyle.sm.copyWith(color: AppColor.primary), + ), + TextSpan( + text: '${product.quantity} ', + style: AppStyle.sm.copyWith( + fontWeight: FontWeight.w600, + color: AppColor.primary, + ), + ), + TextSpan( + text: 'kuantiti telah dibayar.', + style: AppStyle.sm.copyWith(color: AppColor.primary), + ), + ], + ), + ), + ), + ), + ], + ], + ), + ), + ); + } + + Widget _buildStatusBadge(String? status) { + Color backgroundColor; + Color textColor; + String displayText; + IconData icon; + + switch (status) { + case "pending": + backgroundColor = Colors.white; + textColor = Colors.white; + displayText = "Pending"; + icon = Icons.access_time; + break; + case "cancelled": + backgroundColor = Colors.red.withOpacity(0.1); + textColor = Colors.red.shade700; + displayText = "Batal"; + icon = Icons.cancel_outlined; + break; + case "refund": + backgroundColor = Colors.purple.withOpacity(0.1); + textColor = Colors.purple.shade700; + displayText = "Refund"; + icon = Icons.undo; + break; + default: + backgroundColor = Colors.green.withOpacity(0.1); + textColor = Colors.green.shade700; + displayText = "Selesai"; + icon = Icons.check_circle_outline; + } + + return Container( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6), + decoration: BoxDecoration( + color: backgroundColor, + borderRadius: BorderRadius.circular(20), + border: Border.all(color: textColor.withOpacity(0.2)), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon(icon, size: 14, color: textColor), + const SizedBox(width: 4), + Text( + displayText, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: textColor, + ), + ), + ], + ), + ); + } +} diff --git a/lib/presentation/pages/order/widgets/order_list_payment.dart b/lib/presentation/pages/order/widgets/order_list_payment.dart new file mode 100644 index 0000000..3a2f792 --- /dev/null +++ b/lib/presentation/pages/order/widgets/order_list_payment.dart @@ -0,0 +1,166 @@ +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 OrderListPayment extends StatelessWidget { + final Order? order; + const OrderListPayment({super.key, this.order}); + + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Informasi Pembayaran', + style: AppStyle.lg.copyWith( + fontWeight: FontWeight.bold, + color: AppColor.primary, + ), + ), + _buildPaymentStatus(), + ], + ), + const SpaceHeight(12), + ...List.generate( + order?.payments.length ?? 0, + (index) => Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: _buildPaymentItem( + order?.payments[index] ?? PaymentOrder.empty(), + ), + ), + ), + const SpaceHeight(4), + const Divider(), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Jumlah yang Dibayar', + style: AppStyle.md.copyWith(color: Colors.grey.shade700), + ), + Text( + (order?.totalPaid ?? 0).currencyFormatRpV2, + style: TextStyle(fontWeight: FontWeight.w500), + ), + ], + ), + if (((order?.totalAmount ?? 0) - (order?.totalPaid ?? 0)) != 0) ...[ + const SpaceHeight(4), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Sisa Tagihan', + style: TextStyle( + color: Colors.red.shade700, + fontWeight: FontWeight.w500, + ), + ), + Text( + ((order?.totalAmount ?? 0) - (order?.totalPaid ?? 0)) + .currencyFormatRpV2, + style: TextStyle( + color: Colors.red.shade700, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ], + ], + ), + ); + } + + Container _buildPaymentStatus() { + switch (order?.paymentStatus) { + case 'completed': + return Container( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), + decoration: BoxDecoration( + color: AppColor.success.withOpacity(0.2), + borderRadius: BorderRadius.circular(4), + ), + child: Text( + (order?.paymentStatus ?? "").toTitleCase(), + style: AppStyle.xs.copyWith( + fontSize: 10, + fontWeight: FontWeight.bold, + color: AppColor.success, + ), + ), + ); + default: + return Container( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), + decoration: BoxDecoration( + color: Colors.amber.shade100, + borderRadius: BorderRadius.circular(4), + ), + child: Text( + (order?.paymentStatus ?? "").toTitleCase(), + style: AppStyle.xs.copyWith( + fontSize: 10, + fontWeight: FontWeight.bold, + color: Colors.amber.shade800, + ), + ), + ); + } + } + + Row _buildPaymentItem(PaymentOrder payment) { + return Row( + children: [ + Container( + width: 32, + height: 32, + decoration: BoxDecoration( + color: Colors.green.shade100, + borderRadius: BorderRadius.circular(4), + ), + child: Icon(Icons.payments, color: Colors.green.shade700, size: 16), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + payment.paymentMethodName, + style: AppStyle.md.copyWith(fontWeight: FontWeight.w500), + ), + if ((payment.splitTotal) > 1) + Text( + 'Split ${payment.splitNumber} of ${payment.splitTotal}', + style: AppStyle.md.copyWith(color: Colors.grey.shade600), + ), + ], + ), + ), + Text( + (payment.amount).currencyFormatRpV2, + style: AppStyle.md.copyWith( + fontWeight: FontWeight.w600, + color: AppColor.success, + ), + ), + ], + ); + } +} diff --git a/lib/presentation/pages/order/widgets/order_payment_summary.dart b/lib/presentation/pages/order/widgets/order_payment_summary.dart new file mode 100644 index 0000000..d173448 --- /dev/null +++ b/lib/presentation/pages/order/widgets/order_payment_summary.dart @@ -0,0 +1,88 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/extension/extension.dart'; +import '../../../../common/theme/theme.dart'; +import '../../../../domain/order/order.dart'; +import '../../../components/border/dashed_border.dart'; +import '../../../components/spaces/space.dart'; + +class OrderPaymentSummary extends StatelessWidget { + final Order? order; + const OrderPaymentSummary({super.key, this.order}); + + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Ringkasan Pembayaran', + style: AppStyle.lg.copyWith( + fontWeight: FontWeight.bold, + color: AppColor.primary, + ), + ), + const SpaceHeight(12), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Subtotal', + style: AppStyle.md.copyWith(color: Colors.grey.shade700), + ), + Text((order?.subtotal ?? 0).currencyFormatRpV2), + ], + ), + const SpaceHeight(4), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Tax', + style: AppStyle.md.copyWith(color: Colors.grey.shade700), + ), + Text((order?.taxAmount ?? 0).currencyFormatRpV2), + ], + ), + const SpaceHeight(4), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Discount', + style: AppStyle.md.copyWith(color: Colors.grey.shade700), + ), + Text((order?.discountAmount ?? 0).currencyFormatRpV2), + ], + ), + const SpaceHeight(8), + const DashedDivider(color: AppColor.border), + const SpaceHeight(8), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text( + 'Total', + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + Text( + (order?.totalAmount ?? 0).currencyFormatRpV2, + style: AppStyle.lg.copyWith( + fontWeight: FontWeight.bold, + color: AppColor.primary, + ), + ), + ], + ), + ], + ), + ); + } +} diff --git a/lib/presentation/pages/order/widgets/order_right_panel.dart b/lib/presentation/pages/order/widgets/order_right_panel.dart new file mode 100644 index 0000000..9869831 --- /dev/null +++ b/lib/presentation/pages/order/widgets/order_right_panel.dart @@ -0,0 +1,114 @@ +import 'package:flutter/material.dart'; + +import '../../../../application/order/order_loader/order_loader_bloc.dart'; +import '../../../../common/theme/theme.dart'; +import '../../../components/button/button.dart'; +import '../../../components/spaces/space.dart'; +import 'order_information.dart'; +import 'order_list.dart'; +import 'order_list_payment.dart'; +import 'order_payment_summary.dart'; + +class OrderRightPanel extends StatelessWidget { + final OrderLoaderState state; + const OrderRightPanel({super.key, required this.state}); + + @override + Widget build(BuildContext context) { + if (state.selectedOrder == null) { + return Center( + child: Text( + "Belum ada order yang dipilih.", + style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold), + ), + ); + } + + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + OrderInformation(order: state.selectedOrder), + OrderList(order: state.selectedOrder), + const SpaceHeight(16), + OrderPaymentSummary(order: state.selectedOrder), + const SpaceHeight(16), + if (state.selectedOrder?.payments != null && + state.selectedOrder?.payments.isNotEmpty == true) ...[ + OrderListPayment(order: state.selectedOrder), + const SpaceHeight(20), + ], + ], + ), + ), + ), + ), + Container( + padding: EdgeInsets.all(16), + decoration: BoxDecoration(color: AppColor.white), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + AppElevatedButton.outlined( + onPressed: () { + if (state.selectedOrder?.status == 'completed') { + // onPrintRecipt( + // context, + // order: orderDetail!, + // paymentMethod: + // orderDetail!.payments + // ?.map((p) => p.paymentMethodName) + // .join(', ') ?? + // "", + // nominalBayar: orderDetail?.totalPaid ?? 0, + // kembalian: 0, + // productQuantity: orderDetail!.orderItems! + // .toProductQuantities(), + // ); + } else { + // onPrintBill( + // context, + // productQuantity: orderDetail!.orderItems! + // .toProductQuantities(), + // order: orderDetail!, + // ); + } + }, + label: 'Print Bill', + icon: Icon(Icons.print), + ), + SpaceWidth(8), + if (state.selectedOrder?.status == 'pending') ...[ + AppElevatedButton.outlined( + onPressed: () {}, + label: 'Void', + icon: Icon(Icons.undo), + ), + SpaceWidth(8), + AppElevatedButton.outlined( + onPressed: () { + // context.push(SplitBillPage(order: orderDetail!)); + }, + label: 'Split Bill', + icon: Icon(Icons.calculate_outlined), + ), + SpaceWidth(8), + AppElevatedButton.filled( + width: 120, + onPressed: () {}, + label: 'Bayar', + icon: Icon(Icons.payment, color: Colors.white), + ), + ], + ], + ), + ), + ], + ); + } +} diff --git a/lib/presentation/pages/order/widgets/order_title.dart b/lib/presentation/pages/order/widgets/order_title.dart new file mode 100644 index 0000000..c67b35c --- /dev/null +++ b/lib/presentation/pages/order/widgets/order_title.dart @@ -0,0 +1,93 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/extension/extension.dart'; +import '../../../../common/theme/theme.dart'; +import '../../../components/field/field.dart'; +import '../../../components/page/page_title.dart'; +import '../../../components/picker/date_range_picker.dart'; +import '../../../components/spaces/space.dart'; + +class OrderTitle extends StatelessWidget { + final String title; + final DateTime startDate; + final DateTime endDate; + final Function(String) onChanged; + final void Function(DateTime? start, DateTime? end) onDateRangeChanged; + const OrderTitle({ + super.key, + required this.title, + required this.startDate, + required this.endDate, + required this.onChanged, + required this.onDateRangeChanged, + }); + + @override + Widget build(BuildContext context) { + return PageTitle( + title: title, + bottom: Container( + 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: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + startDate.toFormattedDate() == endDate.toFormattedDate() + ? startDate.toFormattedDate() + : '${startDate.toFormattedDate()} - ${endDate.toFormattedDate()}', + style: AppStyle.md.copyWith(fontWeight: FontWeight.w600), + ), + Text( + '0 Pesanan', + style: AppStyle.md.copyWith(fontWeight: FontWeight.w600), + ), + ], + ), + SpaceHeight(16), + Row( + children: [ + Expanded( + child: AppTextFormField( + onChanged: onChanged, + label: 'Cari Pesanan', + showLabel: false, + ), + ), + SpaceWidth(12), + GestureDetector( + onTap: () => DateRangePickerModal.show( + context: context, + initialStartDate: startDate, + initialEndDate: endDate, + primaryColor: AppColor.primary, + onChanged: onDateRangeChanged, + ), + child: Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: AppColor.primary, + borderRadius: BorderRadius.circular(12), + ), + child: Icon( + Icons.filter_list_outlined, + color: AppColor.white, + size: 24, + ), + ), + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/lib/presentation/router/app_router.dart b/lib/presentation/router/app_router.dart index 78017e3..cfda196 100644 --- a/lib/presentation/router/app_router.dart +++ b/lib/presentation/router/app_router.dart @@ -28,5 +28,8 @@ class AppRouter extends RootStackRouter { // Checkout AutoRoute(page: CheckoutRoute.page), + + // Order + AutoRoute(page: OrderRoute.page), ]; } diff --git a/lib/presentation/router/app_router.gr.dart b/lib/presentation/router/app_router.gr.dart index b49096a..77ca9bf 100644 --- a/lib/presentation/router/app_router.gr.dart +++ b/lib/presentation/router/app_router.gr.dart @@ -20,90 +20,93 @@ import 'package:apskel_pos_flutter_v2/presentation/pages/main/pages/customer/cus import 'package:apskel_pos_flutter_v2/presentation/pages/main/pages/home/home_page.dart' as _i3; import 'package:apskel_pos_flutter_v2/presentation/pages/main/pages/report/report_page.dart' - as _i6; -import 'package:apskel_pos_flutter_v2/presentation/pages/main/pages/setting/setting_page.dart' as _i7; -import 'package:apskel_pos_flutter_v2/presentation/pages/main/pages/table/table_page.dart' - as _i10; -import 'package:apskel_pos_flutter_v2/presentation/pages/splash/splash_page.dart' +import 'package:apskel_pos_flutter_v2/presentation/pages/main/pages/setting/setting_page.dart' as _i8; -import 'package:apskel_pos_flutter_v2/presentation/pages/sync/sync_page.dart' +import 'package:apskel_pos_flutter_v2/presentation/pages/main/pages/table/table_page.dart' + as _i11; +import 'package:apskel_pos_flutter_v2/presentation/pages/order/order_page.dart' + as _i6; +import 'package:apskel_pos_flutter_v2/presentation/pages/splash/splash_page.dart' as _i9; -import 'package:auto_route/auto_route.dart' as _i11; +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/widgets.dart' as _i13; /// generated route for /// [_i1.CheckoutPage] -class CheckoutRoute extends _i11.PageRouteInfo { - const CheckoutRoute({List<_i11.PageRouteInfo>? children}) +class CheckoutRoute extends _i12.PageRouteInfo { + const CheckoutRoute({List<_i12.PageRouteInfo>? children}) : super(CheckoutRoute.name, initialChildren: children); static const String name = 'CheckoutRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { - return _i11.WrappedRoute(child: const _i1.CheckoutPage()); + return _i12.WrappedRoute(child: const _i1.CheckoutPage()); }, ); } /// generated route for /// [_i2.CustomerPage] -class CustomerRoute extends _i11.PageRouteInfo { - const CustomerRoute({List<_i11.PageRouteInfo>? children}) +class CustomerRoute extends _i12.PageRouteInfo { + const CustomerRoute({List<_i12.PageRouteInfo>? children}) : super(CustomerRoute.name, initialChildren: children); static const String name = 'CustomerRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { - return _i11.WrappedRoute(child: const _i2.CustomerPage()); + return _i12.WrappedRoute(child: const _i2.CustomerPage()); }, ); } /// generated route for /// [_i3.HomePage] -class HomeRoute extends _i11.PageRouteInfo { - const HomeRoute({List<_i11.PageRouteInfo>? children}) +class HomeRoute extends _i12.PageRouteInfo { + const HomeRoute({List<_i12.PageRouteInfo>? children}) : super(HomeRoute.name, initialChildren: children); static const String name = 'HomeRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { - return _i11.WrappedRoute(child: const _i3.HomePage()); + return _i12.WrappedRoute(child: const _i3.HomePage()); }, ); } /// generated route for /// [_i4.LoginPage] -class LoginRoute extends _i11.PageRouteInfo { - const LoginRoute({List<_i11.PageRouteInfo>? children}) +class LoginRoute extends _i12.PageRouteInfo { + const LoginRoute({List<_i12.PageRouteInfo>? children}) : super(LoginRoute.name, initialChildren: children); static const String name = 'LoginRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { - return _i11.WrappedRoute(child: const _i4.LoginPage()); + return _i12.WrappedRoute(child: const _i4.LoginPage()); }, ); } /// generated route for /// [_i5.MainPage] -class MainRoute extends _i11.PageRouteInfo { - const MainRoute({List<_i11.PageRouteInfo>? children}) +class MainRoute extends _i12.PageRouteInfo { + const MainRoute({List<_i12.PageRouteInfo>? children}) : super(MainRoute.name, initialChildren: children); static const String name = 'MainRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { return const _i5.MainPage(); @@ -112,81 +115,118 @@ class MainRoute extends _i11.PageRouteInfo { } /// generated route for -/// [_i6.ReportPage] -class ReportRoute extends _i11.PageRouteInfo { - const ReportRoute({List<_i11.PageRouteInfo>? children}) +/// [_i6.OrderPage] +class OrderRoute extends _i12.PageRouteInfo { + OrderRoute({ + _i13.Key? key, + required String status, + List<_i12.PageRouteInfo>? children, + }) : super( + OrderRoute.name, + args: OrderRouteArgs(key: key, status: status), + initialChildren: children, + ); + + static const String name = 'OrderRoute'; + + static _i12.PageInfo page = _i12.PageInfo( + name, + builder: (data) { + final args = data.argsAs(); + return _i6.OrderPage(key: args.key, status: args.status); + }, + ); +} + +class OrderRouteArgs { + const OrderRouteArgs({this.key, required this.status}); + + final _i13.Key? key; + + final String status; + + @override + String toString() { + return 'OrderRouteArgs{key: $key, status: $status}'; + } +} + +/// generated route for +/// [_i7.ReportPage] +class ReportRoute extends _i12.PageRouteInfo { + const ReportRoute({List<_i12.PageRouteInfo>? children}) : super(ReportRoute.name, initialChildren: children); static const String name = 'ReportRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { - return const _i6.ReportPage(); + return const _i7.ReportPage(); }, ); } /// generated route for -/// [_i7.SettingPage] -class SettingRoute extends _i11.PageRouteInfo { - const SettingRoute({List<_i11.PageRouteInfo>? children}) +/// [_i8.SettingPage] +class SettingRoute extends _i12.PageRouteInfo { + const SettingRoute({List<_i12.PageRouteInfo>? children}) : super(SettingRoute.name, initialChildren: children); static const String name = 'SettingRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { - return const _i7.SettingPage(); + return const _i8.SettingPage(); }, ); } /// generated route for -/// [_i8.SplashPage] -class SplashRoute extends _i11.PageRouteInfo { - const SplashRoute({List<_i11.PageRouteInfo>? children}) +/// [_i9.SplashPage] +class SplashRoute extends _i12.PageRouteInfo { + const SplashRoute({List<_i12.PageRouteInfo>? children}) : super(SplashRoute.name, initialChildren: children); static const String name = 'SplashRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { - return const _i8.SplashPage(); + return const _i9.SplashPage(); }, ); } /// generated route for -/// [_i9.SyncPage] -class SyncRoute extends _i11.PageRouteInfo { - const SyncRoute({List<_i11.PageRouteInfo>? children}) +/// [_i10.SyncPage] +class SyncRoute extends _i12.PageRouteInfo { + const SyncRoute({List<_i12.PageRouteInfo>? children}) : super(SyncRoute.name, initialChildren: children); static const String name = 'SyncRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { - return _i11.WrappedRoute(child: const _i9.SyncPage()); + return _i12.WrappedRoute(child: const _i10.SyncPage()); }, ); } /// generated route for -/// [_i10.TablePage] -class TableRoute extends _i11.PageRouteInfo { - const TableRoute({List<_i11.PageRouteInfo>? children}) +/// [_i11.TablePage] +class TableRoute extends _i12.PageRouteInfo { + const TableRoute({List<_i12.PageRouteInfo>? children}) : super(TableRoute.name, initialChildren: children); static const String name = 'TableRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { - return _i11.WrappedRoute(child: const _i10.TablePage()); + return _i12.WrappedRoute(child: const _i11.TablePage()); }, ); } diff --git a/pubspec.lock b/pubspec.lock index 74bcf10..9a30be7 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1093,6 +1093,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.4.1" + syncfusion_flutter_core: + dependency: transitive + description: + name: syncfusion_flutter_core + sha256: d03c43f577cdbe020d1632bece00cbf8bec4a7d0ab123923b69141b5fec35420 + url: "https://pub.dev" + source: hosted + version: "31.2.3" + syncfusion_flutter_datepicker: + dependency: "direct main" + description: + name: syncfusion_flutter_datepicker + sha256: f6277bd71a6d04785d7359c8caf373acae07132f1cc453b835173261dbd5ddb6 + url: "https://pub.dev" + source: hosted + version: "31.2.3" synchronized: dependency: transitive description: @@ -1247,4 +1263,4 @@ packages: version: "3.1.3" sdks: dart: ">=3.9.0 <4.0.0" - flutter: ">=3.35.0" + flutter: ">=3.35.1" diff --git a/pubspec.yaml b/pubspec.yaml index 555e83f..17fc9a9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -37,6 +37,7 @@ dependencies: cached_network_image: ^3.4.1 shimmer: ^3.0.0 dropdown_search: ^5.0.6 + syncfusion_flutter_datepicker: ^31.2.3 dev_dependencies: flutter_test: