Commit be178cf2 authored by Dio Maulana's avatar Dio Maulana

add promo cc mandiri

parent 28c996e2
......@@ -291,16 +291,19 @@ class Api {
// }
static Future<List<FilterMenu>> getMenuAndFilterMenu(
String branchCode,
String brandCode,
String role,
String cashierName,
String tokenUser) async {
String branchCode,
String brandCode,
String role,
String cashierName,
String tokenUser,
) async {
String baseUrl = prefs.getString('baseUrl') ?? '';
String apiUrl = '${baseUrl}romi/api/v2/byod/get_menu';
// List<FilterMenu> filterMenu = [];
List<FilterMenu> filterMenu = [];
// List<FilterMenu> filterMenuResult = [];
String sessionID = prefs.getString('sessionId') ?? '';
try {
Map data = {
"branch_code": branchCode,
......@@ -308,7 +311,8 @@ class Api {
"role": role,
"cashier_name": cashierName,
"secure_token": tokenUser,
"from": fromByod
"from": fromByod,
"session_id": sessionID,
};
var bodies = jsonEncode(data);
// var apiResult = await http.post(Uri.parse(apiUrl), body: bodies);
......@@ -828,6 +832,8 @@ class Api {
"doku_minimum_payment": jsonObject['data']
['doku_minimum_payment'],
"order_date": jsonObject['data']['order_date'],
"is_allow_promotion":
jsonObject['data']['is_allow_promotion'] ?? "0",
};
bill.add(Bill.createBill(i));
// billDetail.add(BillDetail.createBillDetail(orderDetail[d]));
......@@ -1679,4 +1685,63 @@ class Api {
return feedBack;
}
}
static Future<bool> addCancelPromotion(String orderID, bool isAdd) async {
await EasyLoading.show(
status: 'Please wait...',
maskType: EasyLoadingMaskType.none,
);
String baseUrl = prefs.getString('baseUrl') ?? '';
String apiUrl;
if (isAdd) {
apiUrl = "${baseUrl}romi/api/byod/add_promotions";
} else {
apiUrl = "${baseUrl}romi/api/byod/cancel_promotions";
}
String branchCode = prefs.getString('outlet') ?? '';
String brandCode = prefs.getString('brand') ?? '';
String role = prefs.getString('role') ?? 'customer';
String cashierName = prefs.getString('cashier_name') ?? '';
String userName = prefs.getString('userName') ?? '';
try {
Map data = {
"branch_code": branchCode,
"brand_code": brandCode,
"role": role,
"cashier_name": cashierName,
"from": fromByod,
"order_id": orderID,
};
var bodies = jsonEncode(data);
var jsonObject = await httpPost(apiUrl, bodies, 'addPromotion');
if (jsonObject != false) {
if (jsonObject['status'].toString().toLowerCase() == 'ok') {
if (isAdd) {
await prefs.setBool('isPromoActive', true);
EasyLoading.showToast('Promosi aktif');
} else {
await prefs.setBool('isPromoActive', false);
EasyLoading.showToast('Promosi tidak aktif');
}
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: addPromotion, URL : $apiUrl',
'ERROR CONNECT TO SERVER, ERROR CATCH : $e');
}
EasyLoading.showToast('Cant connect to server');
return false;
}
}
}
import 'package:flutter/cupertino.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../api/api.dart';
import '../helper/helper.dart';
import 'filter_menu.dart';
class BranchExist extends Cubit<String> {
BranchExist() : super(responseApiWaiting);
......@@ -13,10 +15,20 @@ class BranchExist extends Cubit<String> {
return apiGetBranch;
}
void branchExist(String branchCode, String brandCode, String role,
String cashierName, String sessionId) {
void branchExist(BuildContext context, String branchCode, String brandCode,
String role, String cashierName, String sessionId,
{bool getMenu = false, String token = ''}) {
getBranch(branchCode, brandCode, role, cashierName, sessionId)
.then((value) {
if (getMenu) {
context.read<FilterMenuBloc>().catAndMenu(
branchCode,
brandCode,
role,
cashierName,
token,
);
}
emit(value);
});
}
......
......@@ -22,30 +22,32 @@ class Bill {
String tableName;
bool isFeedBack;
String dokuMinPay;
String isPromotionAllow;
// List<MemberInfo> memberInfo;
Bill(
{required this.id,
required this.totalSeluruhOrderan,
required this.subTotalSeluruhOrderan,
required this.totalPerCustomer,
required this.customerName,
required this.tableStatus,
required this.orderStatus,
required this.outStandingPay,
required this.outStandingIndividu,
required this.dateOrder,
this.billDetail = const [],
this.paymentList = const [],
required this.invoice,
required this.totalService,
required this.totalServiceTax,
required this.discountTotal,
required this.tableName,
required this.isFeedBack,
required this.dokuMinPay
// this.memberInfo = const []
});
Bill({
required this.id,
required this.totalSeluruhOrderan,
required this.subTotalSeluruhOrderan,
required this.totalPerCustomer,
required this.customerName,
required this.tableStatus,
required this.orderStatus,
required this.outStandingPay,
required this.outStandingIndividu,
required this.dateOrder,
this.billDetail = const [],
this.paymentList = const [],
required this.invoice,
required this.totalService,
required this.totalServiceTax,
required this.discountTotal,
required this.tableName,
required this.isFeedBack,
required this.dokuMinPay,
this.isPromotionAllow = "0",
// this.memberInfo = const []
});
factory Bill.createBill(Map<String, dynamic> json) {
return Bill(
......@@ -68,6 +70,7 @@ class Bill {
isFeedBack: json['is_feedback'],
dokuMinPay: json['doku_minimum_payment'],
dateOrder: json['order_date'],
isPromotionAllow: json['is_allow_promotion'] ?? "0",
// memberInfo: json['member_info']
);
}
......
......@@ -947,14 +947,13 @@ class _NewHome2State extends State<NewHome2> {
style: const TextStyle(
fontFamily: 'OpenSans',
fontSize: 14,
color: textColorModalHeaderNama,
color: textColorBlack,
),
decoration: const InputDecoration(
labelText: 'Nama panggilan',
labelStyle: TextStyle(
fontFamily: 'OpenSans',
fontSize: 14,
fontWeight: FontWeight.w600,
color: textColorModalHeaderNama,
),
),
......
......@@ -57,17 +57,20 @@ class _SplashState extends State<Splash> {
loadBaseUrl().then((baseUrl) {
prefs.setString('baseUrl', baseUrl);
context.read<BranchExist>().branchExist(
context,
widget.param,
widget.brand,
widget.role,
widget.cashierName,
widget.sessionId,
getMenu: true,
token: widget.token,
);
// context.read<CategoryMenu>().catAndMenu(widget.param, widget.brand,
// widget.role, widget.cashierName, widget.token);
context.read<FilterMenuBloc>().catAndMenu(widget.param, widget.brand,
widget.role, widget.cashierName, widget.token);
// context.read<FilterMenuBloc>().catAndMenu(widget.param, widget.brand,
// widget.role, widget.cashierName, widget.token);
if (widget.token != '') {
context.read<MemberInfoBloc>().getMemberInfo(widget.token);
......
......@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../bloc/branch_exist.dart';
import '../../bloc/filter_menu.dart';
import '../../helper/helper.dart';
import '../../helper/widget/style.dart';
import '../../main.dart';
......@@ -24,6 +25,7 @@ class CustomAppBar extends StatelessWidget {
String role = prefs.getString('role') ?? '';
String cashierName = prefs.getString('cashier_name') ?? '';
String sessionId = prefs.getString('sessionId') ?? '';
String tokenMember = prefs.getString('token') ?? '';
return Container(
padding: const EdgeInsets.only(
top: 15,
......@@ -39,10 +41,22 @@ class CustomAppBar extends StatelessWidget {
GestureDetector(
onTap: () {
if (!isHistory) {
Navigator.pushReplacement(context,
MaterialPageRoute(builder: (_) => const NewHome2()));
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) => const NewHome2(),
),
);
context.read<BranchExist>().branchExist(
branchCode, brandCode, role, cashierName, sessionId);
context,
branchCode,
brandCode,
role,
cashierName,
sessionId,
getMenu: true,
token: tokenMember,
);
} else {
Navigator.pop(context);
}
......
......@@ -410,6 +410,7 @@ Mohon menuju kasir untuk meminta bukti pembayaran''';
context
.read<BranchExist>()
.branchExist(
context,
branchCode,
brandCode,
role,
......@@ -745,6 +746,7 @@ Mohon menuju kasir untuk meminta bukti pembayaran''';
GestureDetector(
onTap: () {
context.read<BranchExist>().branchExist(
context,
branchCode,
brandCode,
role,
......@@ -1249,8 +1251,8 @@ Mohon menuju kasir untuk meminta bukti pembayaran''';
if (!widget.isHistory) {
Navigator.pushReplacement(context,
MaterialPageRoute(builder: (_) => const NewHome2()));
context.read<BranchExist>().branchExist(
branchCode, brandCode, role, cashierName, sessionId);
context.read<BranchExist>().branchExist(context, branchCode,
brandCode, role, cashierName, sessionId);
} else {
Navigator.pop(context);
}
......
This diff is collapsed.
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