Commit 375f32da authored by Jasa Digital's avatar Jasa Digital

19/10/22

parent 300ca720
......@@ -75,18 +75,23 @@ class Api {
jsonDecode(element)['url_type'] != typeUrlSatu,
);
var uuidOrderId = uuidInit.v4();
String orderID;
if (getIsNewOrder() == false) {
if (indexTypeUrl != -1) {
currentOrderId = jsonDecode(listTypeUrl[indexTypeUrl])['order_id'];
} else {
currentOrderId = getOrderId();
}
var uuidOrderId = uuidInit.v4();
String orderID;
if (currentOrderId != '') {
orderID = currentOrderId;
} else {
orderID = uuidOrderId;
}
} else {
orderID = uuidOrderId;
}
try {
Map data = {
"branch_code": branchCode,
......@@ -193,6 +198,7 @@ class Api {
} else {
setIsCustomerDelivery(false);
}
setIsNewOrder(false);
return responseByodBranchExist;
} else if (jsonObject['status'] == 'error' &&
(jsonObject['code'] == 'BYOD_ALWAYS_OFF' ||
......@@ -982,9 +988,6 @@ class Api {
"rdm_staff_courier_mobile":
jsonObject['data']['rdm_staff_courier_mobile'] ?? "",
};
if (jsonObject['data']['delivery_fee'] != "") {
setIsCustomerDelivery(true);
}
bill.add(Bill.createBill(i));
// billDetail.add(BillDetail.createBillDetail(orderDetail[d]));
}
......
import 'package:flutter_bloc/flutter_bloc.dart';
class ChangeDeliveryPickupBloc extends Cubit<bool> {
ChangeDeliveryPickupBloc() : super(false);
ChangeDeliveryPickupBloc() : super(true);
void toDelivery(bool status) {
emit(status);
......
......@@ -354,8 +354,11 @@ iscanTapAddRemoveQtyViewBill(int orderState) {
return false;
}
String textButtonCheckout(int orderState) {
String textButtonCheckout(int orderState, bool isHistory) {
int paymentMethod = getPaymentMode();
if (isHistory) {
return 'Kembali';
} else {
if (paymentMethod == closebill && orderState == orderStateCreated) {
return 'Pesan';
} else if (paymentMethod == closebill &&
......@@ -379,6 +382,7 @@ String textButtonCheckout(int orderState) {
} else {
return 'Bayar';
}
}
}
bool isCanButtonCheckoutToTap(int orderState) {
......
......@@ -43,6 +43,7 @@ const String _addressOutlet = 'addressOutlet';
const String _phoneOutlet = 'phoneOutlet';
const String _serviceRadius = 'sr';
const String _distanceOutletCustomer = 'doc';
const String _isNewOrder = 'ino';
String getBaseUrl() {
return prefs.getString(_baseUrl) ?? '';
......@@ -375,3 +376,11 @@ double getDistance() {
Future<void> setDistance(double value) async {
prefs.setDouble(_distanceOutletCustomer, value);
}
bool getIsNewOrder() {
return prefs.getBool(_isNewOrder) ?? false;
}
Future<void> setIsNewOrder(bool value) async {
prefs.setBool(_isNewOrder, value);
}
......@@ -19,6 +19,7 @@ import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import 'package:sliver_tools/sliver_tools.dart';
import '../../bloc/address_user_bloc.dart';
import '../../bloc/change_delivery_pickup.dart';
import '../../bloc/filter_menu.dart';
import '../../bloc/outlet_detail.dart';
import '../../helper/mq.dart';
......@@ -678,11 +679,16 @@ class _NewHome2State extends State<NewHome2> {
),
),
(getIsDeliveryPickup())
? const SliverToBoxAdapter(
child: ComponentNameUser(
? SliverToBoxAdapter(
child: BlocBuilder<ChangeDeliveryPickupBloc, bool>(
builder: (ctx, isDelivery) {
return ComponentNameUser(
isDeliveryPickuup: true,
backgroundColorComponent: backgroundColor,
isFromMenu: true,
isdelivery: isDelivery,
);
},
),
)
: const SliverToBoxAdapter(
......
......@@ -13,6 +13,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:geolocator/geolocator.dart';
import '../bloc/branch_exist.dart';
import '../bloc/change_delivery_pickup.dart';
import '../bloc/filter_menu.dart';
import '../main.dart';
import 'package:flutter/services.dart' as bundle_root;
......@@ -49,6 +50,8 @@ class _SplashState extends State<Splash> {
}
}
int durationDelayBeforToMenu = 2000;
@override
void initState() {
loadBaseUrl().then((baseUrl) {
......@@ -88,7 +91,7 @@ class _SplashState extends State<Splash> {
widget.context,
getBrancList: true,
);
Future.delayed(const Duration(milliseconds: 2000), () async {
Future.delayed(Duration(milliseconds: durationDelayBeforToMenu), () async {
// if (getStatusOrderCreated()) {
context.read<FilterMenuBloc>().catAndMenu(
getBranchPref(),
......@@ -97,6 +100,9 @@ class _SplashState extends State<Splash> {
getCashierName(),
getOrderId(),
);
context
.read<ChangeDeliveryPickupBloc>()
.toDelivery(getIsCustomerDelivery());
Navigator.pushReplacement(
widget.context,
MaterialPageRoute(
......@@ -160,7 +166,7 @@ class _SplashState extends State<Splash> {
widget.context,
getBrancList: true,
);
Future.delayed(const Duration(milliseconds: 2000), () async {
Future.delayed(Duration(milliseconds: durationDelayBeforToMenu), () async {
// if (getStatusOrderCreated()) {
context.read<FilterMenuBloc>().catAndMenu(
getBranchPref(),
......@@ -169,6 +175,9 @@ class _SplashState extends State<Splash> {
getCashierName(),
getOrderId(),
);
context
.read<ChangeDeliveryPickupBloc>()
.toDelivery(getIsCustomerDelivery());
Navigator.pushReplacement(
widget.context,
MaterialPageRoute(
......@@ -297,7 +306,7 @@ class _SplashState extends State<Splash> {
widget.context,
getMenu: true,
);
Future.delayed(const Duration(milliseconds: 2000), () async {
Future.delayed(Duration(milliseconds: durationDelayBeforToMenu), () async {
// if (getStatusOrderCreated()) {
context.read<FilterMenuBloc>().catAndMenu(
getBranchPref(),
......@@ -408,7 +417,7 @@ class _SplashState extends State<Splash> {
widget.context,
getMenu: true,
);
Future.delayed(const Duration(milliseconds: 2000), () async {
Future.delayed(Duration(milliseconds: durationDelayBeforToMenu), () async {
// if (getStatusOrderCreated()) {
context.read<FilterMenuBloc>().catAndMenu(
getBranchPref(),
......@@ -497,7 +506,7 @@ class _SplashState extends State<Splash> {
widget.context,
getMenu: true,
);
Future.delayed(const Duration(milliseconds: 2000), () async {
Future.delayed(Duration(milliseconds: durationDelayBeforToMenu), () async {
// if (getStatusOrderCreated()) {
context.read<FilterMenuBloc>().catAndMenu(
getBranchPref(),
......@@ -566,7 +575,7 @@ class _SplashState extends State<Splash> {
}
void goToMenu(contexts) {
Future.delayed(const Duration(milliseconds: 2000), () async {
Future.delayed(Duration(milliseconds: durationDelayBeforToMenu), () async {
Navigator.pushReplacement(
contexts,
MaterialPageRoute(
......
......@@ -13,12 +13,14 @@ class ComponentNameUser extends StatelessWidget {
this.dataBill = const [],
required this.backgroundColorComponent,
this.isFromMenu = false,
required this.isdelivery,
}) : super(key: key);
final bool isDeliveryPickuup;
final List<Bill> dataBill;
final Color backgroundColorComponent;
final bool isFromMenu;
final bool isdelivery;
@override
Widget build(BuildContext context) {
......@@ -48,7 +50,7 @@ class ComponentNameUser extends StatelessWidget {
child: defaultText(
context,
(isDeliveryPickuup)
? (getIsCustomerDelivery())
? (isdelivery)
? 'Delivery'
: 'Pickup'
: 'Meja ${dataBill[0].tableName}',
......
......@@ -497,6 +497,7 @@ class CoreBill extends StatelessWidget {
isDeliveryPickuup: isDeliveryPickuup,
dataBill: dataBill,
backgroundColorComponent: backgroundWhite,
isdelivery: getIsCustomerDelivery(),
),
(isDeliveryPickuup)
? Container(
......@@ -970,6 +971,7 @@ class CoreBill extends StatelessWidget {
outStandingTopayMember: outStandingTopayMember,
indexDataIndividu: indexDataIndividu,
memberinfo: memberinfo,
isHistory: isHistory,
)
: const SizedBox(),
(getIsDeliveryPickup())
......@@ -984,6 +986,7 @@ class CoreBill extends StatelessWidget {
outStandingTopayMember: outStandingTopayMember,
indexDataIndividu: indexDataIndividu,
memberinfo: memberinfo,
isHistory: isHistory,
)
: const SizedBox(),
(!getIsDeliveryPickup())
......@@ -1009,25 +1012,26 @@ class CoreBill extends StatelessWidget {
],
)
: (dataBill[0].tableStatus != tableStatusOpen)
? GestureDetector(
? Column(
children: [
const SizedBox(
height: 12,
),
GestureDetector(
onTap: () {
if (dataBill[0].state ==
orderStateDone) {
//**UUID */
var newOrderId = uuidInit.v4();
//** UUID */
setOrderId(newOrderId);
context
.read<BranchExist>()
.branchExist(
getBranchPref(),
getBrand(),
getRole(),
getCashierName(),
getOrderId(),
if (isHistory) {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) =>
HistoryOrderNew(
historyOrder:
getListHistory(),
),
),
);
} else {
setIsNewOrder(true);
context
.read<BranchExist>()
.branchExist(
......@@ -1038,25 +1042,69 @@ class CoreBill extends StatelessWidget {
getOrderId(),
context,
);
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) =>
const NewHome2()),
const NewHome2(),
),
);
}
},
child: Column(
children: [
const SizedBox(
height: 12,
),
GestureDetector(
onTap: () {
// if (dataBill[0].tableStatus ==
// tableStatusOpen) {
// onTapCashier();
// if (dataBill[0].state ==
// orderStateDone) {
// //**UUID */
// // var newOrderId = uuidInit.v4();
// //** UUID */
// if (isHistory) {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (_) =>
// HistoryOrderNew(
// historyOrder:
// getListHistory(),
// ),
// ),
// );
// } else {
// setIsNewOrder(true);
// context
// .read<BranchExist>()
// .branchExist(
// getBranchPref(),
// getBrand(),
// getRole(),
// getCashierName(),
// getOrderId(),
// context,
// );
// Navigator.pushReplacement(
// context,
// MaterialPageRoute(
// builder: (_) =>
// const NewHome2(),
// ),
// );
// }
// } else {
// setIsNewOrder(true);
// context
// .read<BranchExist>()
// .branchExist(
// getBranchPref(),
// getBrand(),
// getRole(),
// getCashierName(),
// getOrderId(),
// context,
// );
// Navigator.pushReplacement(
// context,
// MaterialPageRoute(
// builder: (_) =>
// const NewHome2(),
// ),
// );
// }
},
child: const ButtonComponent(
......@@ -1065,7 +1113,6 @@ class CoreBill extends StatelessWidget {
),
),
],
),
)
: const SizedBox()
: const SizedBox(),
......@@ -1098,6 +1145,7 @@ class ButtonPayment extends StatelessWidget {
required this.outStandingTopayMember,
required this.indexDataIndividu,
required this.memberinfo,
required this.isHistory,
}) : super(key: key);
final List<Bill> dataBill;
......@@ -1110,6 +1158,7 @@ class ButtonPayment extends StatelessWidget {
final int outStandingTopayMember;
final int indexDataIndividu;
final MemberInfo memberinfo;
final bool isHistory;
@override
Widget build(BuildContext context) {
......@@ -1126,30 +1175,49 @@ class ButtonPayment extends StatelessWidget {
EasyLoading.showToast(
'Alamat harus dipilih terlebih dahulu');
} else {
Api.setToPendingOrder();
Api.setToPendingOrder().then((value) {
if (value) {
context.read<ViewBillBloc>().getBill();
}
});
}
} else {
if (getPickupTime() == '') {
EasyLoading.showToast('Silakan pilih jam pickup');
} else {
Api.setToPendingOrder();
Api.setToPendingOrder().then((value) {
if (value) {
context.read<ViewBillBloc>().getBill();
}
});
}
}
} else {
Api.setToPendingOrder();
Api.setToPendingOrder().then((value) {
if (value) {
context.read<ViewBillBloc>().getBill();
}
});
}
} else if (dataBill[0].state == orderStatePending &&
getTableMode() == tableIndividu) {
EasyLoading.showToast(
'Status orderan anda menunggu untuk disetujui');
} else if (dataBill[0].state == orderStateDone) {
//**UUID */
var newOrderId = uuidInit.v4();
// var newOrderId = uuidInit.v4();
//** UUID */
setOrderId(newOrderId);
if (isHistory) {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => HistoryOrderNew(
historyOrder: getListHistory(),
),
),
);
} else {
setIsNewOrder(true);
context.read<BranchExist>().branchExist(
getBranchPref(),
getBrand(),
......@@ -1158,13 +1226,13 @@ class ButtonPayment extends StatelessWidget {
getOrderId(),
context,
);
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) => const NewHome2(),
),
);
}
} else {
if (paymentMode == closebill && memberinfo.id == '') {
addPayment(
......@@ -1508,7 +1576,10 @@ class ButtonPayment extends StatelessWidget {
child: Center(
child: defaultText(
context,
textButtonCheckout(dataBill[0].state),
textButtonCheckout(
dataBill[0].state,
isHistory,
),
style: buttonBottomBill(),
),
),
......@@ -2048,24 +2119,46 @@ Apakah ingin melanjutkan ?''';
font: 10,
),
),
defaultText(
(address.locationDetail != '')
? defaultText(
context,
"Detail Lokasi: ${address.locationDetail}",
style: addressStyle(
font: 10,
),
),
defaultText(
)
: const SizedBox(),
(address.notes != '')
? defaultText(
context,
"Catatan : ${address.notes}",
style: addressStyle(
font: 10,
),
)
: const SizedBox(),
(databill.isNotEmpty && databill[0].courierName != '' ||
databill.isNotEmpty &&
databill[0].courierPhone != '')
? const SizedBox(
height: 10,
)
: const SizedBox(),
(databill.isNotEmpty && databill[0].courierName != '' ||
databill.isNotEmpty &&
databill[0].courierPhone != '')
? defaultText(
context,
'Kurir Detail :',
style: addressStyle(
font: 10,
),
)
: const SizedBox(),
(databill.isNotEmpty && databill[0].courierName != '')
? defaultText(
context,
"Kurir : ${databill[0].courierName}",
"Kurir Name : ${databill[0].courierName}",
style: addressStyle(
font: 10,
),
......@@ -2075,7 +2168,7 @@ Apakah ingin melanjutkan ?''';
? GestureDetector(
onTap: () {
htmlOpenLink(
'https://wa.me/${databill[0].courierPhone}',
'tel:${databill[0].courierPhone}',
self: false,
);
},
......@@ -2086,7 +2179,7 @@ Apakah ingin melanjutkan ?''';
phoneIconSize,
),
const SizedBox(
width: 10,
width: 5,
),
defaultText(
context,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment