Compare commits
2 Commits
e1825fe86f
...
c8f8d2ec9d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8f8d2ec9d | ||
|
|
87a62a287a |
@ -1,17 +1,21 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:enaklo_pos/core/constants/variables.dart';
|
||||
import 'package:enaklo_pos/core/network/dio_client.dart';
|
||||
import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_remote_datasource.dart';
|
||||
import 'package:enaklo_pos/data/models/response/payment_method_response_model.dart';
|
||||
import 'package:enaklo_pos/data/models/response/summary_response_model.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/order_model.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/order_request.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class OrderRemoteDatasource {
|
||||
final Dio dio = DioClient.instance;
|
||||
|
||||
//save order to remote server
|
||||
Future<bool> saveOrder(OrderModel orderModel) async {
|
||||
final authData = await AuthLocalDataSource().getAuthData();
|
||||
@ -28,11 +32,11 @@ class OrderRemoteDatasource {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
print("📥 HTTP Status Code: ${response.statusCode}");
|
||||
print("📥 Response Body: ${response.body}");
|
||||
print("📥 Response Headers: ${response.headers}");
|
||||
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
print("âś… API call successful - Order saved to server");
|
||||
return true;
|
||||
@ -69,7 +73,8 @@ class OrderRemoteDatasource {
|
||||
print("âś… getOrderByRangeDate API call successful");
|
||||
return Right(OrderResponseModel.fromJson(response.body));
|
||||
} else {
|
||||
print("❌ getOrderByRangeDate API call failed - Status: ${response.statusCode}");
|
||||
print(
|
||||
"❌ getOrderByRangeDate API call failed - Status: ${response.statusCode}");
|
||||
print("❌ Error Response: ${response.body}");
|
||||
return const Left("Failed Load Data");
|
||||
}
|
||||
@ -102,7 +107,8 @@ class OrderRemoteDatasource {
|
||||
print("âś… getSummaryByRangeDate API call successful");
|
||||
return Right(SummaryResponseModel.fromJson(response.body));
|
||||
} else {
|
||||
print("❌ getSummaryByRangeDate API call failed - Status: ${response.statusCode}");
|
||||
print(
|
||||
"❌ getSummaryByRangeDate API call failed - Status: ${response.statusCode}");
|
||||
print("❌ Error Response: ${response.body}");
|
||||
return const Left("Failed Load Data");
|
||||
}
|
||||
@ -112,7 +118,8 @@ class OrderRemoteDatasource {
|
||||
}
|
||||
}
|
||||
|
||||
Future<Either<String, PaymentMethodResponseModel>> getPaymentMethodByRangeDate(
|
||||
Future<Either<String, PaymentMethodResponseModel>>
|
||||
getPaymentMethodByRangeDate(
|
||||
String startDate,
|
||||
String endDate,
|
||||
) async {
|
||||
@ -134,7 +141,8 @@ class OrderRemoteDatasource {
|
||||
print("âś… getPaymentMethodByRangeDate API call successful");
|
||||
return Right(PaymentMethodResponseModel.fromJson(response.body));
|
||||
} else {
|
||||
print("❌ getPaymentMethodByRangeDate API call failed - Status: ${response.statusCode}");
|
||||
print(
|
||||
"❌ getPaymentMethodByRangeDate API call failed - Status: ${response.statusCode}");
|
||||
print("❌ Error Response: ${response.body}");
|
||||
return const Left("Failed Load Payment Method Data");
|
||||
}
|
||||
@ -162,16 +170,17 @@ class OrderRemoteDatasource {
|
||||
'order_items': orderItems,
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
print("📥 Add Order Items HTTP Status Code: ${response.statusCode}");
|
||||
print("📥 Add Order Items Response Body: ${response.body}");
|
||||
print("📥 Add Order Items Response Headers: ${response.headers}");
|
||||
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
print("âś… addOrderItems API call successful");
|
||||
return const Right(true);
|
||||
} else {
|
||||
print("❌ addOrderItems API call failed - Status: ${response.statusCode}");
|
||||
print(
|
||||
"❌ addOrderItems API call failed - Status: ${response.statusCode}");
|
||||
print("❌ Error Response: ${response.body}");
|
||||
return Left("Failed to add order items: ${response.body}");
|
||||
}
|
||||
@ -180,4 +189,38 @@ class OrderRemoteDatasource {
|
||||
return Left("Failed: $e");
|
||||
}
|
||||
}
|
||||
|
||||
// New Api
|
||||
Future<Either<String, bool>> createOrder(OrderRequestModel orderModel) async {
|
||||
final authData = await AuthLocalDataSource().getAuthData();
|
||||
final url = '${Variables.baseUrl}/api/v1/orders';
|
||||
|
||||
try {
|
||||
final response = await dio.post(
|
||||
url,
|
||||
data: orderModel.toMap(),
|
||||
options: Options(
|
||||
headers: {
|
||||
'Authorization': 'Bearer ${authData.token}',
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return const Right(true);
|
||||
} else {
|
||||
return const Left('Gagal membuat pesanan');
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
final errorMessage = e.response?.data['message'] ?? 'Kesalahan jaringan';
|
||||
log("đź’Ą Dio error: ${e.message}");
|
||||
log("đź’Ą Dio response: ${e.response?.data}");
|
||||
return Left(errorMessage);
|
||||
} catch (e) {
|
||||
log("đź’Ą Unexpected error: $e");
|
||||
return const Left('Terjadi kesalahan tak terduga');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
43
lib/data/datasources/outlet_remote_data_source.dart
Normal file
43
lib/data/datasources/outlet_remote_data_source.dart
Normal file
@ -0,0 +1,43 @@
|
||||
import 'dart:developer';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:enaklo_pos/core/network/dio_client.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/outlet_model.dart';
|
||||
import '../../core/constants/variables.dart';
|
||||
import 'auth_local_datasource.dart';
|
||||
|
||||
class OutletRemoteDataSource {
|
||||
final Dio dio = DioClient.instance;
|
||||
|
||||
Future<Either<String, OutletResponse>> getOutlets() async {
|
||||
try {
|
||||
final authData = await AuthLocalDataSource().getAuthData();
|
||||
final url = '${Variables.baseUrl}/api/v1/outlets/list';
|
||||
|
||||
final response = await dio.get(
|
||||
url,
|
||||
queryParameters: {
|
||||
'organization_id': authData.user?.organizationId,
|
||||
},
|
||||
options: Options(
|
||||
headers: {
|
||||
'Authorization': 'Bearer ${authData.token}',
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return Right(OutletResponse.fromMap(response.data));
|
||||
} else {
|
||||
return const Left('Failed to get outlets');
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
log("Dio error: ${e.message}");
|
||||
return Left(e.response?.data['message'] ?? 'Gagal mengambil outlet');
|
||||
} catch (e) {
|
||||
log("Unexpected error: $e");
|
||||
return const Left('Unexpected error occurred');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,8 @@
|
||||
import 'dart:developer';
|
||||
import 'package:enaklo_pos/core/constants/theme.dart';
|
||||
import 'package:enaklo_pos/data/datasources/outlet_remote_data_source.dart';
|
||||
import 'package:enaklo_pos/presentation/home/bloc/order_form/order_form_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/home/bloc/outlet_loader/outlet_loader_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/home/bloc/product_loader/product_loader_bloc.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
||||
@ -221,6 +224,12 @@ class _MyAppState extends State<MyApp> {
|
||||
BlocProvider(
|
||||
create: (context) => ProductLoaderBloc(ProductRemoteDatasource()),
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) => OrderFormBloc(OrderRemoteDatasource()),
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) => OutletLoaderBloc(OutletRemoteDataSource()),
|
||||
),
|
||||
],
|
||||
child: MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
|
||||
59
lib/presentation/home/bloc/order_form/order_form_bloc.dart
Normal file
59
lib/presentation/home/bloc/order_form/order_form_bloc.dart
Normal file
@ -0,0 +1,59 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/order_remote_datasource.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/order_request.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/order_type.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'order_form_event.dart';
|
||||
part 'order_form_state.dart';
|
||||
part 'order_form_bloc.freezed.dart';
|
||||
|
||||
class OrderFormBloc extends Bloc<OrderFormEvent, OrderFormState> {
|
||||
final OrderRemoteDatasource _orderRemoteDatasource;
|
||||
OrderFormBloc(this._orderRemoteDatasource) : super(OrderFormState.initial()) {
|
||||
on<_Create>(
|
||||
(event, emit) async {
|
||||
emit(const _Loading());
|
||||
|
||||
try {
|
||||
// Convert ProductQuantity list to the format expected by the API
|
||||
|
||||
final userData = await AuthLocalDataSource().getAuthData();
|
||||
|
||||
final orderItems = OrderRequestModel(
|
||||
customerName: event.customerName,
|
||||
notes: '',
|
||||
orderType: event.orderType.name,
|
||||
tableNumber: event.tableNumber.toString(),
|
||||
outletId: userData.user?.outletId,
|
||||
userId: userData.user?.id,
|
||||
orderItems: event.items
|
||||
.map(
|
||||
(productQuantity) => OrderItemRequest(
|
||||
productId: productQuantity.product.id,
|
||||
quantity: productQuantity.quantity,
|
||||
notes: productQuantity.notes,
|
||||
unitPrice: productQuantity.product.price,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
final result = await _orderRemoteDatasource.createOrder(orderItems);
|
||||
|
||||
result.fold(
|
||||
(error) => emit(_Error(error)),
|
||||
(success) => emit(const _Success()),
|
||||
);
|
||||
} catch (e) {
|
||||
log("Error in AddOrderItemsBloc: $e");
|
||||
emit(_Error("Failed to add order items: $e"));
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,900 @@
|
||||
// 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_form_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
/// @nodoc
|
||||
mixin _$OrderFormEvent {
|
||||
List<ProductQuantity> get items => throw _privateConstructorUsedError;
|
||||
String get customerName => throw _privateConstructorUsedError;
|
||||
OrderType get orderType => throw _privateConstructorUsedError;
|
||||
String get tableNumber => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(List<ProductQuantity> items, String customerName,
|
||||
OrderType orderType, String tableNumber)
|
||||
create,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(List<ProductQuantity> items, String customerName,
|
||||
OrderType orderType, String tableNumber)?
|
||||
create,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(List<ProductQuantity> items, String customerName,
|
||||
OrderType orderType, String tableNumber)?
|
||||
create,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Create value) create,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Create value)? create,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Create value)? create,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of OrderFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$OrderFormEventCopyWith<OrderFormEvent> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $OrderFormEventCopyWith<$Res> {
|
||||
factory $OrderFormEventCopyWith(
|
||||
OrderFormEvent value, $Res Function(OrderFormEvent) then) =
|
||||
_$OrderFormEventCopyWithImpl<$Res, OrderFormEvent>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{List<ProductQuantity> items,
|
||||
String customerName,
|
||||
OrderType orderType,
|
||||
String tableNumber});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$OrderFormEventCopyWithImpl<$Res, $Val extends OrderFormEvent>
|
||||
implements $OrderFormEventCopyWith<$Res> {
|
||||
_$OrderFormEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of OrderFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? items = null,
|
||||
Object? customerName = null,
|
||||
Object? orderType = null,
|
||||
Object? tableNumber = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
items: null == items
|
||||
? _value.items
|
||||
: items // ignore: cast_nullable_to_non_nullable
|
||||
as List<ProductQuantity>,
|
||||
customerName: null == customerName
|
||||
? _value.customerName
|
||||
: customerName // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
orderType: null == orderType
|
||||
? _value.orderType
|
||||
: orderType // ignore: cast_nullable_to_non_nullable
|
||||
as OrderType,
|
||||
tableNumber: null == tableNumber
|
||||
? _value.tableNumber
|
||||
: tableNumber // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CreateImplCopyWith<$Res>
|
||||
implements $OrderFormEventCopyWith<$Res> {
|
||||
factory _$$CreateImplCopyWith(
|
||||
_$CreateImpl value, $Res Function(_$CreateImpl) then) =
|
||||
__$$CreateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{List<ProductQuantity> items,
|
||||
String customerName,
|
||||
OrderType orderType,
|
||||
String tableNumber});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CreateImplCopyWithImpl<$Res>
|
||||
extends _$OrderFormEventCopyWithImpl<$Res, _$CreateImpl>
|
||||
implements _$$CreateImplCopyWith<$Res> {
|
||||
__$$CreateImplCopyWithImpl(
|
||||
_$CreateImpl _value, $Res Function(_$CreateImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of OrderFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? items = null,
|
||||
Object? customerName = null,
|
||||
Object? orderType = null,
|
||||
Object? tableNumber = null,
|
||||
}) {
|
||||
return _then(_$CreateImpl(
|
||||
items: null == items
|
||||
? _value._items
|
||||
: items // ignore: cast_nullable_to_non_nullable
|
||||
as List<ProductQuantity>,
|
||||
customerName: null == customerName
|
||||
? _value.customerName
|
||||
: customerName // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
orderType: null == orderType
|
||||
? _value.orderType
|
||||
: orderType // ignore: cast_nullable_to_non_nullable
|
||||
as OrderType,
|
||||
tableNumber: null == tableNumber
|
||||
? _value.tableNumber
|
||||
: tableNumber // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$CreateImpl implements _Create {
|
||||
const _$CreateImpl(
|
||||
{required final List<ProductQuantity> items,
|
||||
required this.customerName,
|
||||
required this.orderType,
|
||||
required this.tableNumber})
|
||||
: _items = items;
|
||||
|
||||
final List<ProductQuantity> _items;
|
||||
@override
|
||||
List<ProductQuantity> get items {
|
||||
if (_items is EqualUnmodifiableListView) return _items;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_items);
|
||||
}
|
||||
|
||||
@override
|
||||
final String customerName;
|
||||
@override
|
||||
final OrderType orderType;
|
||||
@override
|
||||
final String tableNumber;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OrderFormEvent.create(items: $items, customerName: $customerName, orderType: $orderType, tableNumber: $tableNumber)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CreateImpl &&
|
||||
const DeepCollectionEquality().equals(other._items, _items) &&
|
||||
(identical(other.customerName, customerName) ||
|
||||
other.customerName == customerName) &&
|
||||
(identical(other.orderType, orderType) ||
|
||||
other.orderType == orderType) &&
|
||||
(identical(other.tableNumber, tableNumber) ||
|
||||
other.tableNumber == tableNumber));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
const DeepCollectionEquality().hash(_items),
|
||||
customerName,
|
||||
orderType,
|
||||
tableNumber);
|
||||
|
||||
/// Create a copy of OrderFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$CreateImplCopyWith<_$CreateImpl> get copyWith =>
|
||||
__$$CreateImplCopyWithImpl<_$CreateImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(List<ProductQuantity> items, String customerName,
|
||||
OrderType orderType, String tableNumber)
|
||||
create,
|
||||
}) {
|
||||
return create(items, customerName, orderType, tableNumber);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(List<ProductQuantity> items, String customerName,
|
||||
OrderType orderType, String tableNumber)?
|
||||
create,
|
||||
}) {
|
||||
return create?.call(items, customerName, orderType, tableNumber);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(List<ProductQuantity> items, String customerName,
|
||||
OrderType orderType, String tableNumber)?
|
||||
create,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (create != null) {
|
||||
return create(items, customerName, orderType, tableNumber);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Create value) create,
|
||||
}) {
|
||||
return create(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Create value)? create,
|
||||
}) {
|
||||
return create?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Create value)? create,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (create != null) {
|
||||
return create(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Create implements OrderFormEvent {
|
||||
const factory _Create(
|
||||
{required final List<ProductQuantity> items,
|
||||
required final String customerName,
|
||||
required final OrderType orderType,
|
||||
required final String tableNumber}) = _$CreateImpl;
|
||||
|
||||
@override
|
||||
List<ProductQuantity> get items;
|
||||
@override
|
||||
String get customerName;
|
||||
@override
|
||||
OrderType get orderType;
|
||||
@override
|
||||
String get tableNumber;
|
||||
|
||||
/// Create a copy of OrderFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$CreateImplCopyWith<_$CreateImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$OrderFormState {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function() success,
|
||||
required TResult Function(String message) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function()? success,
|
||||
TResult? Function(String message)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function()? success,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Success value) success,
|
||||
required TResult Function(_Error value) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Success value)? success,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Success value)? success,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $OrderFormStateCopyWith<$Res> {
|
||||
factory $OrderFormStateCopyWith(
|
||||
OrderFormState value, $Res Function(OrderFormState) then) =
|
||||
_$OrderFormStateCopyWithImpl<$Res, OrderFormState>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$OrderFormStateCopyWithImpl<$Res, $Val extends OrderFormState>
|
||||
implements $OrderFormStateCopyWith<$Res> {
|
||||
_$OrderFormStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of OrderFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$InitialImplCopyWith<$Res> {
|
||||
factory _$$InitialImplCopyWith(
|
||||
_$InitialImpl value, $Res Function(_$InitialImpl) then) =
|
||||
__$$InitialImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$InitialImplCopyWithImpl<$Res>
|
||||
extends _$OrderFormStateCopyWithImpl<$Res, _$InitialImpl>
|
||||
implements _$$InitialImplCopyWith<$Res> {
|
||||
__$$InitialImplCopyWithImpl(
|
||||
_$InitialImpl _value, $Res Function(_$InitialImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of OrderFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$InitialImpl implements _Initial {
|
||||
const _$InitialImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OrderFormState.initial()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$InitialImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function() success,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return initial();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function()? success,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return initial?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function()? success,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (initial != null) {
|
||||
return initial();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Success value) success,
|
||||
required TResult Function(_Error value) error,
|
||||
}) {
|
||||
return initial(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Success value)? success,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) {
|
||||
return initial?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Success value)? success,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (initial != null) {
|
||||
return initial(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Initial implements OrderFormState {
|
||||
const factory _Initial() = _$InitialImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$LoadingImplCopyWith<$Res> {
|
||||
factory _$$LoadingImplCopyWith(
|
||||
_$LoadingImpl value, $Res Function(_$LoadingImpl) then) =
|
||||
__$$LoadingImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$LoadingImplCopyWithImpl<$Res>
|
||||
extends _$OrderFormStateCopyWithImpl<$Res, _$LoadingImpl>
|
||||
implements _$$LoadingImplCopyWith<$Res> {
|
||||
__$$LoadingImplCopyWithImpl(
|
||||
_$LoadingImpl _value, $Res Function(_$LoadingImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of OrderFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$LoadingImpl implements _Loading {
|
||||
const _$LoadingImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OrderFormState.loading()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$LoadingImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function() success,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return loading();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function()? success,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return loading?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function()? success,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Success value) success,
|
||||
required TResult Function(_Error value) error,
|
||||
}) {
|
||||
return loading(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Success value)? success,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) {
|
||||
return loading?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Success value)? success,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Loading implements OrderFormState {
|
||||
const factory _Loading() = _$LoadingImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SuccessImplCopyWith<$Res> {
|
||||
factory _$$SuccessImplCopyWith(
|
||||
_$SuccessImpl value, $Res Function(_$SuccessImpl) then) =
|
||||
__$$SuccessImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SuccessImplCopyWithImpl<$Res>
|
||||
extends _$OrderFormStateCopyWithImpl<$Res, _$SuccessImpl>
|
||||
implements _$$SuccessImplCopyWith<$Res> {
|
||||
__$$SuccessImplCopyWithImpl(
|
||||
_$SuccessImpl _value, $Res Function(_$SuccessImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of OrderFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SuccessImpl implements _Success {
|
||||
const _$SuccessImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OrderFormState.success()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$SuccessImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function() success,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return success();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function()? success,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return success?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function()? success,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (success != null) {
|
||||
return success();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Success value) success,
|
||||
required TResult Function(_Error value) error,
|
||||
}) {
|
||||
return success(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Success value)? success,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) {
|
||||
return success?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Success value)? success,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (success != null) {
|
||||
return success(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Success implements OrderFormState {
|
||||
const factory _Success() = _$SuccessImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ErrorImplCopyWith<$Res> {
|
||||
factory _$$ErrorImplCopyWith(
|
||||
_$ErrorImpl value, $Res Function(_$ErrorImpl) then) =
|
||||
__$$ErrorImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String message});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ErrorImplCopyWithImpl<$Res>
|
||||
extends _$OrderFormStateCopyWithImpl<$Res, _$ErrorImpl>
|
||||
implements _$$ErrorImplCopyWith<$Res> {
|
||||
__$$ErrorImplCopyWithImpl(
|
||||
_$ErrorImpl _value, $Res Function(_$ErrorImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of OrderFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? message = null,
|
||||
}) {
|
||||
return _then(_$ErrorImpl(
|
||||
null == message
|
||||
? _value.message
|
||||
: message // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ErrorImpl implements _Error {
|
||||
const _$ErrorImpl(this.message);
|
||||
|
||||
@override
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OrderFormState.error(message: $message)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ErrorImpl &&
|
||||
(identical(other.message, message) || other.message == message));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, message);
|
||||
|
||||
/// Create a copy of OrderFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ErrorImplCopyWith<_$ErrorImpl> get copyWith =>
|
||||
__$$ErrorImplCopyWithImpl<_$ErrorImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function() success,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return error(message);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function()? success,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return error?.call(message);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function()? success,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(message);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Success value) success,
|
||||
required TResult Function(_Error value) error,
|
||||
}) {
|
||||
return error(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Success value)? success,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) {
|
||||
return error?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Success value)? success,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Error implements OrderFormState {
|
||||
const factory _Error(final String message) = _$ErrorImpl;
|
||||
|
||||
String get message;
|
||||
|
||||
/// Create a copy of OrderFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ErrorImplCopyWith<_$ErrorImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
11
lib/presentation/home/bloc/order_form/order_form_event.dart
Normal file
11
lib/presentation/home/bloc/order_form/order_form_event.dart
Normal file
@ -0,0 +1,11 @@
|
||||
part of 'order_form_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class OrderFormEvent with _$OrderFormEvent {
|
||||
const factory OrderFormEvent.create({
|
||||
required List<ProductQuantity> items,
|
||||
required String customerName,
|
||||
required OrderType orderType,
|
||||
required String tableNumber,
|
||||
}) = _Create;
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
part of 'order_form_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class OrderFormState with _$OrderFormState {
|
||||
const factory OrderFormState.initial() = _Initial;
|
||||
const factory OrderFormState.loading() = _Loading;
|
||||
const factory OrderFormState.success() = _Success;
|
||||
const factory OrderFormState.error(String message) = _Error;
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:enaklo_pos/data/datasources/outlet_remote_data_source.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/outlet_model.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'outlet_loader_event.dart';
|
||||
part 'outlet_loader_state.dart';
|
||||
part 'outlet_loader_bloc.freezed.dart';
|
||||
|
||||
class OutletLoaderBloc extends Bloc<OutletLoaderEvent, OutletLoaderState> {
|
||||
final OutletRemoteDataSource _outletRemoteDataSource;
|
||||
OutletLoaderBloc(this._outletRemoteDataSource)
|
||||
: super(OutletLoaderState.initial()) {
|
||||
on<_GetOutlet>((event, emit) async {
|
||||
emit(const _Loading());
|
||||
final result = await _outletRemoteDataSource.getOutlets();
|
||||
result.fold(
|
||||
(l) => emit(_Error(l)),
|
||||
(r) => emit(_Loaded(r.data?.outlets ?? [])),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,790 @@
|
||||
// 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 'outlet_loader_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
/// @nodoc
|
||||
mixin _$OutletLoaderEvent {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() getOutlet,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? getOutlet,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? getOutlet,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_GetOutlet value) getOutlet,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_GetOutlet value)? getOutlet,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_GetOutlet value)? getOutlet,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $OutletLoaderEventCopyWith<$Res> {
|
||||
factory $OutletLoaderEventCopyWith(
|
||||
OutletLoaderEvent value, $Res Function(OutletLoaderEvent) then) =
|
||||
_$OutletLoaderEventCopyWithImpl<$Res, OutletLoaderEvent>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$OutletLoaderEventCopyWithImpl<$Res, $Val extends OutletLoaderEvent>
|
||||
implements $OutletLoaderEventCopyWith<$Res> {
|
||||
_$OutletLoaderEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of OutletLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$GetOutletImplCopyWith<$Res> {
|
||||
factory _$$GetOutletImplCopyWith(
|
||||
_$GetOutletImpl value, $Res Function(_$GetOutletImpl) then) =
|
||||
__$$GetOutletImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$GetOutletImplCopyWithImpl<$Res>
|
||||
extends _$OutletLoaderEventCopyWithImpl<$Res, _$GetOutletImpl>
|
||||
implements _$$GetOutletImplCopyWith<$Res> {
|
||||
__$$GetOutletImplCopyWithImpl(
|
||||
_$GetOutletImpl _value, $Res Function(_$GetOutletImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of OutletLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$GetOutletImpl implements _GetOutlet {
|
||||
const _$GetOutletImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OutletLoaderEvent.getOutlet()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$GetOutletImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() getOutlet,
|
||||
}) {
|
||||
return getOutlet();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? getOutlet,
|
||||
}) {
|
||||
return getOutlet?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? getOutlet,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (getOutlet != null) {
|
||||
return getOutlet();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_GetOutlet value) getOutlet,
|
||||
}) {
|
||||
return getOutlet(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_GetOutlet value)? getOutlet,
|
||||
}) {
|
||||
return getOutlet?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_GetOutlet value)? getOutlet,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (getOutlet != null) {
|
||||
return getOutlet(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _GetOutlet implements OutletLoaderEvent {
|
||||
const factory _GetOutlet() = _$GetOutletImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$OutletLoaderState {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<Outlet> outlets) loaded,
|
||||
required TResult Function(String message) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<Outlet> outlets)? loaded,
|
||||
TResult? Function(String message)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<Outlet> outlets)? loaded,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Loaded value) loaded,
|
||||
required TResult Function(_Error value) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Loaded value)? loaded,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Loaded value)? loaded,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $OutletLoaderStateCopyWith<$Res> {
|
||||
factory $OutletLoaderStateCopyWith(
|
||||
OutletLoaderState value, $Res Function(OutletLoaderState) then) =
|
||||
_$OutletLoaderStateCopyWithImpl<$Res, OutletLoaderState>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$OutletLoaderStateCopyWithImpl<$Res, $Val extends OutletLoaderState>
|
||||
implements $OutletLoaderStateCopyWith<$Res> {
|
||||
_$OutletLoaderStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of OutletLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$InitialImplCopyWith<$Res> {
|
||||
factory _$$InitialImplCopyWith(
|
||||
_$InitialImpl value, $Res Function(_$InitialImpl) then) =
|
||||
__$$InitialImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$InitialImplCopyWithImpl<$Res>
|
||||
extends _$OutletLoaderStateCopyWithImpl<$Res, _$InitialImpl>
|
||||
implements _$$InitialImplCopyWith<$Res> {
|
||||
__$$InitialImplCopyWithImpl(
|
||||
_$InitialImpl _value, $Res Function(_$InitialImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of OutletLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$InitialImpl implements _Initial {
|
||||
const _$InitialImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OutletLoaderState.initial()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$InitialImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<Outlet> outlets) loaded,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return initial();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<Outlet> outlets)? loaded,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return initial?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<Outlet> outlets)? loaded,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (initial != null) {
|
||||
return initial();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Loaded value) loaded,
|
||||
required TResult Function(_Error value) error,
|
||||
}) {
|
||||
return initial(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Loaded value)? loaded,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) {
|
||||
return initial?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Loaded value)? loaded,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (initial != null) {
|
||||
return initial(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Initial implements OutletLoaderState {
|
||||
const factory _Initial() = _$InitialImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$LoadingImplCopyWith<$Res> {
|
||||
factory _$$LoadingImplCopyWith(
|
||||
_$LoadingImpl value, $Res Function(_$LoadingImpl) then) =
|
||||
__$$LoadingImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$LoadingImplCopyWithImpl<$Res>
|
||||
extends _$OutletLoaderStateCopyWithImpl<$Res, _$LoadingImpl>
|
||||
implements _$$LoadingImplCopyWith<$Res> {
|
||||
__$$LoadingImplCopyWithImpl(
|
||||
_$LoadingImpl _value, $Res Function(_$LoadingImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of OutletLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$LoadingImpl implements _Loading {
|
||||
const _$LoadingImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OutletLoaderState.loading()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$LoadingImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<Outlet> outlets) loaded,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return loading();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<Outlet> outlets)? loaded,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return loading?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<Outlet> outlets)? loaded,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Loaded value) loaded,
|
||||
required TResult Function(_Error value) error,
|
||||
}) {
|
||||
return loading(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Loaded value)? loaded,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) {
|
||||
return loading?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Loaded value)? loaded,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Loading implements OutletLoaderState {
|
||||
const factory _Loading() = _$LoadingImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$LoadedImplCopyWith<$Res> {
|
||||
factory _$$LoadedImplCopyWith(
|
||||
_$LoadedImpl value, $Res Function(_$LoadedImpl) then) =
|
||||
__$$LoadedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({List<Outlet> outlets});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$LoadedImplCopyWithImpl<$Res>
|
||||
extends _$OutletLoaderStateCopyWithImpl<$Res, _$LoadedImpl>
|
||||
implements _$$LoadedImplCopyWith<$Res> {
|
||||
__$$LoadedImplCopyWithImpl(
|
||||
_$LoadedImpl _value, $Res Function(_$LoadedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of OutletLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? outlets = null,
|
||||
}) {
|
||||
return _then(_$LoadedImpl(
|
||||
null == outlets
|
||||
? _value._outlets
|
||||
: outlets // ignore: cast_nullable_to_non_nullable
|
||||
as List<Outlet>,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$LoadedImpl implements _Loaded {
|
||||
const _$LoadedImpl(final List<Outlet> outlets) : _outlets = outlets;
|
||||
|
||||
final List<Outlet> _outlets;
|
||||
@override
|
||||
List<Outlet> get outlets {
|
||||
if (_outlets is EqualUnmodifiableListView) return _outlets;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_outlets);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OutletLoaderState.loaded(outlets: $outlets)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$LoadedImpl &&
|
||||
const DeepCollectionEquality().equals(other._outlets, _outlets));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, const DeepCollectionEquality().hash(_outlets));
|
||||
|
||||
/// Create a copy of OutletLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$LoadedImplCopyWith<_$LoadedImpl> get copyWith =>
|
||||
__$$LoadedImplCopyWithImpl<_$LoadedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<Outlet> outlets) loaded,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return loaded(outlets);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<Outlet> outlets)? loaded,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return loaded?.call(outlets);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<Outlet> outlets)? loaded,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(outlets);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Loaded value) loaded,
|
||||
required TResult Function(_Error value) error,
|
||||
}) {
|
||||
return loaded(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Loaded value)? loaded,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) {
|
||||
return loaded?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Loaded value)? loaded,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Loaded implements OutletLoaderState {
|
||||
const factory _Loaded(final List<Outlet> outlets) = _$LoadedImpl;
|
||||
|
||||
List<Outlet> get outlets;
|
||||
|
||||
/// Create a copy of OutletLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$LoadedImplCopyWith<_$LoadedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ErrorImplCopyWith<$Res> {
|
||||
factory _$$ErrorImplCopyWith(
|
||||
_$ErrorImpl value, $Res Function(_$ErrorImpl) then) =
|
||||
__$$ErrorImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String message});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ErrorImplCopyWithImpl<$Res>
|
||||
extends _$OutletLoaderStateCopyWithImpl<$Res, _$ErrorImpl>
|
||||
implements _$$ErrorImplCopyWith<$Res> {
|
||||
__$$ErrorImplCopyWithImpl(
|
||||
_$ErrorImpl _value, $Res Function(_$ErrorImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of OutletLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? message = null,
|
||||
}) {
|
||||
return _then(_$ErrorImpl(
|
||||
null == message
|
||||
? _value.message
|
||||
: message // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ErrorImpl implements _Error {
|
||||
const _$ErrorImpl(this.message);
|
||||
|
||||
@override
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OutletLoaderState.error(message: $message)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ErrorImpl &&
|
||||
(identical(other.message, message) || other.message == message));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, message);
|
||||
|
||||
/// Create a copy of OutletLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ErrorImplCopyWith<_$ErrorImpl> get copyWith =>
|
||||
__$$ErrorImplCopyWithImpl<_$ErrorImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<Outlet> outlets) loaded,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return error(message);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<Outlet> outlets)? loaded,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return error?.call(message);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<Outlet> outlets)? loaded,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(message);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Loaded value) loaded,
|
||||
required TResult Function(_Error value) error,
|
||||
}) {
|
||||
return error(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Loaded value)? loaded,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) {
|
||||
return error?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Loaded value)? loaded,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Error implements OutletLoaderState {
|
||||
const factory _Error(final String message) = _$ErrorImpl;
|
||||
|
||||
String get message;
|
||||
|
||||
/// Create a copy of OutletLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ErrorImplCopyWith<_$ErrorImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
part of 'outlet_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class OutletLoaderEvent with _$OutletLoaderEvent {
|
||||
const factory OutletLoaderEvent.getOutlet() = _GetOutlet;
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
part of 'outlet_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class OutletLoaderState with _$OutletLoaderState {
|
||||
const factory OutletLoaderState.initial() = _Initial;
|
||||
const factory OutletLoaderState.loading() = _Loading;
|
||||
const factory OutletLoaderState.loaded(List<Outlet> outlets) = _Loaded;
|
||||
const factory OutletLoaderState.error(String message) = _Error;
|
||||
}
|
||||
40
lib/presentation/home/dialog/outlet_dialog.dart
Normal file
40
lib/presentation/home/dialog/outlet_dialog.dart
Normal file
@ -0,0 +1,40 @@
|
||||
import 'package:enaklo_pos/core/components/custom_modal_dialog.dart';
|
||||
import 'package:enaklo_pos/presentation/home/bloc/outlet_loader/outlet_loader_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/home/widgets/outlet_card.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class OutletDialog extends StatelessWidget {
|
||||
const OutletDialog({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomModalDialog(
|
||||
title: 'Outlet',
|
||||
subtitle: 'Silahkan pilih outlet',
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 24.0),
|
||||
child: BlocBuilder<OutletLoaderBloc, OutletLoaderState>(
|
||||
builder: (context, state) {
|
||||
return state.maybeWhen(
|
||||
orElse: () => Center(
|
||||
child: Text('Error has occured'),
|
||||
),
|
||||
loading: () => Center(child: CircularProgressIndicator()),
|
||||
error: (message) => Center(
|
||||
child: Text(message),
|
||||
),
|
||||
loaded: (outlets) => Column(
|
||||
children: List.generate(
|
||||
outlets.length,
|
||||
(index) => OutletCard(
|
||||
outlet: outlets[index],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -5,11 +5,23 @@ import 'package:enaklo_pos/core/constants/colors.dart';
|
||||
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||
import 'package:enaklo_pos/data/models/response/table_model.dart';
|
||||
import 'package:enaklo_pos/presentation/home/bloc/get_table_status/get_table_status_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/home/bloc/order_form/order_form_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/order_type.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class PaymentSaveDialog extends StatefulWidget {
|
||||
const PaymentSaveDialog({super.key});
|
||||
final TableModel? selectedTable;
|
||||
final String customerName;
|
||||
final OrderType orderType;
|
||||
final List<ProductQuantity> items;
|
||||
const PaymentSaveDialog(
|
||||
{super.key,
|
||||
required this.selectedTable,
|
||||
required this.customerName,
|
||||
required this.orderType,
|
||||
required this.items});
|
||||
|
||||
@override
|
||||
State<PaymentSaveDialog> createState() => _PaymentSaveDialogState();
|
||||
@ -17,6 +29,15 @@ class PaymentSaveDialog extends StatefulWidget {
|
||||
|
||||
class _PaymentSaveDialogState extends State<PaymentSaveDialog> {
|
||||
TableModel? selectTable;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.selectedTable != null) {
|
||||
selectTable = widget.selectedTable;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomModalDialog(
|
||||
@ -112,7 +133,16 @@ class _PaymentSaveDialogState extends State<PaymentSaveDialog> {
|
||||
),
|
||||
SpaceHeight(24),
|
||||
Button.filled(
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
context.read<OrderFormBloc>().add(
|
||||
OrderFormEvent.create(
|
||||
items: widget.items,
|
||||
customerName: widget.customerName,
|
||||
orderType: widget.orderType,
|
||||
tableNumber: selectTable!.tableName.toString(),
|
||||
),
|
||||
);
|
||||
},
|
||||
label: "Simpan",
|
||||
),
|
||||
],
|
||||
|
||||
@ -1,12 +1,25 @@
|
||||
import 'package:enaklo_pos/core/components/custom_modal_dialog.dart';
|
||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||
import 'package:enaklo_pos/data/models/response/table_model.dart';
|
||||
import 'package:enaklo_pos/presentation/home/dialog/payment_add_order_dialog.dart';
|
||||
import 'package:enaklo_pos/presentation/home/dialog/payment_save_dialog.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/order_type.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SaveDialog extends StatelessWidget {
|
||||
const SaveDialog({super.key});
|
||||
final TableModel? selectedTable;
|
||||
final String customerName;
|
||||
final OrderType orderType;
|
||||
final List<ProductQuantity> items;
|
||||
|
||||
const SaveDialog(
|
||||
{super.key,
|
||||
required this.selectedTable,
|
||||
required this.customerName,
|
||||
required this.orderType,
|
||||
required this.items});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -23,7 +36,11 @@ class SaveDialog extends StatelessWidget {
|
||||
subtitle: 'Simpan pesanan dan bayar nanti',
|
||||
onTap: () => showDialog(
|
||||
context: context,
|
||||
builder: (context) => const PaymentSaveDialog(),
|
||||
builder: (context) => PaymentSaveDialog(
|
||||
selectedTable: selectedTable,
|
||||
customerName: customerName,
|
||||
orderType: orderType,
|
||||
items: items),
|
||||
),
|
||||
),
|
||||
SpaceHeight(16.0),
|
||||
|
||||
84
lib/presentation/home/models/order_request.dart
Normal file
84
lib/presentation/home/models/order_request.dart
Normal file
@ -0,0 +1,84 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class OrderRequestModel {
|
||||
final String? outletId;
|
||||
final String? userId;
|
||||
final String? tableNumber;
|
||||
final String? orderType;
|
||||
final String? notes;
|
||||
final List<OrderItemRequest>? orderItems;
|
||||
final String? customerName;
|
||||
|
||||
OrderRequestModel({
|
||||
this.outletId,
|
||||
this.userId,
|
||||
this.tableNumber,
|
||||
this.orderType,
|
||||
this.notes,
|
||||
this.orderItems,
|
||||
this.customerName,
|
||||
});
|
||||
|
||||
factory OrderRequestModel.fromJson(String str) =>
|
||||
OrderRequestModel.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory OrderRequestModel.fromMap(Map<String, dynamic> json) =>
|
||||
OrderRequestModel(
|
||||
outletId: json["outlet_id"],
|
||||
userId: json["user_id"],
|
||||
tableNumber: json["table_number"],
|
||||
orderType: json["order_type"],
|
||||
notes: json["notes"],
|
||||
orderItems: json["order_items"] == null
|
||||
? []
|
||||
: List<OrderItemRequest>.from(
|
||||
json["order_items"].map((x) => OrderItemRequest.fromMap(x))),
|
||||
customerName: json["customer_name"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"outlet_id": outletId,
|
||||
"user_id": userId,
|
||||
"table_number": tableNumber,
|
||||
"order_type": orderType,
|
||||
"notes": notes,
|
||||
"order_items": orderItems == null
|
||||
? []
|
||||
: List<dynamic>.from(orderItems!.map((x) => x.toMap())),
|
||||
"customer_name": customerName,
|
||||
};
|
||||
}
|
||||
|
||||
class OrderItemRequest {
|
||||
final String? productId;
|
||||
final int? quantity;
|
||||
final int? unitPrice;
|
||||
final String? notes;
|
||||
|
||||
OrderItemRequest({
|
||||
this.productId,
|
||||
this.quantity,
|
||||
this.unitPrice,
|
||||
this.notes,
|
||||
});
|
||||
|
||||
factory OrderItemRequest.fromJson(String str) =>
|
||||
OrderItemRequest.fromMap(json.decode(str));
|
||||
|
||||
factory OrderItemRequest.fromMap(Map<String, dynamic> json) =>
|
||||
OrderItemRequest(
|
||||
productId: json["product_id"],
|
||||
quantity: json["quantity"],
|
||||
unitPrice: json["unit_price"]?.toDouble(),
|
||||
notes: json["notes"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"product_id": productId,
|
||||
"quantity": quantity,
|
||||
"unit_price": unitPrice,
|
||||
"notes": notes,
|
||||
};
|
||||
}
|
||||
130
lib/presentation/home/models/outlet_model.dart
Normal file
130
lib/presentation/home/models/outlet_model.dart
Normal file
@ -0,0 +1,130 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class OutletResponse {
|
||||
final bool? success;
|
||||
final OutletData? data;
|
||||
final dynamic errors;
|
||||
|
||||
OutletResponse({
|
||||
this.success,
|
||||
this.data,
|
||||
this.errors,
|
||||
});
|
||||
|
||||
factory OutletResponse.fromJson(String str) =>
|
||||
OutletResponse.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory OutletResponse.fromMap(Map<String, dynamic> json) => OutletResponse(
|
||||
success: json["success"],
|
||||
data: json["data"] == null ? null : OutletData.fromMap(json["data"]),
|
||||
errors: json["errors"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"success": success,
|
||||
"data": data?.toMap(),
|
||||
"errors": errors,
|
||||
};
|
||||
}
|
||||
|
||||
class OutletData {
|
||||
final List<Outlet>? outlets;
|
||||
final int? totalCount;
|
||||
final int? page;
|
||||
final int? limit;
|
||||
final int? totalPages;
|
||||
|
||||
OutletData({
|
||||
this.outlets,
|
||||
this.totalCount,
|
||||
this.page,
|
||||
this.limit,
|
||||
this.totalPages,
|
||||
});
|
||||
|
||||
factory OutletData.fromMap(Map<String, dynamic> json) => OutletData(
|
||||
outlets: json["outlets"] == null
|
||||
? []
|
||||
: List<Outlet>.from(json["outlets"].map((x) => Outlet.fromMap(x))),
|
||||
totalCount: json["total_count"],
|
||||
page: json["page"],
|
||||
limit: json["limit"],
|
||||
totalPages: json["total_pages"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"outlets": outlets == null
|
||||
? []
|
||||
: List<dynamic>.from(outlets!.map((x) => x.toMap())),
|
||||
"total_count": totalCount,
|
||||
"page": page,
|
||||
"limit": limit,
|
||||
"total_pages": totalPages,
|
||||
};
|
||||
}
|
||||
|
||||
class Outlet {
|
||||
final String? id;
|
||||
final String? organizationId;
|
||||
final String? name;
|
||||
final String? address;
|
||||
final String? phoneNumber;
|
||||
final String? businessType;
|
||||
final String? currency;
|
||||
final int? taxRate;
|
||||
final bool? isActive;
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
Outlet({
|
||||
this.id,
|
||||
this.organizationId,
|
||||
this.name,
|
||||
this.address,
|
||||
this.phoneNumber,
|
||||
this.businessType,
|
||||
this.currency,
|
||||
this.taxRate,
|
||||
this.isActive,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
});
|
||||
|
||||
factory Outlet.fromMap(Map<String, dynamic> json) => Outlet(
|
||||
id: json["id"],
|
||||
organizationId: json["organization_id"],
|
||||
name: json["name"],
|
||||
address: json["address"],
|
||||
phoneNumber: json["phone_number"],
|
||||
businessType: json["business_type"],
|
||||
currency: json["currency"],
|
||||
taxRate: json["tax_rate"],
|
||||
isActive: json["is_active"],
|
||||
createdAt: json["created_at"] == null
|
||||
? null
|
||||
: DateTime.parse(json["created_at"]),
|
||||
updatedAt: json["updated_at"] == null
|
||||
? null
|
||||
: DateTime.parse(json["updated_at"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"id": id,
|
||||
"organization_id": organizationId,
|
||||
"name": name,
|
||||
"address": address,
|
||||
"phone_number": phoneNumber,
|
||||
"business_type": businessType,
|
||||
"currency": currency,
|
||||
"tax_rate": taxRate,
|
||||
"is_active": isActive,
|
||||
"created_at": createdAt?.toIso8601String(),
|
||||
"updated_at": updatedAt?.toIso8601String(),
|
||||
};
|
||||
|
||||
factory Outlet.fromJson(String str) => Outlet.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
}
|
||||
@ -2,7 +2,10 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:enaklo_pos/core/components/dashed_divider.dart';
|
||||
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||
import 'package:enaklo_pos/presentation/home/dialog/save_dialog.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/order_type.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
||||
import 'package:enaklo_pos/presentation/home/widgets/confirm_payment_title.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
@ -116,6 +119,7 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ConfirmPaymentTitle(
|
||||
isBack: false,
|
||||
title: 'Konfirmasi',
|
||||
subtitle: widget.isTable
|
||||
? 'Orders Table ${widget.table?.tableName}'
|
||||
@ -769,48 +773,51 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
const SpaceHeight(20.0),
|
||||
BlocBuilder<CheckoutBloc, CheckoutState>(
|
||||
builder: (context, state) {
|
||||
return Row(
|
||||
children: [
|
||||
Button.outlined(
|
||||
width: 150.0,
|
||||
onPressed: () {
|
||||
totalPriceController.text =
|
||||
uangPas
|
||||
.toString()
|
||||
.currencyFormatRpV2;
|
||||
priceValue = uangPas;
|
||||
},
|
||||
label: 'UANG PAS',
|
||||
),
|
||||
const SpaceWidth(20.0),
|
||||
Button.outlined(
|
||||
width: 150.0,
|
||||
onPressed: () {
|
||||
totalPriceController.text =
|
||||
uangPas2
|
||||
.toString()
|
||||
.currencyFormatRpV2;
|
||||
priceValue = uangPas2;
|
||||
},
|
||||
label: uangPas2
|
||||
.toString()
|
||||
.currencyFormatRpV2,
|
||||
),
|
||||
const SpaceWidth(20.0),
|
||||
Button.outlined(
|
||||
width: 150.0,
|
||||
onPressed: () {
|
||||
totalPriceController.text =
|
||||
uangPas3
|
||||
.toString()
|
||||
.currencyFormatRpV2;
|
||||
priceValue = uangPas3;
|
||||
},
|
||||
label: uangPas3
|
||||
.toString()
|
||||
.currencyFormatRpV2,
|
||||
),
|
||||
],
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
Button.outlined(
|
||||
width: 150.0,
|
||||
onPressed: () {
|
||||
totalPriceController.text =
|
||||
uangPas
|
||||
.toString()
|
||||
.currencyFormatRpV2;
|
||||
priceValue = uangPas;
|
||||
},
|
||||
label: 'UANG PAS',
|
||||
),
|
||||
const SpaceWidth(20.0),
|
||||
Button.outlined(
|
||||
width: 150.0,
|
||||
onPressed: () {
|
||||
totalPriceController.text =
|
||||
uangPas2
|
||||
.toString()
|
||||
.currencyFormatRpV2;
|
||||
priceValue = uangPas2;
|
||||
},
|
||||
label: uangPas2
|
||||
.toString()
|
||||
.currencyFormatRpV2,
|
||||
),
|
||||
const SpaceWidth(20.0),
|
||||
Button.outlined(
|
||||
width: 150.0,
|
||||
onPressed: () {
|
||||
totalPriceController.text =
|
||||
uangPas3
|
||||
.toString()
|
||||
.currencyFormatRpV2;
|
||||
priceValue = uangPas3;
|
||||
},
|
||||
label: uangPas3
|
||||
.toString()
|
||||
.currencyFormatRpV2,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
@ -821,43 +828,83 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.white,
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: AppColors.background,
|
||||
width: 1.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Button.outlined(
|
||||
onPressed: () {},
|
||||
label: 'Batalkan',
|
||||
BlocBuilder<CheckoutBloc, CheckoutState>(
|
||||
builder: (context, state) {
|
||||
final orderType = state.maybeWhen(
|
||||
orElse: () => OrderType.dineIn,
|
||||
loaded: (products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
tax,
|
||||
serviceCharge,
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
);
|
||||
|
||||
List<ProductQuantity> items = state.maybeWhen(
|
||||
orElse: () => [],
|
||||
loaded: (products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
tax,
|
||||
serviceCharge,
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
products,
|
||||
);
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.white,
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: AppColors.background,
|
||||
width: 1.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
SpaceWidth(12),
|
||||
Expanded(
|
||||
child: Button.filled(
|
||||
onPressed: () => showDialog(
|
||||
context: context,
|
||||
builder: (context) => SaveDialog()),
|
||||
label: 'Simpan',
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Button.outlined(
|
||||
onPressed: () => context.pop(),
|
||||
label: 'Batalkan',
|
||||
),
|
||||
),
|
||||
SpaceWidth(12),
|
||||
Expanded(
|
||||
child: Button.filled(
|
||||
onPressed: () => showDialog(
|
||||
context: context,
|
||||
builder: (context) => SaveDialog(
|
||||
selectedTable: widget.table,
|
||||
customerName:
|
||||
customerController.text,
|
||||
items: items,
|
||||
orderType: orderType,
|
||||
)),
|
||||
label: 'Simpan',
|
||||
),
|
||||
),
|
||||
SpaceWidth(12),
|
||||
Expanded(
|
||||
child: Button.filled(
|
||||
onPressed: () {},
|
||||
label: 'Bayar',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SpaceWidth(12),
|
||||
Expanded(
|
||||
child: Button.filled(
|
||||
onPressed: () {},
|
||||
label: 'Bayar',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
import 'package:enaklo_pos/presentation/home/bloc/outlet_loader/outlet_loader_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/home/bloc/product_loader/product_loader_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/home/widgets/home_right_title.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -58,6 +59,9 @@ class _HomePageState extends State<HomePage> {
|
||||
|
||||
// Initialize checkout with tax and service charge settings
|
||||
context.read<CheckoutBloc>().add(const CheckoutEvent.started());
|
||||
|
||||
// Get Outlets
|
||||
context.read<OutletLoaderBloc>().add(const OutletLoaderEvent.getOutlet());
|
||||
}
|
||||
|
||||
void onCategoryTap(int index) {
|
||||
@ -490,7 +494,8 @@ class _HomePageState extends State<HomePage> {
|
||||
elevation: 1,
|
||||
onPressed: () {
|
||||
context.push(ConfirmPaymentPage(
|
||||
isTable: widget.isTable,
|
||||
isTable:
|
||||
widget.table == null ? false : true,
|
||||
table: widget.table,
|
||||
));
|
||||
},
|
||||
|
||||
@ -17,7 +17,7 @@ class HomeRightTitle extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: context.deviceHeight * 0.1,
|
||||
height: context.deviceHeight * 0.15,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.primary,
|
||||
border: Border(
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
||||
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||
import 'package:enaklo_pos/presentation/home/dialog/outlet_dialog.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/components/search_input.dart';
|
||||
@ -25,12 +27,24 @@ class HomeTitle extends StatelessWidget {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
'DEFAULT OUTLET',
|
||||
style: TextStyle(
|
||||
color: AppColors.primary,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
GestureDetector(
|
||||
onTap: () => showDialog(
|
||||
context: context,
|
||||
builder: (context) => OutletDialog(),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Text(
|
||||
'DEFAULT OUTLET',
|
||||
style: TextStyle(
|
||||
color: AppColors.primary,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
SpaceWidth(2),
|
||||
Icon(Icons.keyboard_arrow_down, color: AppColors.primary),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
|
||||
53
lib/presentation/home/widgets/outlet_card.dart
Normal file
53
lib/presentation/home/widgets/outlet_card.dart
Normal file
@ -0,0 +1,53 @@
|
||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/outlet_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class OutletCard extends StatelessWidget {
|
||||
final Outlet outlet;
|
||||
const OutletCard({super.key, required this.outlet});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16.0,
|
||||
vertical: 12.0,
|
||||
),
|
||||
margin: EdgeInsets.only(bottom: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.white,
|
||||
border: Border.all(color: AppColors.primary),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.store, color: AppColors.primary),
|
||||
SpaceWidth(12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
outlet.name ?? "",
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
outlet.address ?? "",
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -67,8 +67,8 @@ class _TableWidgetState extends State<TableWidget> {
|
||||
} else {
|
||||
// Handle occupied table click - load draft order and navigate to payment
|
||||
context.read<CheckoutBloc>().add(
|
||||
CheckoutEvent.loadDraftOrder(data!),
|
||||
);
|
||||
CheckoutEvent.loadDraftOrder(data!),
|
||||
);
|
||||
log("Data Draft Order: ${data!.toMap()}");
|
||||
context.push(PaymentTablePage(
|
||||
table: widget.table,
|
||||
@ -220,7 +220,8 @@ class _TableWidgetState extends State<TableWidget> {
|
||||
builder: (context) => AlertDialog(
|
||||
title: Row(
|
||||
children: [
|
||||
Icon(Icons.warning, color: AppColors.red),
|
||||
Icon(Icons.warning,
|
||||
color: AppColors.red),
|
||||
SizedBox(width: 8),
|
||||
Text('Void Order?'),
|
||||
],
|
||||
@ -229,24 +230,33 @@ class _TableWidgetState extends State<TableWidget> {
|
||||
'Apakah anda yakin ingin membatalkan pesanan untuk meja ${widget.table.tableName}?\n\nPesanan akan dihapus secara permanen.'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text('Tidak',
|
||||
style: TextStyle(color: AppColors.primary)),
|
||||
onPressed: () =>
|
||||
Navigator.pop(context),
|
||||
child: Text('Tidak',
|
||||
style: TextStyle(
|
||||
color: AppColors.primary)),
|
||||
),
|
||||
BlocListener<StatusTableBloc, StatusTableState>(
|
||||
BlocListener<StatusTableBloc,
|
||||
StatusTableState>(
|
||||
listener: (context, state) {
|
||||
state.maybeWhen(
|
||||
orElse: () {},
|
||||
success: () {
|
||||
context
|
||||
.read<GetTableBloc>()
|
||||
.add(const GetTableEvent.getTables());
|
||||
Navigator.pop(context); // Close void dialog
|
||||
Navigator.pop(context); // Close table info dialog
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
.add(const GetTableEvent
|
||||
.getTables());
|
||||
Navigator.pop(
|
||||
context); // Close void dialog
|
||||
Navigator.pop(
|
||||
context); // Close table info dialog
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Pesanan berhasil dibatalkan'),
|
||||
backgroundColor: AppColors.primary,
|
||||
content: Text(
|
||||
'Pesanan berhasil dibatalkan'),
|
||||
backgroundColor:
|
||||
AppColors.primary,
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -260,24 +270,31 @@ class _TableWidgetState extends State<TableWidget> {
|
||||
// Void the order
|
||||
final newTable = TableModel(
|
||||
id: widget.table.id,
|
||||
tableName: widget.table.tableName,
|
||||
tableName:
|
||||
widget.table.tableName,
|
||||
status: 'available',
|
||||
orderId: 0,
|
||||
paymentAmount: 0,
|
||||
startTime: DateTime.now().toIso8601String(),
|
||||
startTime: DateTime.now()
|
||||
.toIso8601String(),
|
||||
position: widget.table.position,
|
||||
);
|
||||
context.read<StatusTableBloc>().add(
|
||||
StatusTableEvent.statusTabel(newTable),
|
||||
context
|
||||
.read<StatusTableBloc>()
|
||||
.add(
|
||||
StatusTableEvent
|
||||
.statusTabel(newTable),
|
||||
);
|
||||
// Remove draft order from local storage
|
||||
ProductLocalDatasource.instance
|
||||
.removeDraftOrderById(widget.table.orderId);
|
||||
.removeDraftOrderById(
|
||||
widget.table.orderId);
|
||||
log("Voided order for table: ${widget.table.tableName}");
|
||||
},
|
||||
child: const Text(
|
||||
"Ya, Batalkan",
|
||||
style: TextStyle(color: Colors.white),
|
||||
style: TextStyle(
|
||||
color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -292,14 +309,14 @@ class _TableWidgetState extends State<TableWidget> {
|
||||
),
|
||||
SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: BlocConsumer<StatusTableBloc, StatusTableState>(
|
||||
child: BlocConsumer<StatusTableBloc,
|
||||
StatusTableState>(
|
||||
listener: (context, state) {
|
||||
state.maybeWhen(
|
||||
orElse: () {},
|
||||
success: () {
|
||||
context
|
||||
.read<GetTableBloc>()
|
||||
.add(const GetTableEvent.getTables());
|
||||
context.read<GetTableBloc>().add(
|
||||
const GetTableEvent.getTables());
|
||||
context.pop();
|
||||
});
|
||||
},
|
||||
@ -308,7 +325,8 @@ class _TableWidgetState extends State<TableWidget> {
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
context.read<CheckoutBloc>().add(
|
||||
CheckoutEvent.loadDraftOrder(data!),
|
||||
CheckoutEvent.loadDraftOrder(
|
||||
data!),
|
||||
);
|
||||
context.push(PaymentTablePage(
|
||||
table: widget.table,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user