dev #1
48
lib/core/components/flushbar.dart
Normal file
48
lib/core/components/flushbar.dart
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import 'package:another_flushbar/flushbar.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class AppFlushbar {
|
||||||
|
static void showSuccess(BuildContext context, String message) {
|
||||||
|
Flushbar(
|
||||||
|
messageText: Text(
|
||||||
|
message,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.check_circle,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
duration: const Duration(seconds: 2),
|
||||||
|
flushbarPosition: FlushbarPosition.BOTTOM,
|
||||||
|
backgroundColor: Colors.green,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
margin: const EdgeInsets.all(12),
|
||||||
|
).show(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void showError(BuildContext context, String message) {
|
||||||
|
Flushbar(
|
||||||
|
messageText: Text(
|
||||||
|
message,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.error,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
duration: const Duration(seconds: 3),
|
||||||
|
flushbarPosition: FlushbarPosition.BOTTOM,
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
margin: const EdgeInsets.all(12),
|
||||||
|
).show(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -191,7 +191,8 @@ class OrderRemoteDatasource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// New Api
|
// New Api
|
||||||
Future<Either<String, bool>> createOrder(OrderRequestModel orderModel) async {
|
Future<Either<String, OrderDetailResponseModel>> createOrder(
|
||||||
|
OrderRequestModel orderModel) async {
|
||||||
final authData = await AuthLocalDataSource().getAuthData();
|
final authData = await AuthLocalDataSource().getAuthData();
|
||||||
final url = '${Variables.baseUrl}/api/v1/orders';
|
final url = '${Variables.baseUrl}/api/v1/orders';
|
||||||
|
|
||||||
@ -209,7 +210,7 @@ class OrderRemoteDatasource {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
return const Right(true);
|
return Right(OrderDetailResponseModel.fromMap(response.data));
|
||||||
} else {
|
} else {
|
||||||
return const Left('Gagal membuat pesanan');
|
return const Left('Gagal membuat pesanan');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,36 @@ class OrderResponseModel {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class OrderDetailResponseModel {
|
||||||
|
final bool? success;
|
||||||
|
final Order? data;
|
||||||
|
final dynamic errors;
|
||||||
|
|
||||||
|
OrderDetailResponseModel({
|
||||||
|
this.success,
|
||||||
|
this.data,
|
||||||
|
this.errors,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory OrderDetailResponseModel.fromJson(String str) =>
|
||||||
|
OrderDetailResponseModel.fromMap(json.decode(str));
|
||||||
|
|
||||||
|
String toJson() => json.encode(toMap());
|
||||||
|
|
||||||
|
factory OrderDetailResponseModel.fromMap(Map<String, dynamic> json) =>
|
||||||
|
OrderDetailResponseModel(
|
||||||
|
success: json["success"],
|
||||||
|
data: json["data"] == null ? null : Order.fromMap(json["data"]),
|
||||||
|
errors: json["errors"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() => {
|
||||||
|
"success": success,
|
||||||
|
"data": data?.toMap(),
|
||||||
|
"errors": errors,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
class OrderData {
|
class OrderData {
|
||||||
final List<Order>? orders;
|
final List<Order>? orders;
|
||||||
final int? totalCount;
|
final int? totalCount;
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import 'dart:developer';
|
|||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:enaklo_pos/data/datasources/auth_local_datasource.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/data/datasources/order_remote_datasource.dart';
|
||||||
|
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/models/order_request.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/order_type.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
||||||
@ -47,7 +48,7 @@ class OrderFormBloc extends Bloc<OrderFormEvent, OrderFormState> {
|
|||||||
|
|
||||||
result.fold(
|
result.fold(
|
||||||
(error) => emit(_Error(error)),
|
(error) => emit(_Error(error)),
|
||||||
(success) => emit(const _Success()),
|
(success) => emit(_Success(success.data!)),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log("Error in AddOrderItemsBloc: $e");
|
log("Error in AddOrderItemsBloc: $e");
|
||||||
|
|||||||
@ -327,7 +327,7 @@ mixin _$OrderFormState {
|
|||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function() success,
|
required TResult Function(Order order) success,
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@ -335,7 +335,7 @@ mixin _$OrderFormState {
|
|||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function()? success,
|
TResult? Function(Order order)? success,
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@ -343,7 +343,7 @@ mixin _$OrderFormState {
|
|||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function()? success,
|
TResult Function(Order order)? success,
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) =>
|
}) =>
|
||||||
@ -439,7 +439,7 @@ class _$InitialImpl implements _Initial {
|
|||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function() success,
|
required TResult Function(Order order) success,
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
}) {
|
}) {
|
||||||
return initial();
|
return initial();
|
||||||
@ -450,7 +450,7 @@ class _$InitialImpl implements _Initial {
|
|||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function()? success,
|
TResult? Function(Order order)? success,
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
}) {
|
}) {
|
||||||
return initial?.call();
|
return initial?.call();
|
||||||
@ -461,7 +461,7 @@ class _$InitialImpl implements _Initial {
|
|||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function()? success,
|
TResult Function(Order order)? success,
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
@ -556,7 +556,7 @@ class _$LoadingImpl implements _Loading {
|
|||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function() success,
|
required TResult Function(Order order) success,
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
}) {
|
}) {
|
||||||
return loading();
|
return loading();
|
||||||
@ -567,7 +567,7 @@ class _$LoadingImpl implements _Loading {
|
|||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function()? success,
|
TResult? Function(Order order)? success,
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
}) {
|
}) {
|
||||||
return loading?.call();
|
return loading?.call();
|
||||||
@ -578,7 +578,7 @@ class _$LoadingImpl implements _Loading {
|
|||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function()? success,
|
TResult Function(Order order)? success,
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
@ -635,6 +635,8 @@ abstract class _$$SuccessImplCopyWith<$Res> {
|
|||||||
factory _$$SuccessImplCopyWith(
|
factory _$$SuccessImplCopyWith(
|
||||||
_$SuccessImpl value, $Res Function(_$SuccessImpl) then) =
|
_$SuccessImpl value, $Res Function(_$SuccessImpl) then) =
|
||||||
__$$SuccessImplCopyWithImpl<$Res>;
|
__$$SuccessImplCopyWithImpl<$Res>;
|
||||||
|
@useResult
|
||||||
|
$Res call({Order order});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -647,36 +649,61 @@ class __$$SuccessImplCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of OrderFormState
|
/// Create a copy of OrderFormState
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? order = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$SuccessImpl(
|
||||||
|
null == order
|
||||||
|
? _value.order
|
||||||
|
: order // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Order,
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
|
|
||||||
class _$SuccessImpl implements _Success {
|
class _$SuccessImpl implements _Success {
|
||||||
const _$SuccessImpl();
|
const _$SuccessImpl(this.order);
|
||||||
|
|
||||||
|
@override
|
||||||
|
final Order order;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OrderFormState.success()';
|
return 'OrderFormState.success(order: $order)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) ||
|
return identical(this, other) ||
|
||||||
(other.runtimeType == runtimeType && other is _$SuccessImpl);
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$SuccessImpl &&
|
||||||
|
(identical(other.order, order) || other.order == order));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => runtimeType.hashCode;
|
int get hashCode => Object.hash(runtimeType, order);
|
||||||
|
|
||||||
|
/// 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')
|
||||||
|
_$$SuccessImplCopyWith<_$SuccessImpl> get copyWith =>
|
||||||
|
__$$SuccessImplCopyWithImpl<_$SuccessImpl>(this, _$identity);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function() success,
|
required TResult Function(Order order) success,
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
}) {
|
}) {
|
||||||
return success();
|
return success(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -684,10 +711,10 @@ class _$SuccessImpl implements _Success {
|
|||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function()? success,
|
TResult? Function(Order order)? success,
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
}) {
|
}) {
|
||||||
return success?.call();
|
return success?.call(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -695,12 +722,12 @@ class _$SuccessImpl implements _Success {
|
|||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function()? success,
|
TResult Function(Order order)? success,
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (success != null) {
|
if (success != null) {
|
||||||
return success();
|
return success(order);
|
||||||
}
|
}
|
||||||
return orElse();
|
return orElse();
|
||||||
}
|
}
|
||||||
@ -744,7 +771,15 @@ class _$SuccessImpl implements _Success {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract class _Success implements OrderFormState {
|
abstract class _Success implements OrderFormState {
|
||||||
const factory _Success() = _$SuccessImpl;
|
const factory _Success(final Order order) = _$SuccessImpl;
|
||||||
|
|
||||||
|
Order get order;
|
||||||
|
|
||||||
|
/// Create a copy of OrderFormState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
_$$SuccessImplCopyWith<_$SuccessImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -817,7 +852,7 @@ class _$ErrorImpl implements _Error {
|
|||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function() success,
|
required TResult Function(Order order) success,
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
}) {
|
}) {
|
||||||
return error(message);
|
return error(message);
|
||||||
@ -828,7 +863,7 @@ class _$ErrorImpl implements _Error {
|
|||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function()? success,
|
TResult? Function(Order order)? success,
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
}) {
|
}) {
|
||||||
return error?.call(message);
|
return error?.call(message);
|
||||||
@ -839,7 +874,7 @@ class _$ErrorImpl implements _Error {
|
|||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function()? success,
|
TResult Function(Order order)? success,
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
|
|||||||
@ -4,6 +4,6 @@ part of 'order_form_bloc.dart';
|
|||||||
class OrderFormState with _$OrderFormState {
|
class OrderFormState with _$OrderFormState {
|
||||||
const factory OrderFormState.initial() = _Initial;
|
const factory OrderFormState.initial() = _Initial;
|
||||||
const factory OrderFormState.loading() = _Loading;
|
const factory OrderFormState.loading() = _Loading;
|
||||||
const factory OrderFormState.success() = _Success;
|
const factory OrderFormState.success(Order order) = _Success;
|
||||||
const factory OrderFormState.error(String message) = _Error;
|
const factory OrderFormState.error(String message) = _Error;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import 'package:enaklo_pos/core/components/buttons.dart';
|
import 'package:enaklo_pos/core/components/buttons.dart';
|
||||||
import 'package:enaklo_pos/core/components/custom_modal_dialog.dart';
|
import 'package:enaklo_pos/core/components/custom_modal_dialog.dart';
|
||||||
|
import 'package:enaklo_pos/core/components/flushbar.dart';
|
||||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
import 'package:enaklo_pos/core/components/spaces.dart';
|
||||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||||
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||||
@ -8,6 +9,7 @@ import 'package:enaklo_pos/presentation/home/bloc/get_table_status/get_table_sta
|
|||||||
import 'package:enaklo_pos/presentation/home/bloc/order_form/order_form_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/order_type.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/success/pages/success_save_order_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
@ -67,10 +69,6 @@ class _PaymentSaveDialogState extends State<PaymentSaveDialog> {
|
|||||||
return state.maybeWhen(
|
return state.maybeWhen(
|
||||||
orElse: () => const CircularProgressIndicator(),
|
orElse: () => const CircularProgressIndicator(),
|
||||||
success: (tables) {
|
success: (tables) {
|
||||||
print("🔘 Tables fetched: ${tables.length} tables");
|
|
||||||
print(
|
|
||||||
"🔘 Table statuses: ${tables.map((t) => '${t.tableName}: ${t.status}').join(', ')}");
|
|
||||||
// No need to filter since we're fetching the correct tables directly
|
|
||||||
final availableTables = tables;
|
final availableTables = tables;
|
||||||
|
|
||||||
if (selectTable == null && availableTables.isNotEmpty) {
|
if (selectTable == null && availableTables.isNotEmpty) {
|
||||||
@ -132,7 +130,22 @@ class _PaymentSaveDialogState extends State<PaymentSaveDialog> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
SpaceHeight(24),
|
SpaceHeight(24),
|
||||||
Button.filled(
|
BlocListener<OrderFormBloc, OrderFormState>(
|
||||||
|
listener: (context, state) {
|
||||||
|
state.maybeWhen(
|
||||||
|
orElse: () {},
|
||||||
|
success: (data) {
|
||||||
|
context.pushReplacement(SuccessSaveOrderPage(
|
||||||
|
order: data,
|
||||||
|
));
|
||||||
|
},
|
||||||
|
error: (message) => AppFlushbar.showError(context, message),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: BlocBuilder<OrderFormBloc, OrderFormState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
return state.maybeWhen(
|
||||||
|
orElse: () => Button.filled(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.read<OrderFormBloc>().add(
|
context.read<OrderFormBloc>().add(
|
||||||
OrderFormEvent.create(
|
OrderFormEvent.create(
|
||||||
@ -145,6 +158,13 @@ class _PaymentSaveDialogState extends State<PaymentSaveDialog> {
|
|||||||
},
|
},
|
||||||
label: "Simpan",
|
label: "Simpan",
|
||||||
),
|
),
|
||||||
|
loading: () => Center(
|
||||||
|
child: const CircularProgressIndicator(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import 'package:enaklo_pos/core/components/custom_modal_dialog.dart';
|
import 'package:enaklo_pos/core/components/custom_modal_dialog.dart';
|
||||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
import 'package:enaklo_pos/core/components/spaces.dart';
|
||||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
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/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_add_order_dialog.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/dialog/payment_save_dialog.dart';
|
import 'package:enaklo_pos/presentation/home/dialog/payment_save_dialog.dart';
|
||||||
@ -8,7 +9,7 @@ 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/models/product_quantity.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class SaveDialog extends StatelessWidget {
|
class SaveDialog extends StatefulWidget {
|
||||||
final TableModel? selectedTable;
|
final TableModel? selectedTable;
|
||||||
final String customerName;
|
final String customerName;
|
||||||
final OrderType orderType;
|
final OrderType orderType;
|
||||||
@ -21,6 +22,11 @@ class SaveDialog extends StatelessWidget {
|
|||||||
required this.orderType,
|
required this.orderType,
|
||||||
required this.items});
|
required this.items});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SaveDialog> createState() => _SaveDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SaveDialogState extends State<SaveDialog> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return CustomModalDialog(
|
return CustomModalDialog(
|
||||||
@ -34,15 +40,17 @@ class SaveDialog extends StatelessWidget {
|
|||||||
icon: Icons.schedule_outlined,
|
icon: Icons.schedule_outlined,
|
||||||
title: 'Bayar Nanti',
|
title: 'Bayar Nanti',
|
||||||
subtitle: 'Simpan pesanan dan bayar nanti',
|
subtitle: 'Simpan pesanan dan bayar nanti',
|
||||||
onTap: () => showDialog(
|
onTap: () {
|
||||||
|
context.pop();
|
||||||
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => PaymentSaveDialog(
|
builder: (context) => PaymentSaveDialog(
|
||||||
selectedTable: selectedTable,
|
selectedTable: widget.selectedTable,
|
||||||
customerName: customerName,
|
customerName: widget.customerName,
|
||||||
orderType: orderType,
|
orderType: widget.orderType,
|
||||||
items: items),
|
items: widget.items),
|
||||||
),
|
);
|
||||||
),
|
}),
|
||||||
SpaceHeight(16.0),
|
SpaceHeight(16.0),
|
||||||
_item(
|
_item(
|
||||||
icon: Icons.shopping_cart_checkout_outlined,
|
icon: Icons.shopping_cart_checkout_outlined,
|
||||||
|
|||||||
@ -884,13 +884,13 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
|||||||
child: Button.filled(
|
child: Button.filled(
|
||||||
onPressed: () => showDialog(
|
onPressed: () => showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => SaveDialog(
|
builder: (dcontext) => SaveDialog(
|
||||||
selectedTable: widget.table,
|
selectedTable: widget.table,
|
||||||
customerName:
|
customerName: customerController.text,
|
||||||
customerController.text,
|
|
||||||
items: items,
|
items: items,
|
||||||
orderType: orderType,
|
orderType: orderType,
|
||||||
)),
|
),
|
||||||
|
),
|
||||||
label: 'Simpan',
|
label: 'Simpan',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||||
import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/bloc/outlet_loader/outlet_loader_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:enaklo_pos/presentation/home/bloc/product_loader/product_loader_bloc.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/widgets/home_right_title.dart';
|
import 'package:enaklo_pos/presentation/home/widgets/home_right_title.dart';
|
||||||
|
|||||||
182
lib/presentation/success/pages/success_save_order_page.dart
Normal file
182
lib/presentation/success/pages/success_save_order_page.dart
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
import 'package:enaklo_pos/core/components/components.dart';
|
||||||
|
import 'package:enaklo_pos/core/components/dashed_divider.dart';
|
||||||
|
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||||
|
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||||
|
import 'package:enaklo_pos/core/extensions/date_time_ext.dart';
|
||||||
|
import 'package:enaklo_pos/core/extensions/string_ext.dart';
|
||||||
|
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/home/pages/dashboard_page.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class SuccessSaveOrderPage extends StatelessWidget {
|
||||||
|
final Order order;
|
||||||
|
const SuccessSaveOrderPage({super.key, required this.order});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppColors.background,
|
||||||
|
body: Center(
|
||||||
|
child: Container(
|
||||||
|
width: context.deviceWidth * 0.4,
|
||||||
|
height: context.deviceHeight * 0.8,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.white,
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(12.0)),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Pesanan!',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
Text('Pesanan Berhasil disimpan',
|
||||||
|
style: const TextStyle(fontSize: 14)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
DashedDivider(
|
||||||
|
color: AppColors.grey,
|
||||||
|
),
|
||||||
|
SpaceHeight(24),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
|
child: Text(
|
||||||
|
order.metadata?['customer_name'] ?? "-",
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 24,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: AppColors.primary,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0).copyWith(top: 24),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'No. Pesanan',
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
order.orderNumber ?? "-",
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SpaceHeight(4),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'No. Meja',
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
order.tableNumber ?? "-",
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SpaceHeight(4),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Waktu',
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
(order.createdAt ?? DateTime.now())
|
||||||
|
.toFormattedDate3(),
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Spacer(),
|
||||||
|
DashedDivider(
|
||||||
|
color: AppColors.grey,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Status Pembayaran',
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Belum Bayar',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold, color: Colors.red),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
DashedDivider(
|
||||||
|
color: AppColors.grey,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Total Pembayaran',
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
(order.totalAmount ?? 0).toString().currencyFormatRpV2,
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
DashedDivider(
|
||||||
|
color: AppColors.grey,
|
||||||
|
),
|
||||||
|
Spacer(),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Button.outlined(
|
||||||
|
onPressed: () =>
|
||||||
|
context.pushReplacement(DashboardPage()),
|
||||||
|
label: 'Kembali',
|
||||||
|
height: 44,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SpaceWidth(12),
|
||||||
|
Expanded(
|
||||||
|
child: Button.filled(
|
||||||
|
onPressed: () {},
|
||||||
|
label: 'Cetak',
|
||||||
|
icon: Icon(
|
||||||
|
Icons.print,
|
||||||
|
color: AppColors.white,
|
||||||
|
),
|
||||||
|
height: 44,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -22,6 +22,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.11.0"
|
version: "6.11.0"
|
||||||
|
another_flushbar:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: another_flushbar
|
||||||
|
sha256: "19bf9520230ec40b300aaf9dd2a8fefcb277b25ecd1c4838f530566965befc2a"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.12.30"
|
||||||
archive:
|
archive:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -61,6 +61,7 @@ dependencies:
|
|||||||
flutter_screenutil: ^5.9.3
|
flutter_screenutil: ^5.9.3
|
||||||
dio: ^5.8.0+1
|
dio: ^5.8.0+1
|
||||||
awesome_dio_interceptor: ^1.3.0
|
awesome_dio_interceptor: ^1.3.0
|
||||||
|
another_flushbar: ^1.12.30
|
||||||
# imin_printer: ^0.6.10
|
# imin_printer: ^0.6.10
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user