Commit b29fe28b authored by Dio Maulana's avatar Dio Maulana

13/10/22

parent 63fcc40d
...@@ -20,6 +20,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; ...@@ -20,6 +20,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
import '../bloc/address_user_bloc.dart';
import '../bloc/order_bloc.dart'; import '../bloc/order_bloc.dart';
import '../helper/widget/open_url.dart'; import '../helper/widget/open_url.dart';
import '../main.dart'; import '../main.dart';
...@@ -92,7 +93,7 @@ class Api { ...@@ -92,7 +93,7 @@ class Api {
"order_id": orderID, "order_id": orderID,
"session_id": sessionId, "session_id": sessionId,
"from": fromByod, "from": fromByod,
"url_lookup": (urlType == typeUrlTiga) ? 'https://dimas.com' : '', "url_lookup": (debug) ? 'https://www.ravintola.web.id/' : (urlType == typeUrlTiga) ? getUrlLookUp() : '',
"customer_lat": latitude, "customer_lat": latitude,
"customer_long": longitude, "customer_long": longitude,
"type_url": urlType, "type_url": urlType,
...@@ -167,6 +168,11 @@ class Api { ...@@ -167,6 +168,11 @@ class Api {
if (jsonObject['data']['table_mode'] != null) { if (jsonObject['data']['table_mode'] != null) {
setTableMode(jsonObject['data']['table_mode']); setTableMode(jsonObject['data']['table_mode']);
} }
if (jsonObject['data']['type_order'] == typeOrderDelivery) {
setIsCustomerDelivery(true);
} else {
setIsCustomerDelivery(false);
}
return responseByodBranchExist; return responseByodBranchExist;
} else if (jsonObject['status'] == 'error' && } else if (jsonObject['status'] == 'error' &&
(jsonObject['code'] == 'BYOD_ALWAYS_OFF' || (jsonObject['code'] == 'BYOD_ALWAYS_OFF' ||
...@@ -779,6 +785,7 @@ class Api { ...@@ -779,6 +785,7 @@ class Api {
String token, { String token, {
String orderIdH = '', String orderIdH = '',
String userNameH = '', String userNameH = '',
bool isCallGetAddress = false,
}) async { }) async {
String baseUrl = getBaseUrl(); String baseUrl = getBaseUrl();
String apiUrl = "$baseUrl${endPoint}get_bill"; String apiUrl = "$baseUrl${endPoint}get_bill";
...@@ -917,6 +924,7 @@ class Api { ...@@ -917,6 +924,7 @@ class Api {
"packaging_fee": "packaging_fee":
jsonObject['data']['packaging_fee'] ?? "0.00", jsonObject['data']['packaging_fee'] ?? "0.00",
"platform_fee": jsonObject['data']['platform_fee'] ?? "0.00", "platform_fee": jsonObject['data']['platform_fee'] ?? "0.00",
"delivery_fee": jsonObject['data']['delivery_fee'] ?? "0.00",
}; };
bill.add(Bill.createBill(i)); bill.add(Bill.createBill(i));
// billDetail.add(BillDetail.createBillDetail(orderDetail[d])); // billDetail.add(BillDetail.createBillDetail(orderDetail[d]));
...@@ -1162,6 +1170,7 @@ class Api { ...@@ -1162,6 +1170,7 @@ class Api {
"code_voucher": codeVoucher, "code_voucher": codeVoucher,
"secure_token": token, "secure_token": token,
"amount": amount, "amount": amount,
"time_ready_for_pickup": getPickupTime(),
"from": fromByod "from": fromByod
}; };
var bodies = jsonEncode(data); var bodies = jsonEncode(data);
...@@ -1609,6 +1618,7 @@ class Api { ...@@ -1609,6 +1618,7 @@ class Api {
"cashier_name": cashierName, "cashier_name": cashierName,
"amount": amount, "amount": amount,
"secure_token": token, "secure_token": token,
"time_ready_for_pickup": getPickupTime(),
"from": fromByod "from": fromByod
}; };
var bodies = jsonEncode(data); var bodies = jsonEncode(data);
...@@ -1913,6 +1923,7 @@ class Api { ...@@ -1913,6 +1923,7 @@ class Api {
"cashier_name": cashierName, "cashier_name": cashierName,
"customer_name": userName, "customer_name": userName,
"from": fromByod, "from": fromByod,
"time_ready_for_pickup": getPickupTime(),
"order_id": orderID "order_id": orderID
}; };
var bodies = jsonEncode(data); var bodies = jsonEncode(data);
...@@ -2040,7 +2051,7 @@ class Api { ...@@ -2040,7 +2051,7 @@ class Api {
} }
} }
static Future<Address> getAddress() async { static Future<Address> getAddress({context}) async {
String baseUrl = getBaseUrl(); String baseUrl = getBaseUrl();
String apiUrl = "$baseUrl${endPointRdm}get_address/"; String apiUrl = "$baseUrl${endPointRdm}get_address/";
...@@ -2068,6 +2079,11 @@ class Api { ...@@ -2068,6 +2079,11 @@ class Api {
if (jsonObject != false) { if (jsonObject != false) {
if (jsonObject['status'].toString().toLowerCase() == 'ok') { if (jsonObject['status'].toString().toLowerCase() == 'ok') {
Map<String, dynamic> data = jsonObject['data']; Map<String, dynamic> data = jsonObject['data'];
if (getTypeOrder() == typeOrderDelivery) {
Api.getDeliveryCharge(
jsonObject['data']['lat'], jsonObject['data']['long'])
.then((value) {});
}
return Address.json(data); return Address.json(data);
} }
...@@ -2092,9 +2108,9 @@ class Api { ...@@ -2092,9 +2108,9 @@ class Api {
String baseUrl = prefs.getString('baseUrl') ?? ''; String baseUrl = prefs.getString('baseUrl') ?? '';
String apiUrl; String apiUrl;
if (isAdd) { if (isAdd) {
apiUrl = "${baseUrl}romi/api/byod/add_promotions"; apiUrl = "$baseUrl${endPoint}add_promotions";
} else { } else {
apiUrl = "${baseUrl}romi/api/byod/cancel_promotions"; apiUrl = "$baseUrl${endPoint}cancel_promotions";
} }
String branchCode = getBranchPref(); String branchCode = getBranchPref();
String brandCode = getBrand(); String brandCode = getBrand();
...@@ -2102,8 +2118,15 @@ class Api { ...@@ -2102,8 +2118,15 @@ class Api {
String cashierName = getCashierName(); String cashierName = getCashierName();
String orderID = getOrderId(); String orderID = getOrderId();
String sessionId = getSessionId();
String signString = signApi();
int sessionC = getSessionCounter();
try { try {
Map data = { Map data = {
"session_id": sessionId,
"count": sessionC,
"sign": signString,
"branch_code": branchCode, "branch_code": branchCode,
"brand_code": brandCode, "brand_code": brandCode,
"role": role, "role": role,
...@@ -2142,4 +2165,109 @@ class Api { ...@@ -2142,4 +2165,109 @@ class Api {
return false; return false;
} }
} }
static Future<bool> getDeliveryCharge(String lat, String long) async {
String baseUrl = prefs.getString('baseUrl') ?? '';
String apiUrl;
apiUrl = "$baseUrl${endPoint}get_delivery_charge";
String branchCode = getBranchPref();
String brandCode = getBrand();
String role = getRole();
String cashierName = getCashierName();
String orderID = getOrderId();
String sessionId = getSessionId();
String signString = signApi();
int sessionC = getSessionCounter();
try {
Map data = {
"session_id": sessionId,
"count": sessionC,
"sign": signString,
"branch_code": branchCode,
"brand_code": brandCode,
"role": role,
"cashier_name": cashierName,
"from": fromByod,
"order_id": orderID,
"customer_name": getCustomerName(),
"customer_address_lat": lat,
"customer_address_long": long,
};
var bodies = jsonEncode(data);
var jsonObject = await httpPost(apiUrl, bodies, 'getDeliveryCharge');
if (jsonObject != false) {
if (jsonObject['status'].toString().toLowerCase() == 'ok') {
return true;
} else {
EasyLoading.showToast(jsonObject['msg']);
return false;
}
} else {
EasyLoading.showToast('Something went wrong');
return false;
}
} catch (e) {
if (debug) {
logd('API CLASS ON API.DART, FUNGSI: getDeliveryCharge, URL : $apiUrl',
'ERROR CONNECT TO SERVER, ERROR CATCH : $e');
}
EasyLoading.showToast('Cant connect to server');
return false;
}
}
static Future<bool> changeTypeOrder(int typeOrder) async {
String baseUrl = prefs.getString('baseUrl') ?? '';
String apiUrl;
apiUrl = "$baseUrl${endPoint}change_type_order_dp";
String branchCode = getBranchPref();
String brandCode = getBrand();
String role = getRole();
String cashierName = getCashierName();
String orderID = getOrderId();
String sessionId = getSessionId();
String signString = signApi();
int sessionC = getSessionCounter();
try {
Map data = {
"session_id": sessionId,
"count": sessionC,
"sign": signString,
"type_order": typeOrder,
"branch_code": branchCode,
"brand_code": brandCode,
"role": role,
"cashier_name": cashierName,
"from": fromByod,
"order_id": orderID,
"customer_name": getCustomerName(),
};
var bodies = jsonEncode(data);
var jsonObject = await httpPost(apiUrl, bodies, 'changeTypeOrder');
if (jsonObject != false) {
if (jsonObject['status'].toString().toLowerCase() == 'ok') {
return true;
} else {
EasyLoading.showToast(jsonObject['msg']);
return false;
}
} else {
EasyLoading.showToast('Something went wrong');
return false;
}
} catch (e) {
if (debug) {
logd('API CLASS ON API.DART, FUNGSI: changeTypeOrder, URL : $apiUrl',
'ERROR CONNECT TO SERVER, ERROR CATCH : $e');
}
EasyLoading.showToast('Cant connect to server');
return false;
}
}
} }
import 'package:byod/models/address_user.dart'; import 'package:byod/models/address_user.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import '../api/api.dart'; import '../api/api.dart';
......
...@@ -36,6 +36,7 @@ class ViewBillBloc extends Cubit<List<Bill>> { ...@@ -36,6 +36,7 @@ class ViewBillBloc extends Cubit<List<Bill>> {
String tableNumberH = '', String tableNumberH = '',
String tokenH = '', String tokenH = '',
String userNameH = '', String userNameH = '',
isGetAddress = false,
}) async { }) async {
String branchCode; String branchCode;
String brandCode; String brandCode;
...@@ -60,6 +61,7 @@ class ViewBillBloc extends Cubit<List<Bill>> { ...@@ -60,6 +61,7 @@ class ViewBillBloc extends Cubit<List<Bill>> {
brandCode, brandCode,
tableNumber, tableNumber,
token, token,
isCallGetAddress: isGetAddress,
); );
} else { } else {
bill = await Api.getBill( bill = await Api.getBill(
...@@ -69,6 +71,7 @@ class ViewBillBloc extends Cubit<List<Bill>> { ...@@ -69,6 +71,7 @@ class ViewBillBloc extends Cubit<List<Bill>> {
token, token,
orderIdH: orderIdH, orderIdH: orderIdH,
userNameH: userNameH, userNameH: userNameH,
isCallGetAddress: isGetAddress,
); );
} }
......
...@@ -314,9 +314,19 @@ bool isVisibleAddMoreButton(int tableStatus, int orderState) { ...@@ -314,9 +314,19 @@ bool isVisibleAddMoreButton(int tableStatus, int orderState) {
return false; return false;
} }
bool isVisibleAddRemoveQuantityButtonCheckout(bool isHistory, int orderStatus) { bool isVisibleAddRemoveQuantityButtonCheckout(
bool isHistory, int orderStatusBillDetail) {
int paymentMethod = getPaymentMode(); int paymentMethod = getPaymentMode();
if (!isHistory && paymentMethod == closebill && orderStatus == pendingOrder) { if (!isHistory &&
paymentMethod == closebill &&
orderStatusBillDetail == pendingOrder) {
return true;
}
return false;
}
iscanTapAddRemoveQtyViewBill(int orderState) {
if (orderState == orderStateCreated) {
return true; return true;
} }
return false; return false;
...@@ -708,7 +718,7 @@ const int typeUrlTiga = 3; ...@@ -708,7 +718,7 @@ const int typeUrlTiga = 3;
//** Type ORder */ //** Type ORder */
const int typeOrderDelivery = 0; const int typeOrderDelivery = 0;
const int typeOrderDineIn = 1; const int typeOrderDineIn = 1;
const int typeOrderPickup = 1; const int typeOrderPickup = 2;
//** Type ORder */ //** Type ORder */
//** END CONSTANT */ //** END CONSTANT */
...@@ -296,7 +296,9 @@ class _EmoticonRateState extends State<EmoticonRate> { ...@@ -296,7 +296,9 @@ class _EmoticonRateState extends State<EmoticonRate> {
).then((value) { ).then((value) {
Navigator.pop(context); Navigator.pop(context);
if (!widget.isHistory) { if (!widget.isHistory) {
context.read<ViewBillBloc>().getBill(); context
.read<ViewBillBloc>()
.getBill();
} else { } else {
List<String> listHistory = getListHistory(); List<String> listHistory = getListHistory();
if (listHistory.isNotEmpty) { if (listHistory.isNotEmpty) {
......
...@@ -240,7 +240,9 @@ class EmoticonRateNew extends StatelessWidget { ...@@ -240,7 +240,9 @@ class EmoticonRateNew extends StatelessWidget {
).then((value) { ).then((value) {
Navigator.pop(context); Navigator.pop(context);
if (!isHistory) { if (!isHistory) {
context.read<ViewBillBloc>().getBill(); context
.read<ViewBillBloc>()
.getBill();
} else { } else {
List<String> listHistory = getListHistory(); List<String> listHistory = getListHistory();
if (listHistory.isNotEmpty) { if (listHistory.isNotEmpty) {
......
...@@ -15,6 +15,7 @@ class PlusMinusButton extends StatelessWidget { ...@@ -15,6 +15,7 @@ class PlusMinusButton extends StatelessWidget {
this.backgroundAmountColor = backgroundColor, this.backgroundAmountColor = backgroundColor,
this.isFromVariant = false, this.isFromVariant = false,
this.widthInitialValue = 94, this.widthInitialValue = 94,
this.isCanTap = true,
}) : super(key: key); }) : super(key: key);
final int initialValue; final int initialValue;
...@@ -23,6 +24,7 @@ class PlusMinusButton extends StatelessWidget { ...@@ -23,6 +24,7 @@ class PlusMinusButton extends StatelessWidget {
final Color backgroundAmountColor; final Color backgroundAmountColor;
final bool isFromVariant; final bool isFromVariant;
final double widthInitialValue; final double widthInitialValue;
final bool isCanTap;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -60,11 +62,13 @@ class PlusMinusButton extends StatelessWidget { ...@@ -60,11 +62,13 @@ class PlusMinusButton extends StatelessWidget {
width: 22, width: 22,
height: 22, height: 22,
child: Image( child: Image(
image: AssetImage((initialValue < 2 && isFromVariant) image: AssetImage((!isCanTap)
? 'assets/icons/minus.png' ? 'assets/icons/minus.png'
: (isExcelso) : (initialValue < 2 && isFromVariant)
? 'assets/icons/minus-gold.png' ? 'assets/icons/minus.png'
: 'assets/icons/minus-blue.png'), : (isExcelso)
? 'assets/icons/minus-gold.png'
: 'assets/icons/minus-blue.png'),
), ),
), ),
), ),
...@@ -84,9 +88,11 @@ class PlusMinusButton extends StatelessWidget { ...@@ -84,9 +88,11 @@ class PlusMinusButton extends StatelessWidget {
width: 22, width: 22,
height: 22, height: 22,
child: Image( child: Image(
image: AssetImage((isExcelso) image: AssetImage((!isCanTap)
? 'assets/icons/plus-gold.png' ? 'assets/icons/plus-grey.png'
: 'assets/icons/plus.png'), : (isExcelso)
? 'assets/icons/plus-gold.png'
: 'assets/icons/plus.png'),
), ),
), ),
), ),
......
...@@ -67,13 +67,11 @@ void main() async { ...@@ -67,13 +67,11 @@ void main() async {
prefs = value; prefs = value;
configLoading(); configLoading();
for (int d = 0; d < Uri.base.pathSegments.length; d++) { for (int d = 0; d < Uri.base.pathSegments.length; d++) {
if (Uri.base.pathSegments[0] != 'byod-neo/') { stringPath.add(Uri.base.pathSegments[d]);
stringPath.add(Uri.base.pathSegments[d]); if (d == Uri.base.pathSegments.length - 1) {
if (d == Uri.base.pathSegments.length - 1) { routesToAccess += Uri.base.pathSegments[d];
routesToAccess += Uri.base.pathSegments[d]; } else {
} else { routesToAccess += '${Uri.base.pathSegments[d]}/';
routesToAccess += '${Uri.base.pathSegments[d]}/';
}
} }
} }
loadAssetConfig().then((title) { loadAssetConfig().then((title) {
......
...@@ -25,6 +25,7 @@ class Bill { ...@@ -25,6 +25,7 @@ class Bill {
String dokuMinPay; String dokuMinPay;
String packagingFee; String packagingFee;
String platformFee; String platformFee;
String deliveryFee;
// List<MemberInfo> memberInfo; // List<MemberInfo> memberInfo;
Bill({ Bill({
...@@ -50,6 +51,7 @@ class Bill { ...@@ -50,6 +51,7 @@ class Bill {
required this.dokuMinPay, required this.dokuMinPay,
this.packagingFee = "0.00", this.packagingFee = "0.00",
this.platformFee = "0.00", this.platformFee = "0.00",
this.deliveryFee = "0.00",
// this.memberInfo = const [] // this.memberInfo = const []
}); });
...@@ -77,6 +79,7 @@ class Bill { ...@@ -77,6 +79,7 @@ class Bill {
dateOrder: json['order_date'], dateOrder: json['order_date'],
packagingFee: json['packaging_fee'], packagingFee: json['packaging_fee'],
platformFee: json['platform_fee'], platformFee: json['platform_fee'],
deliveryFee: json['delivery_fee']
// memberInfo: json['member_info'] // memberInfo: json['member_info']
); );
} }
......
...@@ -220,7 +220,7 @@ class _HomeState extends State<Home> { ...@@ -220,7 +220,7 @@ class _HomeState extends State<Home> {
double widthScreen, double widthScreen,
double maxWidthScreen, double maxWidthScreen,
BuildContext context, BuildContext context,
int tableMode, int paymentMode,
List<FavoriteGroup> favList, List<FavoriteGroup> favList,
) { ) {
return BlocBuilder<SearchMenu, List<dynamic>>( return BlocBuilder<SearchMenu, List<dynamic>>(
...@@ -341,7 +341,7 @@ class _HomeState extends State<Home> { ...@@ -341,7 +341,7 @@ class _HomeState extends State<Home> {
totalItem, totalItem,
totalHarga, totalHarga,
widthScreen, widthScreen,
tableMode, paymentMode,
listOrders) listOrders)
: const SizedBox())) : const SizedBox()))
], ],
......
...@@ -32,6 +32,7 @@ class ListOrder extends StatelessWidget { ...@@ -32,6 +32,7 @@ class ListOrder extends StatelessWidget {
itemBuilder: (ctx, d) { itemBuilder: (ctx, d) {
return OrderViewBillNew( return OrderViewBillNew(
billDetail: bill[i].billDetail[d], billDetail: bill[i].billDetail[d],
bill: bill[0],
lastItem: lastItem:
(i + 1 == bill.length && d + 1 == bill[i].billDetail.length) (i + 1 == bill.length && d + 1 == bill[i].billDetail.length)
? true ? true
......
...@@ -12,11 +12,13 @@ import '../../helper/widget/button_dialog.dart'; ...@@ -12,11 +12,13 @@ import '../../helper/widget/button_dialog.dart';
import '../../helper/widget/note_modal_bottom_sheet.dart'; import '../../helper/widget/note_modal_bottom_sheet.dart';
import '../../helper/widget/plus_minus_button.dart'; import '../../helper/widget/plus_minus_button.dart';
import '../../helper/widget/style.dart'; import '../../helper/widget/style.dart';
import '../../models/bill.dart';
import '../../models/bill_detail.dart'; import '../../models/bill_detail.dart';
import 'view_bill_new.dart'; import 'view_bill_new.dart';
class OrderViewBillNew extends StatefulWidget { class OrderViewBillNew extends StatefulWidget {
final BillDetail billDetail; final BillDetail billDetail;
final Bill bill;
final bool lastItem; final bool lastItem;
final bool isHistory; final bool isHistory;
final int tableStatus; final int tableStatus;
...@@ -24,6 +26,7 @@ class OrderViewBillNew extends StatefulWidget { ...@@ -24,6 +26,7 @@ class OrderViewBillNew extends StatefulWidget {
Key? key, Key? key,
required this.billDetail, required this.billDetail,
required this.isHistory, required this.isHistory,
required this.bill,
this.lastItem = false, this.lastItem = false,
required this.tableStatus, required this.tableStatus,
}) : super(key: key); }) : super(key: key);
...@@ -260,49 +263,57 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> { ...@@ -260,49 +263,57 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
children: [ children: [
GestureDetector( GestureDetector(
onTap: () { onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context); if (iscanTapAddRemoveQtyViewBill(widget.bill.state) ==
true) {
FocusScopeNode currentFocus =
FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) { if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus(); currentFocus.unfocus();
}
showModalBottomSheet(
backgroundColor: backgroundColor,
isScrollControlled: true,
context: context,
builder: (context) {
return NoteModalBottomSheet(
noteController: TextEditingController(
text: widget.billDetail.notes),
initialValue: initialValue,
orderVariants: const [],
menuItem: FilterMenu(
id: '',
name: '',
price: '',
originalPrice: '',
imageUrlMedium: '',
imageUrlThumbnail: '',
isSell: false,
type: typeMenu,
categoryName: '',
categoryId: '',
description: '',
groupName: '',
groupId: ''),
lisrOrders: const [],
from: fromBill,
idOrderan: widget.billDetail.id,
contextFrom: contextOrderViewBill,
);
},
);
} }
showModalBottomSheet(
backgroundColor: backgroundColor,
isScrollControlled: true,
context: context,
builder: (context) {
return NoteModalBottomSheet(
noteController: TextEditingController(
text: widget.billDetail.notes),
initialValue: initialValue,
orderVariants: const [],
menuItem: FilterMenu(
id: '',
name: '',
price: '',
originalPrice: '',
imageUrlMedium: '',
imageUrlThumbnail: '',
isSell: false,
type: typeMenu,
categoryName: '',
categoryId: '',
description: '',
groupName: '',
groupId: ''),
lisrOrders: const [],
from: fromBill,
idOrderan: widget.billDetail.id,
contextFrom: contextOrderViewBill,
);
},
);
}, },
child: Container( child: Container(
height: 30, height: 30,
width: 98, width: 98,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(21), borderRadius: BorderRadius.circular(21),
color: buttonColor, color: (iscanTapAddRemoveQtyViewBill(
widget.bill.state) ==
true)
? buttonColor
: disabledColor,
), ),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
...@@ -339,6 +350,8 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> { ...@@ -339,6 +350,8 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
initialValue: widget.billDetail.quantity, initialValue: widget.billDetail.quantity,
plus: plus, plus: plus,
minus: minus, minus: minus,
isCanTap:
iscanTapAddRemoveQtyViewBill(widget.bill.state),
), ),
const SizedBox( const SizedBox(
width: 12, width: 12,
......
...@@ -89,6 +89,40 @@ class RincianPembayaran extends StatelessWidget { ...@@ -89,6 +89,40 @@ class RincianPembayaran extends StatelessWidget {
), ),
], ],
), ),
(getIsDeliveryPickup())
? (getTypeOrder() == typeOrderDelivery)
? const SizedBox(
height: 8,
)
: const SizedBox()
: const SizedBox(),
(getIsDeliveryPickup())
? (getTypeOrder() == typeOrderDelivery)
? Row(
children: [
defaultText(
context,
'Delivery Fee',
style: rincianPembayaran(
font: 12,
color: textGreyBill,
),
),
const Spacer(),
defaultText(
context,
(amountParseToInt(dataBill[0].deliveryFee) == 0)
? '-'
: 'Rp ${formatNumber().format(amountParseToInt(dataBill[0].deliveryFee))}',
style: rincianPembayaran(
font: 12,
color: textGreyBill,
),
),
],
)
: const SizedBox()
: const SizedBox(),
(getIsDeliveryPickup()) (getIsDeliveryPickup())
? const SizedBox( ? const SizedBox(
height: 8, height: 8,
......
...@@ -51,6 +51,7 @@ class ViewBillNew extends StatelessWidget { ...@@ -51,6 +51,7 @@ class ViewBillNew extends StatelessWidget {
final String tableNumberH; final String tableNumberH;
final String token; final String token;
final String userName; final String userName;
final bool isRepeatViewBill;
const ViewBillNew({ const ViewBillNew({
Key? key, Key? key,
this.isHistory = false, this.isHistory = false,
...@@ -60,10 +61,18 @@ class ViewBillNew extends StatelessWidget { ...@@ -60,10 +61,18 @@ class ViewBillNew extends StatelessWidget {
this.tableNumberH = '', this.tableNumberH = '',
this.token = '', this.token = '',
this.userName = '', this.userName = '',
this.isRepeatViewBill = false,
}) : super(key: key); }) : super(key: key);
// final RefreshController _refreshController = // final RefreshController _refreshController =
// RefreshController(initialRefresh: false); // RefreshController(initialRefresh: false);
Future<void> getBillTwice(BuildContext context) async {
context.read<ViewBillBloc>().getBill();
}
Future<void> getAddressTwice(BuildContext context) async {
context.read<AddressUser>().getAddressUser();
}
void saveBillDetail(List<Bill> dataBill) async { void saveBillDetail(List<Bill> dataBill) async {
setTotalOrder(dataBill[0].totalSeluruhOrderan); setTotalOrder(dataBill[0].totalSeluruhOrderan);
...@@ -72,8 +81,17 @@ class ViewBillNew extends StatelessWidget { ...@@ -72,8 +81,17 @@ class ViewBillNew extends StatelessWidget {
void getBillFunc(BuildContext context) { void getBillFunc(BuildContext context) {
if (!isHistory) { if (!isHistory) {
context.read<ViewBillBloc>().getBill(); getBillTwice(context).then((_) {
context.read<AddressUser>().getAddressUser(); if (getTypeOrder() == typeOrderDelivery) {
getAddressTwice(context).then((_) {
if (isRepeatViewBill) {
Future.delayed(const Duration(milliseconds: 2000), () async {
getBillTwice(context);
});
}
});
}
});
} else { } else {
context.read<ViewBillBloc>().getBill( context.read<ViewBillBloc>().getBill(
orderIdH: orderId, orderIdH: orderId,
...@@ -366,7 +384,7 @@ class CoreBill extends StatelessWidget { ...@@ -366,7 +384,7 @@ class CoreBill extends StatelessWidget {
final String brandCode; final String brandCode;
final String orderId; final String orderId;
void getBillFunc(BuildContext context) { void getBillFunction(BuildContext context) {
context.read<ViewBillBloc>().getBill(); context.read<ViewBillBloc>().getBill();
} }
...@@ -905,7 +923,7 @@ class CoreBill extends StatelessWidget { ...@@ -905,7 +923,7 @@ class CoreBill extends StatelessWidget {
if (isCanButtonCheckoutToTap(dataBill[0].state)) { if (isCanButtonCheckoutToTap(dataBill[0].state)) {
if (dataBill[0].state == orderStateCreated) { if (dataBill[0].state == orderStateCreated) {
Api.setToPendingOrder(); Api.setToPendingOrder();
getBillFunc(context); context.read<ViewBillBloc>().getBill();
} else if (dataBill[0].state == } else if (dataBill[0].state ==
orderStatePending && orderStatePending &&
getTableMode() == tableIndividu) { getTableMode() == tableIndividu) {
...@@ -1416,7 +1434,12 @@ class CoreBill extends StatelessWidget { ...@@ -1416,7 +1434,12 @@ class CoreBill extends StatelessWidget {
onTap: () { onTap: () {
if (getIsPickup()) { if (getIsPickup()) {
setIsCustomerDelivery(false); setIsCustomerDelivery(false);
getBillFunc(context); Api.changeTypeOrder(typeOrderPickup).then((value) {
if (value) {
context.read<ViewBillBloc>().getBill();
setTypeOrder(typeOrderPickup);
}
});
Navigator.pop(context); Navigator.pop(context);
} else { } else {
String textOnOk = 'OK'; String textOnOk = 'OK';
...@@ -1484,7 +1507,13 @@ Note: Ganti outlet akan menyebabkan orderan anda saat ini hilang ...@@ -1484,7 +1507,13 @@ Note: Ganti outlet akan menyebabkan orderan anda saat ini hilang
); );
} else { } else {
setIsCustomerDelivery(true); setIsCustomerDelivery(true);
getBillFunc(context); Api.changeTypeOrder(typeOrderDelivery).then((value) {
if (value) {
context.read<ViewBillBloc>().getBill();
setTypeOrder(typeOrderDelivery);
}
});
Navigator.pop(context); Navigator.pop(context);
} }
}, },
...@@ -1903,41 +1932,105 @@ Apakah ingin melanjutkan ?'''; ...@@ -1903,41 +1932,105 @@ Apakah ingin melanjutkan ?''';
const SizedBox( const SizedBox(
width: 10, width: 10,
), ),
GestureDetector( Column(
onTap: () { children: [
Navigator.pushReplacement( GestureDetector(
context, onTap: () {
MaterialPageRoute( Navigator.pushReplacement(
builder: (_) => WebViewMap( context,
titleAppBar: 'Ganti Alamat', MaterialPageRoute(
url: builder: (_) => WebViewMap(
'${getBaseUrl()}rdm/address/add/?session_id=${getSessionId()}', titleAppBar: 'Ganti Alamat',
url:
'${getBaseUrl()}rdm/address/add/?session_id=${getSessionId()}',
),
),
);
},
child: Container(
width: 98,
height: 30,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
color: backgroundWhite,
border: Border.all(
color: buttonColor,
),
),
child: Center(
child: defaultText(
context,
'Ganti Alamat',
style: addButton(
font: 8,
color: buttonColor,
),
),
), ),
),
);
},
child: Container(
width: 98,
height: 30,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
color: backgroundWhite,
border: Border.all(
color: buttonColor,
), ),
), ),
child: Center( const SizedBox(
child: defaultText( height: 10,
context, ),
'Ganti Alamat', GestureDetector(
style: addButton( onTap: () {
font: 8, void ontapOkeChange() {
color: buttonColor, Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) => const SelectBranch(
isFormBill: true,
),
),
);
}
void onTapCancelChange() {
Navigator.pop(context);
}
String textOnOk = 'OK';
String textOnCancel = 'Batal';
String title = 'Ganti Outlet';
String description = '''
Ganti outlet akan menyebabkan orderan anda saat ini hilang.
Apakah ingin melanjutkan ?''';
buttonDialogGlobal(
context,
title,
description,
textOnOk,
textOnCancel,
ontapOkeChange,
onTapCancelChange,
okButtonColor: buttonColor,
);
},
child: Container(
width: 98,
height: 30,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
color: backgroundWhite,
border: Border.all(
color: buttonColor,
),
),
child: Center(
child: defaultText(
context,
'Ganti Outlet',
style: addButton(
font: 8,
color: buttonColor,
),
),
), ),
), ),
), ),
), ],
) ),
], ],
), ),
const SizedBox( const SizedBox(
......
// ignore_for_file: sized_box_for_whitespace // ignore_for_file: sized_box_for_whitespace
import 'package:byod/ui/home/new_home2.dart';
import 'package:byod/ui/viewbill/view_bill_new.dart'; import 'package:byod/ui/viewbill/view_bill_new.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../bloc/address_user_bloc.dart';
import '../../helper/helper.dart'; import '../../helper/helper.dart';
import '../../helper/widget/style.dart'; import '../../helper/widget/style.dart';
...@@ -35,7 +31,9 @@ class CustomAppBar extends StatelessWidget { ...@@ -35,7 +31,9 @@ class CustomAppBar extends StatelessWidget {
Navigator.pushReplacement( Navigator.pushReplacement(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (_) => const ViewBillNew(), builder: (_) => const ViewBillNew(
isRepeatViewBill: true,
),
), ),
); );
}, },
...@@ -69,7 +67,9 @@ class CustomAppBar extends StatelessWidget { ...@@ -69,7 +67,9 @@ class CustomAppBar extends StatelessWidget {
Navigator.pushReplacement( Navigator.pushReplacement(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (_) => const ViewBillNew(), builder: (_) => const ViewBillNew(
isRepeatViewBill: true,
),
), ),
); );
}, },
......
...@@ -162,7 +162,9 @@ class _WebViewMapState extends State<WebViewMap> { ...@@ -162,7 +162,9 @@ class _WebViewMapState extends State<WebViewMap> {
Navigator.pushReplacement( Navigator.pushReplacement(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (_) => const ViewBillNew(), builder: (_) => const ViewBillNew(
isRepeatViewBill: true,
),
), ),
); );
} }
......
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