Merge branch 'wala_plus' of http://34.17.182.140/Haroon6138/mohemm-flutter-app into wala_plus

* 'wala_plus' of http://34.17.182.140/Haroon6138/mohemm-flutter-app:
  filter api added
  tested in release mode the QR Fix
  Added business card API
wala_plus
Sultan khan 4 weeks ago
commit c3afbdc55b

@ -1,6 +1,9 @@
import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:developer';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:mohem_flutter_app/api/api_client.dart'; import 'package:mohem_flutter_app/api/api_client.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/consts.dart'; import 'package:mohem_flutter_app/classes/consts.dart';
@ -8,6 +11,7 @@ import 'package:mohem_flutter_app/models/offers_and_discounts/get_categories_lis
import 'package:mohem_flutter_app/models/offers_and_discounts/get_offers_list.dart'; import 'package:mohem_flutter_app/models/offers_and_discounts/get_offers_list.dart';
import 'package:mohem_flutter_app/models/offers_and_discounts/wala_plus_category_model.dart'; import 'package:mohem_flutter_app/models/offers_and_discounts/wala_plus_category_model.dart';
import 'package:mohem_flutter_app/models/offers_and_discounts/wala_plus_retailer_model.dart'; import 'package:mohem_flutter_app/models/offers_and_discounts/wala_plus_retailer_model.dart';
import 'package:mohem_flutter_app/widgets/location/Location.dart' as location;
class OffersAndDiscountsApiClient { class OffersAndDiscountsApiClient {
static final OffersAndDiscountsApiClient _instance = OffersAndDiscountsApiClient._internal(); static final OffersAndDiscountsApiClient _instance = OffersAndDiscountsApiClient._internal();
@ -75,13 +79,48 @@ class OffersAndDiscountsApiClient {
String _resolveUserName() { String _resolveUserName() {
String? pUserName = AppState().getUserName; String? pUserName = AppState().getUserName;
if (pUserName == null || pUserName.isEmpty) { if (pUserName == null || pUserName.isEmpty) {
pUserName = AppState().postParamsObject?.userName ?? pUserName = AppState().postParamsObject?.userName ?? AppState().postParamsObject?.pUserName ?? AppState().memberInformationList?.eMPLOYEENUMBER;
AppState().postParamsObject?.pUserName ??
AppState().memberInformationList?.eMPLOYEENUMBER;
} }
return pUserName ?? ""; return pUserName ?? "";
} }
// Same Location.isEnabled -> Location.havePermission -> Location.getCurrentLocation pattern
// used by mark_attendance_widget.dart (e.g. Wifi attendance), wrapped as a Future since this
// is a background enrichment of the request, not a blocking user action - any failure (service
// disabled, permission denied, error) just resolves to null so the retailer fetch still proceeds
// without WP_Geo_Location rather than showing permission dialogs here.
Future<Position?> _getCurrentPositionSilently(BuildContext context) async {
Completer<bool> enabledCompleter = Completer<bool>();
location.Location.isEnabled((bool isEnabled) {
if (!enabledCompleter.isCompleted) enabledCompleter.complete(isEnabled);
});
bool isEnabled = await enabledCompleter.future;
debugPrint("_getCurrentPositionSilently: location service isEnabled=$isEnabled");
if (!isEnabled) return null;
Completer<bool> permissionCompleter = Completer<bool>();
location.Location.havePermission((bool hasPermission) {
if (!permissionCompleter.isCompleted) permissionCompleter.complete(hasPermission);
});
bool hasPermission = await permissionCompleter.future;
debugPrint("_getCurrentPositionSilently: havePermission=$hasPermission");
if (!hasPermission) return null;
Completer<Position?> positionCompleter = Completer<Position?>();
location.Location.getCurrentLocation(
(Position position, bool isMocked) {
debugPrint("_getCurrentPositionSilently: got position lat=${position.latitude}, lng=${position.longitude}, isMocked=$isMocked");
if (!positionCompleter.isCompleted) positionCompleter.complete(position);
},
() {
debugPrint("_getCurrentPositionSilently: getCurrentLocation error callback fired");
if (!positionCompleter.isCompleted) positionCompleter.complete(null);
},
context,
);
return positionCompleter.future;
}
String _resolveDepNationalId() { String _resolveDepNationalId() {
if (!ApiConsts.isDependetLogin) { if (!ApiConsts.isDependetLogin) {
return ""; return "";
@ -116,7 +155,6 @@ class OffersAndDiscountsApiClient {
return ""; return "";
} }
Map<String, dynamic> _getBaseWalaPlusParams() { Map<String, dynamic> _getBaseWalaPlusParams() {
Map<String, dynamic> base = {}; Map<String, dynamic> base = {};
base.addAll(AppState().postParamsJson); base.addAll(AppState().postParamsJson);
@ -164,10 +202,7 @@ class OffersAndDiscountsApiClient {
(response) { (response) {
List<WalaPlusCategoryModel> categories = []; List<WalaPlusCategoryModel> categories = [];
if (response != null) { if (response != null) {
dynamic cats = response['WalaPlus_Categories'] ?? dynamic cats = response['WalaPlus_Categories'] ?? response['walaPlus_Categories'] ?? response['WalaPlusCategories'] ?? response['result'];
response['walaPlus_Categories'] ??
response['WalaPlusCategories'] ??
response['result'];
if (cats is String) { if (cats is String) {
try { try {
cats = json.decode(cats); cats = json.decode(cats);
@ -192,11 +227,30 @@ class OffersAndDiscountsApiClient {
); );
} }
// Confirmed with backend team: WP_Offer_Type accepts "online" and "store".
static const String walaPlusOfferTypeOnline = "online";
static const String walaPlusOfferTypeInStore = "store";
// Maps the screen's internal filter key ("online"/"instore"/"all") to the WP_Offer_Type value
// the backend expects. Returns null for "all" (or anything unrecognized) so callers can skip
// sending WP_Offer_Type entirely.
static String? mapOfferTypeFilter(String internalKey) {
switch (internalKey) {
case "online":
return walaPlusOfferTypeOnline;
case "instore":
return walaPlusOfferTypeInStore;
default:
return null;
}
}
Future<WalaPlusRetailersResponse?> getWalaPlusRetailers({ Future<WalaPlusRetailersResponse?> getWalaPlusRetailers({
String? categoryId, String? categoryId,
int page = 1, int page = 1,
int perPage = 10, int perPage = 10,
String? geoLocation, String? geoLocation,
String? offerType,
BuildContext? context, BuildContext? context,
String? mobileNumber, String? mobileNumber,
}) async { }) async {
@ -216,6 +270,9 @@ class OffersAndDiscountsApiClient {
postParams["MemberType"] = ApiConsts.isDependetLogin ? 2 : 1; postParams["MemberType"] = ApiConsts.isDependetLogin ? 2 : 1;
postParams["CompanyID"] = 1; postParams["CompanyID"] = 1;
postParams["WP_CategoryID"] = effectiveCatId; postParams["WP_CategoryID"] = effectiveCatId;
if (offerType != null && offerType.trim().isNotEmpty) {
postParams["WP_Offer_Type"] = offerType.trim();
}
postParams["WP_Page"] = page; postParams["WP_Page"] = page;
postParams["WP_Per_page"] = perPage; postParams["WP_Per_page"] = perPage;
@ -227,11 +284,7 @@ class OffersAndDiscountsApiClient {
return await ApiClient().postJsonForObject( return await ApiClient().postJsonForObject(
(response) { (response) {
if (response != null) { if (response != null) {
dynamic val = response['WalaPlus_Retailers'] ?? dynamic val = response['WalaPlus_Retailers'] ?? response['walaPlus_Retailers'] ?? response['WalaPlusRetailers'] ?? response['WP_Retailers'] ?? response['result'];
response['walaPlus_Retailers'] ??
response['WalaPlusRetailers'] ??
response['WP_Retailers'] ??
response['result'];
if (val is String) { if (val is String) {
try { try {
val = json.decode(val); val = json.decode(val);
@ -262,11 +315,7 @@ class OffersAndDiscountsApiClient {
); );
} }
Future<WalaPlusRetailerModel?> getWalaPlusRetailerById({ Future<WalaPlusRetailerModel?> getWalaPlusRetailerById({required String retailerId, BuildContext? context, String? mobileNumber}) async {
required String retailerId,
BuildContext? context,
String? mobileNumber,
}) async {
String url = ApiConsts.walaPlusRetailersByID; String url = ApiConsts.walaPlusRetailersByID;
String pUserName = _resolveUserName(); String pUserName = _resolveUserName();
String pMobileNumber = _resolveMobileNumber(overrideMobile: mobileNumber); String pMobileNumber = _resolveMobileNumber(overrideMobile: mobileNumber);
@ -283,6 +332,20 @@ class OffersAndDiscountsApiClient {
} }
postParams["MemberType"] = ApiConsts.isDependetLogin ? 2 : 1; postParams["MemberType"] = ApiConsts.isDependetLogin ? 2 : 1;
postParams["CompanyID"] = 1; postParams["CompanyID"] = 1;
if (context != null) {
try {
Position? position = await _getCurrentPositionSilently(context);
log("context position: $position");
if (position != null) {
postParams["WP_Geo_Location"] = "${position.latitude},${position.longitude}";
}
} catch (e) {
debugPrint("getWalaPlusRetailerById: unable to get current location: $e");
}
}
_cleanWalaPlusParams(postParams); _cleanWalaPlusParams(postParams);
debugPrint("getWalaPlusRetailerById: calling $url with WP_RetailerID: $retailerId"); debugPrint("getWalaPlusRetailerById: calling $url with WP_RetailerID: $retailerId");
@ -291,11 +354,7 @@ class OffersAndDiscountsApiClient {
(response) { (response) {
if (response != null) { if (response != null) {
debugPrint("getWalaPlusRetailerById response keys: ${response is Map ? response.keys.toList() : 'non-map'}"); debugPrint("getWalaPlusRetailerById response keys: ${response is Map ? response.keys.toList() : 'non-map'}");
dynamic val = response['WalaPlus_RetailersByID'] ?? dynamic val = response['WalaPlus_RetailersByID'] ?? response['walaPlus_RetailersByID'] ?? response['WalaPlusRetailersByID'] ?? response['WP_RetailersByID'] ?? response['result'];
response['walaPlus_RetailersByID'] ??
response['WalaPlusRetailersByID'] ??
response['WP_RetailersByID'] ??
response['result'];
if (val is String) { if (val is String) {
try { try {
val = json.decode(val); val = json.decode(val);
@ -324,9 +383,7 @@ class OffersAndDiscountsApiClient {
} }
if ((model?.locations == null || model!.locations!.isEmpty) && if ((model?.locations == null || model!.locations!.isEmpty) &&
(map.containsKey('locations') || map.containsKey('Locations') || map.containsKey('location') || map.containsKey('Location'))) { (map.containsKey('locations') || map.containsKey('Locations') || map.containsKey('location') || map.containsKey('Location'))) {
model?.locations = WalaPlusRetailerModel.parseLocationsList( model?.locations = WalaPlusRetailerModel.parseLocationsList(map['locations'] ?? map['Locations'] ?? map['location'] ?? map['Location']);
map['locations'] ?? map['Locations'] ?? map['location'] ?? map['Location'],
);
} }
} else if (response is Map<String, dynamic> && response.containsKey('name')) { } else if (response is Map<String, dynamic> && response.containsKey('name')) {
model = WalaPlusRetailerModel.fromJson(response); model = WalaPlusRetailerModel.fromJson(response);
@ -339,9 +396,7 @@ class OffersAndDiscountsApiClient {
} }
if ((model.locations == null || model.locations!.isEmpty) && if ((model.locations == null || model.locations!.isEmpty) &&
(response.containsKey('locations') || response.containsKey('Locations') || response.containsKey('location') || response.containsKey('Location'))) { (response.containsKey('locations') || response.containsKey('Locations') || response.containsKey('location') || response.containsKey('Location'))) {
model.locations = WalaPlusRetailerModel.parseLocationsList( model.locations = WalaPlusRetailerModel.parseLocationsList(response['locations'] ?? response['Locations'] ?? response['location'] ?? response['Location']);
response['locations'] ?? response['Locations'] ?? response['location'] ?? response['Location'],
);
} }
} }
debugPrint("getWalaPlusRetailerById: parsed retailer '${model.name}', offers: ${model.offers?.length ?? 0}, locations: ${model.locations?.length ?? 0}"); debugPrint("getWalaPlusRetailerById: parsed retailer '${model.name}', offers: ${model.offers?.length ?? 0}, locations: ${model.locations?.length ?? 0}");
@ -370,12 +425,7 @@ class OffersAndDiscountsApiClient {
return ""; return "";
} }
Future<Map<String, dynamic>?> redeemWalaPlusOffer({ Future<Map<String, dynamic>?> redeemWalaPlusOffer({required String offerId, String? offerType, String? userReference, BuildContext? context}) async {
required String offerId,
String? offerType,
String? userReference,
BuildContext? context,
}) async {
String url = ApiConsts.walaPlusOfferRedeem; String url = ApiConsts.walaPlusOfferRedeem;
String pUserName = _resolveUserName(); String pUserName = _resolveUserName();
String pUserReference = _resolveUserReference(overrideUserReference: userReference); String pUserReference = _resolveUserReference(overrideUserReference: userReference);
@ -405,10 +455,7 @@ class OffersAndDiscountsApiClient {
(response) { (response) {
if (response != null) { if (response != null) {
debugPrint("redeemWalaPlusOffer response: $response"); debugPrint("redeemWalaPlusOffer response: $response");
dynamic val = response['WalaPlus_OfferRedeem'] ?? dynamic val = response['WalaPlus_OfferRedeem'] ?? response['walaPlus_OfferRedeem'] ?? response['WalaPlusOfferRedeem'] ?? response['result'];
response['walaPlus_OfferRedeem'] ??
response['WalaPlusOfferRedeem'] ??
response['result'];
if (val is String) { if (val is String) {
try { try {
val = json.decode(val); val = json.decode(val);

@ -1,5 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'package:mohem_flutter_app/api/api_client.dart'; import 'package:mohem_flutter_app/api/api_client.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart';
@ -35,99 +36,140 @@ class ProfileApiClient {
factory ProfileApiClient() => _instance; factory ProfileApiClient() => _instance;
Future<List<GetEmployeeContactsList>> getEmployeeContacts() async { // GET_EMP_BUSINESS_CARD_INFO requires the literal TokenID below to validate the call -
String url = "${ApiConsts.erpRest}GET_EMPLOYEE_CONTACTS"; // it is not the usual session TokenID, so we don't merge AppState().postParamsJson here.
Future<GenericResponseModel?> getEmployeeBusinessCardInfo() async {
String url = "${ApiConsts.erpRest}GET_EMP_BUSINESS_CARD_INFO";
String deviceToken = AppState().getIsHuawei ? AppState().getHuaweiPushToken : (AppState().getDeviceToken ?? "");
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {
"P_MENU_TYPE": "E", "VersionID": AppState().postParamsObject?.versionID,
"P_SELECTED_RESP_ID": -999, "Channel": AppState().postParamsObject?.channel,
"LanguageID": AppState().postParamsObject?.languageID,
"TokenID": "GET_EMP_BUSINESS_CARD_INFO",
"P_USER_NAME": AppState().getUserName ?? AppState().postParamsObject?.userName ?? AppState().postParamsObject?.pUserName,
"DeviceToken": deviceToken,
"DeviceType": Platform.isAndroid ? "android" : "ios",
}; };
print(jsonEncode(postParams));
return await ApiClient().postJsonForObject(
(json) {
return GenericResponseModel.fromJson(json);
},
url,
postParams,
);
}
Future<List<GetEmployeeContactsList>> getEmployeeContacts() async {
String url = "${ApiConsts.erpRest}GET_EMPLOYEE_CONTACTS";
Map<String, dynamic> postParams = {"P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": -999};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.getEmployeeContactsList ?? []; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.getEmployeeContactsList ?? [];
},
url,
postParams,
);
} }
Future<List<GetEmployeeBasicDetailsList>> getEmployeeBasicDetails() async { Future<List<GetEmployeeBasicDetailsList>> getEmployeeBasicDetails() async {
String url = "${ApiConsts.erpRest}GET_EMPLOYEE_BASIC_DETAILS"; String url = "${ApiConsts.erpRest}GET_EMPLOYEE_BASIC_DETAILS";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {"P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": -999};
"P_MENU_TYPE": "E",
"P_SELECTED_RESP_ID": -999,
};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.getEmployeeBasicDetailsList ?? []; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.getEmployeeBasicDetailsList ?? [];
},
url,
postParams,
);
} }
Future<List<GetEmployeePhonesList>> getEmployeePhones() async { Future<List<GetEmployeePhonesList>> getEmployeePhones() async {
String url = "${ApiConsts.erpRest}GET_EMPLOYEE_PHONES"; String url = "${ApiConsts.erpRest}GET_EMPLOYEE_PHONES";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {"P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": -999};
"P_MENU_TYPE": "E",
"P_SELECTED_RESP_ID": -999,
};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.getEmployeePhonesList ?? []; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.getEmployeePhonesList ?? [];
},
url,
postParams,
);
} }
Future<List<GetEmployeeAddressList>> getEmployeeAddress() async { Future<List<GetEmployeeAddressList>> getEmployeeAddress() async {
String url = "${ApiConsts.erpRest}GET_EMPLOYEE_ADDRESS"; String url = "${ApiConsts.erpRest}GET_EMPLOYEE_ADDRESS";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {"P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": -999};
"P_MENU_TYPE": "E",
"P_SELECTED_RESP_ID": -999,
};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.getEmployeeAddressList ?? []; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.getEmployeeAddressList ?? [];
},
url,
postParams,
);
} }
Future<List<EmployeeDocumentsList>> getEmployeeDocuments() async { Future<List<EmployeeDocumentsList>> getEmployeeDocuments() async {
String url = "${ApiConsts.erpRest}GET_EMPLOYEE_DOCUMENTS"; String url = "${ApiConsts.erpRest}GET_EMPLOYEE_DOCUMENTS";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {"P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": -999};
"P_MENU_TYPE": "E",
"P_SELECTED_RESP_ID": -999,
};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.employeeDocumentsList ?? []; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.employeeDocumentsList ?? [];
},
url,
postParams,
);
} }
Future updateEmpImage(img) async { Future updateEmpImage(img) async {
String url = "${ApiConsts.erpRest}UPDATE_EMPLOYEE_IMAGE"; String url = "${ApiConsts.erpRest}UPDATE_EMPLOYEE_IMAGE";
Map<String, dynamic> postParams = {"P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": -999, "P_IMAGE": img}; Map<String, dynamic> postParams = {"P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": -999, "P_IMAGE": img};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
// GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return json['UpdateEmployeeImageList']; // GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return json['UpdateEmployeeImageList'];
},
url,
postParams,
);
} }
Future<GenericResponseModel> getDffStructure(String pFunctionName, String uRL, String requestType) async { Future<GenericResponseModel> getDffStructure(String pFunctionName, String uRL, String requestType) async {
String url = ApiConsts.erpRest + uRL; String url = ApiConsts.erpRest + uRL;
Map<String, dynamic> postParams = {"P_SELECTED_RESP_ID": -999, "P_MENU_TYPE": "E", "P_REQUEST_TYPE": pFunctionName, "P_FUNCTION_NAME": pFunctionName, "P_COUNTRY_CODE": "SA"}; Map<String, dynamic> postParams = {"P_SELECTED_RESP_ID": -999, "P_MENU_TYPE": "E", "P_REQUEST_TYPE": pFunctionName, "P_FUNCTION_NAME": pFunctionName, "P_COUNTRY_CODE": "SA"};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData;
},
url,
postParams,
);
} }
Future<GenericResponseModel> getColStructure(String pFunctionName, String uRL, String requestType) async { Future<GenericResponseModel> getColStructure(String pFunctionName, String uRL, String requestType) async {
String url = ApiConsts.erpRest + uRL; String url = ApiConsts.erpRest + uRL;
Map<String, dynamic> postParams = {"P_SELECTED_RESP_ID": -999, "P_MENU_TYPE": "E", "P_FUNCTION_NAME": pFunctionName, "P_REQUEST_TYPE": requestType}; Map<String, dynamic> postParams = {"P_SELECTED_RESP_ID": -999, "P_MENU_TYPE": "E", "P_FUNCTION_NAME": pFunctionName, "P_REQUEST_TYPE": requestType};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData;
},
url,
postParams,
);
} }
Future<ESERVICESVS> getValueSetValues(String pSegmentName, String pDescFlexContextCode, String pDescFlexName, List<Map<String, dynamic>> list) async { Future<ESERVICESVS> getValueSetValues(String pSegmentName, String pDescFlexContextCode, String pDescFlexName, List<Map<String, dynamic>> list) async {
@ -144,41 +186,38 @@ class ProfileApiClient {
"GetValueSetValuesTBL": list, "GetValueSetValuesTBL": list,
}; };
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.getValueSetValuesList!.first; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.getValueSetValuesList!.first;
},
url,
postParams,
);
} }
Future<List<GetPhoneNumberTypesModel>> getPhoneNumberTypes() async { Future<List<GetPhoneNumberTypesModel>> getPhoneNumberTypes() async {
String url = "${ApiConsts.erpRest}GET_OBJECT_VALUES"; String url = "${ApiConsts.erpRest}GET_OBJECT_VALUES";
Map<String, dynamic> postParams = {"P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": -999, "P_OBJECT_NAME": "PHONE_TYPE", "P_OBJECT_TYPE": "LOOKUP"}; Map<String, dynamic> postParams = {"P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": -999, "P_OBJECT_NAME": "PHONE_TYPE", "P_OBJECT_TYPE": "LOOKUP"};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.getObjectValuesList ?? []; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.getObjectValuesList ?? [];
},
url,
postParams,
);
} }
Future<SubmitContactTransactionList?> submetConatctTransaction( Future<SubmitContactTransactionList?> submetConatctTransaction(String pFunctionName, String actionType, int contactRelationId, String date) async {
String pFunctionName,
String actionType,
int contactRelationId,
String date,
) async {
String url = "${ApiConsts.erpRest}SUBMIT_CONTACT_TRANSACTION"; String url = "${ApiConsts.erpRest}SUBMIT_CONTACT_TRANSACTION";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {
"P_MENU_TYPE": "E", "P_MENU_TYPE": "E",
"P_SELECTED_RESP_ID": -999, "P_SELECTED_RESP_ID": -999,
"P_FUNCTION_NAME": pFunctionName, "P_FUNCTION_NAME": pFunctionName,
"EITTransactionTBL": [ "EITTransactionTBL": [
{ {"TRANSACTION_NUMBER": 1, "NAME": "DATE_END", "VARCHAR2_VALUE": null, "NUMBER_VALUE": null, "DATE_VALUE": date},
"TRANSACTION_NUMBER": 1,
"NAME": "DATE_END",
"VARCHAR2_VALUE": null,
"NUMBER_VALUE": null,
"DATE_VALUE": date,
}
], ],
"P_CONTACT_RELATIONSHIP_ID": contactRelationId, "P_CONTACT_RELATIONSHIP_ID": contactRelationId,
"P_ACTION": actionType, "P_ACTION": actionType,
@ -186,28 +225,29 @@ class ProfileApiClient {
"LegislationCodeStr": "SA", "LegislationCodeStr": "SA",
}; };
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.submitContactTransactionList; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.submitContactTransactionList;
},
url,
postParams,
);
} }
Future<GetApprovesList?> getApproves(String action, String comments, int transactionId, String itemKey) async { Future<GetApprovesList?> getApproves(String action, String comments, int transactionId, String itemKey) async {
String url = "${ApiConsts.erpRest}GET_APPROVERS_LIST"; String url = "${ApiConsts.erpRest}GET_APPROVERS_LIST";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {"P_AME_TRANSACTION_TYPE": "SSHRMS", "P_PAGE_LIMIT": 1000, "P_PAGE_NUM": 1, "P_TRANSACTION_ID": transactionId, "P_ACTION_MODE": action, "P_COMMENTS": comments};
"P_AME_TRANSACTION_TYPE": "SSHRMS",
"P_PAGE_LIMIT": 1000,
"P_PAGE_NUM": 1,
"P_TRANSACTION_ID": transactionId,
"P_ACTION_MODE": action,
"P_COMMENTS": comments,
};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
// return responseData.getApprovesList; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
return (responseData.getApprovesList?.length ?? 0) > 0 ? responseData.getApprovesList!.first : null; // return responseData.getApprovesList;
}, url, postParams); return (responseData.getApprovesList?.length ?? 0) > 0 ? responseData.getApprovesList!.first : null;
},
url,
postParams,
);
} }
Future<SubmitPhonesTransactionList> submitPhoneNumbers(List<GetEmployeePhonesList> empList) async { Future<SubmitPhonesTransactionList> submitPhoneNumbers(List<GetEmployeePhonesList> empList) async {
@ -216,50 +256,49 @@ class ProfileApiClient {
"P_MENU_TYPE": "E", "P_MENU_TYPE": "E",
"P_SELECTED_RESP_ID": -999, "P_SELECTED_RESP_ID": -999,
"P_FUNCTION_NAME": "HR_PERINFO_SS", "P_FUNCTION_NAME": "HR_PERINFO_SS",
"P_MBL_PHONES_TBL": empList.map((element) { "P_MBL_PHONES_TBL":
return element.toJson(); empList.map((element) {
}).toList() return element.toJson();
}).toList(),
}; };
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return SubmitPhonesTransactionList.fromJson(responseData.submitPhonesTransactionList ?? {}); GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return SubmitPhonesTransactionList.fromJson(responseData.submitPhonesTransactionList ?? {});
},
url,
postParams,
);
} }
Future<StartPhoneApprovalProcess?> startPhoneApprovalProcess(String action, String comments, String itemKey, int transactionId) async { Future<StartPhoneApprovalProcess?> startPhoneApprovalProcess(String action, String comments, String itemKey, int transactionId) async {
String url = "${ApiConsts.erpRest}START_PHONES_APPROVAL_PROCESS"; String url = "${ApiConsts.erpRest}START_PHONES_APPROVAL_PROCESS";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {"P_SELECTED_RESP_ID": -999, "P_MENU_TYPE": "E", "P_ACTION_MODE": action, "P_COMMENTS": comments, "P_ITEM_KEY": itemKey, "P_TRANSACTION_ID": transactionId};
"P_SELECTED_RESP_ID": -999,
"P_MENU_TYPE": "E",
"P_ACTION_MODE": action,
"P_COMMENTS": comments,
"P_ITEM_KEY": itemKey,
"P_TRANSACTION_ID": transactionId,
};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.startPhonesApprovalProcessList; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.startPhonesApprovalProcessList;
},
url,
postParams,
);
} }
Future<StartAddressApprovalProcess?> startAddressApprovalProcess(String action, String comments, String itemKey, int transactionId) async { Future<StartAddressApprovalProcess?> startAddressApprovalProcess(String action, String comments, String itemKey, int transactionId) async {
String url = "${ApiConsts.erpRest}START_ADDRESS_APPROVAL_PROCESS"; String url = "${ApiConsts.erpRest}START_ADDRESS_APPROVAL_PROCESS";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {"P_SELECTED_RESP_ID": -999, "P_MENU_TYPE": "E", "P_ACTION_MODE": action, "P_COMMENTS": comments, "P_ITEM_KEY": itemKey, "P_TRANSACTION_ID": transactionId};
"P_SELECTED_RESP_ID": -999,
"P_MENU_TYPE": "E",
"P_ACTION_MODE": action,
"P_COMMENTS": comments,
"P_ITEM_KEY": itemKey,
"P_TRANSACTION_ID": transactionId,
};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.startAddressApprovalProcessList; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.startAddressApprovalProcessList;
},
url,
postParams,
);
} }
Future<SubmitBasicDetailsTransactionList> submitBasicDetailsTransaction(String pDescFlexContextCode, String pFunctionName, List<Map<String, dynamic>> list, int correctOrNew) async { Future<SubmitBasicDetailsTransactionList> submitBasicDetailsTransaction(String pDescFlexContextCode, String pFunctionName, List<Map<String, dynamic>> list, int correctOrNew) async {
@ -275,31 +314,38 @@ class ProfileApiClient {
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
postParams["EITTransactionTBL"] = list; postParams["EITTransactionTBL"] = list;
postParams["EITTransactionTBLModel"] = list; postParams["EITTransactionTBLModel"] = list;
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.submitBasicDetTransactionList!; //ESERVICESDV.fromJson(responseData.getDefaultValueList!.toJson()); GenericResponseModel responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.submitBasicDetTransactionList!; //ESERVICESDV.fromJson(responseData.getDefaultValueList!.toJson());
},
url,
postParams,
);
} }
Future<StartAddressApprovalProcess?> startBasicDetailsApprovalProcess(String action, String comments, String itemKey, int transactionId) async { Future<StartAddressApprovalProcess?> startBasicDetailsApprovalProcess(String action, String comments, String itemKey, int transactionId) async {
String url = "${ApiConsts.erpRest}START_BASIC_DET_APPR_PROCESS"; String url = "${ApiConsts.erpRest}START_BASIC_DET_APPR_PROCESS";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {"P_SELECTED_RESP_ID": -999, "P_MENU_TYPE": "E", "P_ACTION_MODE": action, "P_COMMENTS": comments, "P_ITEM_KEY": itemKey, "P_TRANSACTION_ID": transactionId};
"P_SELECTED_RESP_ID": -999,
"P_MENU_TYPE": "E",
"P_ACTION_MODE": action,
"P_COMMENTS": comments,
"P_ITEM_KEY": itemKey,
"P_TRANSACTION_ID": transactionId,
};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.startAddressApprovalProcessList; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.startAddressApprovalProcessList;
},
url,
postParams,
);
} }
Future<SubmitAddressTransaction> submitAddressTransaction( Future<SubmitAddressTransaction> submitAddressTransaction(
String pDescFlexContextCode, String pFunctionName, List<Map<String, dynamic>> list, int correctOrNew, String countryCode, String effectiveDate) async { String pDescFlexContextCode,
String pFunctionName,
List<Map<String, dynamic>> list,
int correctOrNew,
String countryCode,
String effectiveDate,
) async {
String url = "${ApiConsts.erpRest}SUBMIT_ADDRESS_TRANSACTION"; String url = "${ApiConsts.erpRest}SUBMIT_ADDRESS_TRANSACTION";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {
"P_SELECTED_RESP_ID": -999, "P_SELECTED_RESP_ID": -999,
@ -316,23 +362,28 @@ class ProfileApiClient {
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
postParams["EITTransactionTBL"] = list; postParams["EITTransactionTBL"] = list;
// postParams["EITTransactionTBLModel"] = list; // postParams["EITTransactionTBLModel"] = list;
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.submitAddressTransactionList!; //ESERVICESDV.fromJson(responseData.getDefaultValueList!.toJson()); GenericResponseModel responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.submitAddressTransactionList!; //ESERVICESDV.fromJson(responseData.getDefaultValueList!.toJson());
},
url,
postParams,
);
} }
Future<List<GetCountriesListModel>> getCountriesList() async { Future<List<GetCountriesListModel>> getCountriesList() async {
String url = "${ApiConsts.erpRest}GET_COUNTRIES"; String url = "${ApiConsts.erpRest}GET_COUNTRIES";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {"P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": -999};
"P_MENU_TYPE": "E",
"P_SELECTED_RESP_ID": -999,
};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.getCountriesList ?? []; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.getCountriesList ?? [];
},
url,
postParams,
);
} }
// add & update family member // add & update family member
@ -340,73 +391,75 @@ class ProfileApiClient {
String url = "${ApiConsts.erpRest}GET_BASIC_DET_DFF_STRUCTURE"; String url = "${ApiConsts.erpRest}GET_BASIC_DET_DFF_STRUCTURE";
Map<String, dynamic> postParams = {"P_FUNCTION_NAME": "HR_PERINFO_SS", "P_MENU_TYPE": "E", "P_REQUEST_TYPE": "CONTACT", "P_SELECTED_RESP_ID": -999}; Map<String, dynamic> postParams = {"P_FUNCTION_NAME": "HR_PERINFO_SS", "P_MENU_TYPE": "E", "P_REQUEST_TYPE": "CONTACT", "P_SELECTED_RESP_ID": -999};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.getBasicDetDffStructureList ?? []; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.getBasicDetDffStructureList ?? [];
},
url,
postParams,
);
} }
// add & update family member // add & update family member
Future<List<GetContactColsStructureList>> getContactColsStructureList(String actionType) async { Future<List<GetContactColsStructureList>> getContactColsStructureList(String actionType) async {
String url = "${ApiConsts.erpRest}GET_CONTACT_COLS_STRUCTURE"; String url = "${ApiConsts.erpRest}GET_CONTACT_COLS_STRUCTURE";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {"P_ACTION": actionType, "P_FUNCTION_NAME": "HR_PERINFO_SS"};
"P_ACTION": actionType,
"P_FUNCTION_NAME": "HR_PERINFO_SS",
};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.getContactColsStructureList ?? []; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.getContactColsStructureList ?? [];
},
url,
postParams,
);
} }
// update family member // update family member
Future<List<GetContactDetailsList>> getContactDetailsList(int contactRelationId) async { Future<List<GetContactDetailsList>> getContactDetailsList(int contactRelationId) async {
String url = "${ApiConsts.erpRest}GET_CONTACT_DETAILS"; String url = "${ApiConsts.erpRest}GET_CONTACT_DETAILS";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {"P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": -999, "P_CONTACT_RELATIONSHIP_ID": contactRelationId};
"P_MENU_TYPE": "E",
"P_SELECTED_RESP_ID": -999,
"P_CONTACT_RELATIONSHIP_ID": contactRelationId,
};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.getContactDetailsList ?? []; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.getContactDetailsList ?? [];
},
url,
postParams,
);
} }
// add & update family member // add & update family member
Future<List<GetContactDffStructureList>> getContactDffStructureList() async { Future<List<GetContactDffStructureList>> getContactDffStructureList() async {
String url = "${ApiConsts.erpRest}GET_CONTACT_DFF_STRUCTURE"; String url = "${ApiConsts.erpRest}GET_CONTACT_DFF_STRUCTURE";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {"P_DESC_FLEX_CONTEXT_CODE": "HMG_ADD_CONTACT_DETAILS", "P_FUNCTION_NAME": "HR_PERINFO_SS", "P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": -999};
"P_DESC_FLEX_CONTEXT_CODE": "HMG_ADD_CONTACT_DETAILS",
"P_FUNCTION_NAME": "HR_PERINFO_SS",
"P_MENU_TYPE": "E",
"P_SELECTED_RESP_ID": -999,
};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.getContactDffStructureList ?? []; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.getContactDffStructureList ?? [];
},
url,
postParams,
);
} }
Future<SubmitContactTransactionList?> submitContactTransactionAddAndUpdate(String actionType, relationId, List<Map<String, dynamic>> list) async { Future<SubmitContactTransactionList?> submitContactTransactionAddAndUpdate(String actionType, relationId, List<Map<String, dynamic>> list) async {
String url = "${ApiConsts.erpRest}SUBMIT_CONTACT_TRANSACTION"; String url = "${ApiConsts.erpRest}SUBMIT_CONTACT_TRANSACTION";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {"P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": -999, "P_FUNCTION_NAME": "HR_PERINFO_SS", "P_ACTION": actionType, "P_CONTACT_RELATIONSHIP_ID": relationId};
"P_MENU_TYPE": "E",
"P_SELECTED_RESP_ID": -999,
"P_FUNCTION_NAME": "HR_PERINFO_SS",
"P_ACTION": actionType,
"P_CONTACT_RELATIONSHIP_ID": relationId,
};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
postParams["EITTransactionTBL"] = list; postParams["EITTransactionTBL"] = list;
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.submitContactTransactionList; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.submitContactTransactionList;
},
url,
postParams,
);
} }
Future<List<GetPerformanceAppraisalList>> getPerformanceAppraisal() async { Future<List<GetPerformanceAppraisalList>> getPerformanceAppraisal() async {
@ -414,55 +467,48 @@ class ProfileApiClient {
Map<String, dynamic> postParams = {}; Map<String, dynamic> postParams = {};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); (json) {
return responseData.getPerformanceAppraisalList ?? []; GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
}, url, postParams); return responseData.getPerformanceAppraisalList ?? [];
},
url,
postParams,
);
} }
Future<PatientInfoModel?> getPatientInfo({ Future<PatientInfoModel?> getPatientInfo({required String nationalId, required String dob, String? logInTokenID}) async {
required String nationalId,
required String dob,
String? logInTokenID,
}) async {
// NHIC Service GetPatientInfo only works on Production (hmgwebservices.com) // NHIC Service GetPatientInfo only works on Production (hmgwebservices.com)
// String url = "https://hmgwebservices.com/Services/NHIC.svc/REST/GetPatientInfo"; // String url = "https://hmgwebservices.com/Services/NHIC.svc/REST/GetPatientInfo";
String url = "${ApiConsts.erpRest}GetMemberInfo"; String url = "${ApiConsts.erpRest}GetMemberInfo";
String token = logInTokenID ?? String token = logInTokenID ?? AppState().postParamsObject?.logInTokenID ?? "";
AppState().postParamsObject?.logInTokenID ??
"";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {
"PatientIdentificationID": int.tryParse(nationalId.trim()) ?? nationalId.trim(), "PatientIdentificationID": int.tryParse(nationalId.trim()) ?? nationalId.trim(),
"PatientOutSA": 0, "PatientOutSA": 0,
"DOB": dob.trim(), "DOB": dob.trim(),
"LogInTokenID": token, "LogInTokenID": token,
"PatientMobileNumber":AppState().postParamsObject?.mobileNumber, // added this as per e-services changed "PatientMobileNumber": AppState().postParamsObject?.mobileNumber, // added this as per e-services changed
"TokenID":AppState().postParamsObject?.tokenID,// added this as per e-services changed "TokenID": AppState().postParamsObject?.tokenID, // added this as per e-services changed
"LanguageID":AppState().postParamsObject?.languageID,// added this as per e-services changed "LanguageID": AppState().postParamsObject?.languageID, // added this as per e-services changed
"Channel":AppState().postParamsObject?.channel, "Channel": AppState().postParamsObject?.channel,
"VersionID": AppState().postParamsObject?.versionID, "VersionID": AppState().postParamsObject?.versionID,
"UserName":AppState().postParamsObject?.userName "UserName": AppState().postParamsObject?.userName,
}; };
print(jsonEncode(postParams)); print(jsonEncode(postParams));
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
return PatientInfoModel.fromJson(json); (json) {
}, url, postParams); return PatientInfoModel.fromJson(json);
},
url,
postParams,
);
} }
Future<GenericResponseModel?> processContactMazayaAccess({ Future<GenericResponseModel?> processContactMazayaAccess({required String accessAction, int? contactRelationshipId, int? contactPersonId, int? personId}) async {
required String accessAction,
int? contactRelationshipId,
int? contactPersonId,
int? personId,
}) async {
String url = "${ApiConsts.erpRest}PROCESS_CONTACT_MAZAYA_ACCESS"; String url = "${ApiConsts.erpRest}PROCESS_CONTACT_MAZAYA_ACCESS";
String action = accessAction.trim().toLowerCase() == "revoke" ? "Revoke" : "Grant"; String action = accessAction.trim().toLowerCase() == "revoke" ? "Revoke" : "Grant";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {"P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": -999, "P_ACCESS_ACTION": action};
"P_MENU_TYPE": "E",
"P_SELECTED_RESP_ID": -999,
"P_ACCESS_ACTION": action,
};
if (contactRelationshipId != null) { if (contactRelationshipId != null) {
postParams["P_CONTACT_RELATIONSHIP_ID"] = contactRelationshipId; postParams["P_CONTACT_RELATIONSHIP_ID"] = contactRelationshipId;
} }
@ -473,8 +519,12 @@ class ProfileApiClient {
postParams["P_PERSON_ID"] = personId; postParams["P_PERSON_ID"] = personId;
} }
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject(
return GenericResponseModel.fromJson(json); (json) {
}, url, postParams); return GenericResponseModel.fromJson(json);
},
url,
postParams,
);
} }
} }

@ -90,6 +90,8 @@ class ApiConsts {
//DummyCards for the UI //DummyCards for the UI
static int tabletMinLength = 500; static int tabletMinLength = 500;
// Notification Center GUIDs for OTP // Notification Center GUIDs for OTP

@ -405,6 +405,9 @@ class GenericResponseModel {
dynamic getWalaplusDepInfoModelInternal; dynamic getWalaplusDepInfoModelInternal;
List<WalaPlusCategoryModel>? walaPlusCategories; List<WalaPlusCategoryModel>? walaPlusCategories;
String? businessCardQROutside;
EmpBusinessCardInfoModel? empBusinessCardInfoModel;
GenericResponseModel({ GenericResponseModel({
this.date, this.date,
this.languageID, this.languageID,
@ -680,6 +683,8 @@ class GenericResponseModel {
this.getWalaplusDepInfoModel, this.getWalaplusDepInfoModel,
this.getWalaplusDepInfoModelInternal, this.getWalaplusDepInfoModelInternal,
this.walaPlusCategories, this.walaPlusCategories,
this.businessCardQROutside,
this.empBusinessCardInfoModel,
}); });
GenericResponseModel.fromJson(Map<String, dynamic> json) { GenericResponseModel.fromJson(Map<String, dynamic> json) {
@ -1478,6 +1483,9 @@ class GenericResponseModel {
getWalaplusDepInfoModel = json['GET_WALAPLUS_DEP_INFO_Model'] != null ? GetWalaplusDepInfoModel.fromJson(json['GET_WALAPLUS_DEP_INFO_Model']) : null; getWalaplusDepInfoModel = json['GET_WALAPLUS_DEP_INFO_Model'] != null ? GetWalaplusDepInfoModel.fromJson(json['GET_WALAPLUS_DEP_INFO_Model']) : null;
getWalaplusDepInfoModelInternal = json['GET_WALAPLUS_DEP_INFO_Model_Internal']; getWalaplusDepInfoModelInternal = json['GET_WALAPLUS_DEP_INFO_Model_Internal'];
businessCardQROutside = json['BusinessCardQR_Outside'];
empBusinessCardInfoModel = json['GET_EMP_BUSINESS_CARD_INFO_Model'] != null ? EmpBusinessCardInfoModel.fromJson(json['GET_EMP_BUSINESS_CARD_INFO_Model']) : null;
if (json['WalaPlus_Categories'] != null) { if (json['WalaPlus_Categories'] != null) {
walaPlusCategories = <WalaPlusCategoryModel>[]; walaPlusCategories = <WalaPlusCategoryModel>[];
json['WalaPlus_Categories'].forEach((v) { json['WalaPlus_Categories'].forEach((v) {
@ -1976,6 +1984,11 @@ class GenericResponseModel {
data['GET_WALAPLUS_DEP_INFO_Model'] = this.getWalaplusDepInfoModel!.toJson(); data['GET_WALAPLUS_DEP_INFO_Model'] = this.getWalaplusDepInfoModel!.toJson();
} }
data['BusinessCardQR_Outside'] = this.businessCardQROutside;
if (this.empBusinessCardInfoModel != null) {
data['GET_EMP_BUSINESS_CARD_INFO_Model'] = this.empBusinessCardInfoModel!.toJson();
}
if (walaPlusCategories != null) { if (walaPlusCategories != null) {
data['WalaPlus_Categories'] = walaPlusCategories!.map((WalaPlusCategoryModel v) => v.toJson()).toList(); data['WalaPlus_Categories'] = walaPlusCategories!.map((WalaPlusCategoryModel v) => v.toJson()).toList();
} }
@ -2011,21 +2024,41 @@ class GetWalaplusDepInfoModel {
String? pEmpMobileNumber; String? pEmpMobileNumber;
String? pDependentName; String? pDependentName;
GetWalaplusDepInfoModel({ GetWalaplusDepInfoModel({this.pEmpEmailAddress, this.pEmpMobileNumber, this.pDependentName});
this.pEmpEmailAddress,
this.pEmpMobileNumber, factory GetWalaplusDepInfoModel.fromJson(Map<String, dynamic> json) =>
this.pDependentName, GetWalaplusDepInfoModel(pEmpEmailAddress: json["P_EMP_EMAIL_ADDRESS"], pEmpMobileNumber: json["P_EMP_MOBILE_NUMBER"], pDependentName: json["P_DEPENDENT_NAME"]);
});
Map<String, dynamic> toJson() => {"P_EMP_EMAIL_ADDRESS": pEmpEmailAddress, "P_EMP_MOBILE_NUMBER": pEmpMobileNumber, "P_DEPENDENT_NAME": pDependentName};
}
class EmpBusinessCardInfoModel {
String? pEmailAddress;
String? pFirstName;
String? pLastName;
String? pMobilePhoneNumber;
String? pPositionTitle;
String? pWorkExtensionNumber;
EmpBusinessCardInfoModel({this.pEmailAddress, this.pFirstName, this.pLastName, this.pMobilePhoneNumber, this.pPositionTitle, this.pWorkExtensionNumber});
String get fullName => [pFirstName, pLastName].where((e) => e != null && e.trim().isNotEmpty).join(" ");
factory GetWalaplusDepInfoModel.fromJson(Map<String, dynamic> json) => GetWalaplusDepInfoModel( factory EmpBusinessCardInfoModel.fromJson(Map<String, dynamic> json) => EmpBusinessCardInfoModel(
pEmpEmailAddress: json["P_EMP_EMAIL_ADDRESS"], pEmailAddress: json["P_EMAIL_ADDRESS"],
pEmpMobileNumber: json["P_EMP_MOBILE_NUMBER"], pFirstName: json["P_FIRST_NAME"],
pDependentName: json["P_DEPENDENT_NAME"], pLastName: json["P_LAST_NAME"],
); pMobilePhoneNumber: json["P_MOBILE_PHONE_NUMBER"],
pPositionTitle: json["P_POSITION_TITLE"],
pWorkExtensionNumber: json["P_WORK_EXTENSION_NUMBER"],
);
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"P_EMP_EMAIL_ADDRESS": pEmpEmailAddress, "P_EMAIL_ADDRESS": pEmailAddress,
"P_EMP_MOBILE_NUMBER": pEmpMobileNumber, "P_FIRST_NAME": pFirstName,
"P_DEPENDENT_NAME": pDependentName, "P_LAST_NAME": pLastName,
}; "P_MOBILE_PHONE_NUMBER": pMobilePhoneNumber,
"P_POSITION_TITLE": pPositionTitle,
"P_WORK_EXTENSION_NUMBER": pWorkExtensionNumber,
};
} }

@ -9,12 +9,7 @@ class WalaPlusRetailersResponse {
int? perPage; int? perPage;
List<WalaPlusRetailerModel>? retailers; List<WalaPlusRetailerModel>? retailers;
WalaPlusRetailersResponse({ WalaPlusRetailersResponse({this.page, this.pagesCount, this.perPage, this.retailers});
this.page,
this.pagesCount,
this.perPage,
this.retailers,
});
factory WalaPlusRetailersResponse.fromJson(Map<String, dynamic> json) { factory WalaPlusRetailersResponse.fromJson(Map<String, dynamic> json) {
List<WalaPlusRetailerModel> retailersList = []; List<WalaPlusRetailerModel> retailersList = [];
@ -35,21 +30,15 @@ class WalaPlusRetailersResponse {
} }
return WalaPlusRetailersResponse( return WalaPlusRetailersResponse(
page: json['page'] is int page: json['page'] is int ? json['page'] : int.tryParse(json['page']?.toString() ?? json['WP_Page']?.toString() ?? '1'),
? json['page'] pagesCount: json['pages_count'] is int ? json['pages_count'] : int.tryParse(json['pages_count']?.toString() ?? json['pagesCount']?.toString() ?? json['totalPages']?.toString() ?? '1'),
: int.tryParse(json['page']?.toString() ?? json['WP_Page']?.toString() ?? '1'), perPage: json['per_page'] is int ? json['per_page'] : int.tryParse(json['per_page']?.toString() ?? json['perPage']?.toString() ?? json['WP_Per_page']?.toString() ?? '10'),
pagesCount: json['pages_count'] is int
? json['pages_count']
: int.tryParse(json['pages_count']?.toString() ?? json['pagesCount']?.toString() ?? json['totalPages']?.toString() ?? '1'),
perPage: json['per_page'] is int
? json['per_page']
: int.tryParse(json['per_page']?.toString() ?? json['perPage']?.toString() ?? json['WP_Per_page']?.toString() ?? '10'),
retailers: retailersList, retailers: retailersList,
); );
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
Map<String, dynamic> data = <String, dynamic>{}; Map<String, dynamic> data = <String, dynamic>{};
data['page'] = page; data['page'] = page;
data['pages_count'] = pagesCount; data['pages_count'] = pagesCount;
data['per_page'] = perPage; data['per_page'] = perPage;
@ -68,22 +57,11 @@ class WalaPlusRetailersByIDResponse {
List<WalaPlusOfferModel>? offers; List<WalaPlusOfferModel>? offers;
List<WalaPlusRetailerModel>? retailer; List<WalaPlusRetailerModel>? retailer;
WalaPlusRetailersByIDResponse({ WalaPlusRetailersByIDResponse({this.page, this.pagesCount, this.perPage, this.locations, this.offers, this.retailer});
this.page,
this.pagesCount,
this.perPage,
this.locations,
this.offers,
this.retailer,
});
factory WalaPlusRetailersByIDResponse.fromJson(Map<String, dynamic> json) { factory WalaPlusRetailersByIDResponse.fromJson(Map<String, dynamic> json) {
List<WalaPlusRetailerLocation> locList = WalaPlusRetailerModel.parseLocationsList( List<WalaPlusRetailerLocation> locList = WalaPlusRetailerModel.parseLocationsList(json['locations'] ?? json['Locations'] ?? json['location'] ?? json['Location']);
json['locations'] ?? json['Locations'] ?? json['location'] ?? json['Location'], List<WalaPlusOfferModel> offList = WalaPlusRetailerModel.parseOffersList(json['offers'] ?? json['Offers']);
);
List<WalaPlusOfferModel> offList = WalaPlusRetailerModel.parseOffersList(
json['offers'] ?? json['Offers'],
);
List<WalaPlusRetailerModel> retList = []; List<WalaPlusRetailerModel> retList = [];
dynamic retData = json['retailer'] ?? json['Retailer']; dynamic retData = json['retailer'] ?? json['Retailer'];
@ -109,15 +87,9 @@ class WalaPlusRetailersByIDResponse {
} }
return WalaPlusRetailersByIDResponse( return WalaPlusRetailersByIDResponse(
page: json['page'] is int page: json['page'] is int ? json['page'] : int.tryParse(json['page']?.toString() ?? json['WP_Page']?.toString() ?? ''),
? json['page'] pagesCount: json['pages_count'] is int ? json['pages_count'] : int.tryParse(json['pages_count']?.toString() ?? json['pagesCount']?.toString() ?? ''),
: int.tryParse(json['page']?.toString() ?? json['WP_Page']?.toString() ?? ''), perPage: json['per_page'] is int ? json['per_page'] : int.tryParse(json['per_page']?.toString() ?? json['perPage']?.toString() ?? ''),
pagesCount: json['pages_count'] is int
? json['pages_count']
: int.tryParse(json['pages_count']?.toString() ?? json['pagesCount']?.toString() ?? ''),
perPage: json['per_page'] is int
? json['per_page']
: int.tryParse(json['per_page']?.toString() ?? json['perPage']?.toString() ?? ''),
locations: locList, locations: locList,
offers: offList, offers: offList,
retailer: retList, retailer: retList,
@ -289,9 +261,7 @@ class WalaPlusRetailerModel {
} }
List<WalaPlusOfferModel> offersList = parseOffersList(offersSource ?? targetJson['offers'] ?? targetJson['Offers']); List<WalaPlusOfferModel> offersList = parseOffersList(offersSource ?? targetJson['offers'] ?? targetJson['Offers']);
List<WalaPlusRetailerLocation> locationsList = parseLocationsList( List<WalaPlusRetailerLocation> locationsList = parseLocationsList(locationsSource ?? targetJson['locations'] ?? targetJson['Locations'] ?? targetJson['location'] ?? targetJson['Location']);
locationsSource ?? targetJson['locations'] ?? targetJson['Locations'] ?? targetJson['location'] ?? targetJson['Location'],
);
List<WalaPlusCategoryModel> categoriesList = []; List<WalaPlusCategoryModel> categoriesList = [];
if (targetJson['categories'] != null && targetJson['categories'] is List) { if (targetJson['categories'] != null && targetJson['categories'] is List) {
@ -309,7 +279,8 @@ class WalaPlusRetailerModel {
} }
} }
String? foundValidity = targetJson['validity']?.toString() ?? String? foundValidity =
targetJson['validity']?.toString() ??
targetJson['valid_to']?.toString() ?? targetJson['valid_to']?.toString() ??
targetJson['valid_until']?.toString() ?? targetJson['valid_until']?.toString() ??
targetJson['end_date']?.toString() ?? targetJson['end_date']?.toString() ??
@ -323,9 +294,7 @@ class WalaPlusRetailerModel {
if (foundValidity == null || foundValidity == "null" || foundValidity.trim().isEmpty) { if (foundValidity == null || foundValidity == "null" || foundValidity.trim().isEmpty) {
for (var entry in targetJson.entries) { for (var entry in targetJson.entries) {
String k = entry.key.toLowerCase(); String k = entry.key.toLowerCase();
if ((k.contains('valid') || k.contains('expir') || k.contains('duration')) && if ((k.contains('valid') || k.contains('expir') || k.contains('duration')) && !k.contains('isverificationcodevalid') && !k.contains('barcode')) {
!k.contains('isverificationcodevalid') &&
!k.contains('barcode')) {
if (entry.value != null && entry.value.toString().trim().isNotEmpty && entry.value.toString() != "null") { if (entry.value != null && entry.value.toString().trim().isNotEmpty && entry.value.toString() != "null") {
foundValidity = entry.value.toString().trim(); foundValidity = entry.value.toString().trim();
break; break;
@ -335,7 +304,8 @@ class WalaPlusRetailerModel {
} }
return WalaPlusRetailerModel( return WalaPlusRetailerModel(
id: targetJson['id']?.toString() ?? id:
targetJson['id']?.toString() ??
targetJson['WP_RetailerID']?.toString() ?? targetJson['WP_RetailerID']?.toString() ??
targetJson['retailer_id']?.toString() ?? targetJson['retailer_id']?.toString() ??
targetJson['RetailerID']?.toString() ?? targetJson['RetailerID']?.toString() ??
@ -388,10 +358,7 @@ class WalaPlusRetailerModel {
} }
} }
s = s s = s.replaceAll(r'\/', '/').replaceAll(r'\"', '"').replaceAll(r"\'", "'");
.replaceAll(r'\/', '/')
.replaceAll(r'\"', '"')
.replaceAll(r"\'", "'");
s = s.replaceAllMapped(RegExp(r'\\u([0-9a-fA-F]{4})'), (match) { s = s.replaceAllMapped(RegExp(r'\\u([0-9a-fA-F]{4})'), (match) {
try { try {
@ -600,10 +567,7 @@ class WalaPlusRetailerModel {
} }
if (locations != null && locations!.isNotEmpty) { if (locations != null && locations!.isNotEmpty) {
for (var loc in locations!) { for (var loc in locations!) {
if (loc.contact != null && if (loc.contact != null && loc.contact!.trim().isNotEmpty && loc.contact != "null" && !loc.contact!.contains('@')) {
loc.contact!.trim().isNotEmpty &&
loc.contact != "null" &&
!loc.contact!.contains('@')) {
return loc.contact!.trim(); return loc.contact!.trim();
} }
} }
@ -619,11 +583,12 @@ class WalaPlusRetailerModel {
bool get isOnlineStore => (type?.trim().toLowerCase() == 'online'); bool get isOnlineStore => (type?.trim().toLowerCase() == 'online');
bool get isInstore => (type?.trim().toLowerCase() == 'instore' || bool get isInstore =>
type?.trim().toLowerCase() == 'in_store' || (type?.trim().toLowerCase() == 'instore' ||
type?.trim().toLowerCase() == 'in store' || type?.trim().toLowerCase() == 'in_store' ||
type?.trim().toLowerCase() == 'store' || type?.trim().toLowerCase() == 'in store' ||
(type == null && locations != null && locations!.isNotEmpty)); type?.trim().toLowerCase() == 'store' ||
(type == null && locations != null && locations!.isNotEmpty));
String? get normalizedType { String? get normalizedType {
if (type != null && type!.trim().isNotEmpty) { if (type != null && type!.trim().isNotEmpty) {
@ -659,16 +624,7 @@ class WalaPlusRetailerContact {
String? instagram; String? instagram;
String? twitter; String? twitter;
WalaPlusRetailerContact({ WalaPlusRetailerContact({this.email, this.emails, this.phone, this.phones, this.website, this.address, this.instagram, this.twitter});
this.email,
this.emails,
this.phone,
this.phones,
this.website,
this.address,
this.instagram,
this.twitter,
});
factory WalaPlusRetailerContact.fromJson(Map<String, dynamic> json) { factory WalaPlusRetailerContact.fromJson(Map<String, dynamic> json) {
List<String> emailsList = []; List<String> emailsList = [];
@ -706,16 +662,7 @@ class WalaPlusRetailerContact {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return { return {'email': email, 'emails': emails, 'phone': phone, 'phones': phones, 'website': website, 'address': address, 'instagram': instagram, 'twitter': twitter};
'email': email,
'emails': emails,
'phone': phone,
'phones': phones,
'website': website,
'address': address,
'instagram': instagram,
'twitter': twitter,
};
} }
String? get primaryEmail { String? get primaryEmail {
@ -748,6 +695,7 @@ class WalaPlusRetailerLocation {
String? contact; String? contact;
String? countryNameAr; String? countryNameAr;
String? countryNameEn; String? countryNameEn;
String? distance;
double? latitude; double? latitude;
double? longitude; double? longitude;
dynamic placeId; dynamic placeId;
@ -761,6 +709,7 @@ class WalaPlusRetailerLocation {
this.contact, this.contact,
this.countryNameAr, this.countryNameAr,
this.countryNameEn, this.countryNameEn,
this.distance,
this.latitude, this.latitude,
this.longitude, this.longitude,
this.placeId, this.placeId,
@ -776,6 +725,7 @@ class WalaPlusRetailerLocation {
contact: json['contact']?.toString(), contact: json['contact']?.toString(),
countryNameAr: WalaPlusRetailerModel.decodeUnicodeString(json['country_name_ar']), countryNameAr: WalaPlusRetailerModel.decodeUnicodeString(json['country_name_ar']),
countryNameEn: WalaPlusRetailerModel.decodeUnicodeString(json['country_name_en']), countryNameEn: WalaPlusRetailerModel.decodeUnicodeString(json['country_name_en']),
distance: WalaPlusRetailerModel.decodeUnicodeString(json['distance']),
latitude: json['latitude'] is num ? (json['latitude'] as num).toDouble() : double.tryParse(json['latitude']?.toString() ?? ''), latitude: json['latitude'] is num ? (json['latitude'] as num).toDouble() : double.tryParse(json['latitude']?.toString() ?? ''),
longitude: json['longitude'] is num ? (json['longitude'] as num).toDouble() : double.tryParse(json['longitude']?.toString() ?? ''), longitude: json['longitude'] is num ? (json['longitude'] as num).toDouble() : double.tryParse(json['longitude']?.toString() ?? ''),
placeId: json['place_id'], placeId: json['place_id'],
@ -792,6 +742,7 @@ class WalaPlusRetailerLocation {
data['contact'] = contact; data['contact'] = contact;
data['country_name_ar'] = countryNameAr; data['country_name_ar'] = countryNameAr;
data['country_name_en'] = countryNameEn; data['country_name_en'] = countryNameEn;
data['distance'] = distance;
data['latitude'] = latitude; data['latitude'] = latitude;
data['longitude'] = longitude; data['longitude'] = longitude;
data['place_id'] = placeId; data['place_id'] = placeId;
@ -840,18 +791,7 @@ class WalaPlusOfferModel {
dynamic usage; dynamic usage;
String? expiredAt; String? expiredAt;
WalaPlusOfferModel({ WalaPlusOfferModel({this.id, this.retailerId, this.title, this.image, this.imageThumb, this.type, this.description, this.price, this.usage, this.expiredAt});
this.id,
this.retailerId,
this.title,
this.image,
this.imageThumb,
this.type,
this.description,
this.price,
this.usage,
this.expiredAt,
});
factory WalaPlusOfferModel.fromJson(Map<String, dynamic> json) { factory WalaPlusOfferModel.fromJson(Map<String, dynamic> json) {
return WalaPlusOfferModel( return WalaPlusOfferModel(

@ -1,15 +1,18 @@
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/colors.dart';
import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/classes/utils.dart';
import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart';
import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
import 'package:mohem_flutter_app/models/generic_response_model.dart';
class BusinessCardDialog extends StatelessWidget { class BusinessCardDialog extends StatelessWidget {
const BusinessCardDialog({Key? key}) : super(key: key); final String? qrBase64;
final EmpBusinessCardInfoModel? employeeInfo;
const BusinessCardDialog({Key? key, this.qrBase64, this.employeeInfo}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -40,7 +43,7 @@ class BusinessCardDialog extends StatelessWidget {
), ),
), ),
Image.memory( Image.memory(
Utils.getPostBytes(AppState().memberInformationList!.businessCardQR ?? ""), Utils.getPostBytes(qrBase64 ?? ""),
width: 129, width: 129,
height: 129, height: 129,
), ),
@ -50,28 +53,25 @@ class BusinessCardDialog extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
(AppState().memberInformationList!.eMPLOYEENAME ?? "").toText23(isBold: true).paddingOnly(top: 15), (employeeInfo?.fullName ?? "").toText23(isBold: true).paddingOnly(top: 15),
(AppState().memberInformationList!.getPositionName() ?? "").toText17( (employeeInfo?.pPositionTitle ?? "").toText17(
color: MyColors.grey57Color, color: MyColors.grey57Color,
), ),
30.height, 30.height,
// (AppState().memberInformationList!.eMPLOYEENUMBER ?? "").toText13(),
Row( Row(
children: [ children: [
const Icon(Icons.email, size: 17.5, color: MyColors.grey3AColor).paddingOnly(right: 11.5), const Icon(Icons.email, size: 17.5, color: MyColors.grey3AColor).paddingOnly(right: 11.5),
("${LocaleKeys.email.tr()}: ").toText18(color: MyColors.grey57Color), ("${LocaleKeys.email.tr()}: ").toText18(color: MyColors.grey57Color),
(AppState().memberInformationList!.eMPLOYEEEMAILADDRESS ?? "").toText18(), (employeeInfo?.pEmailAddress ?? "").toText18(),
], ],
), ),
Row( Row(
children: [ children: [
const Icon(Icons.call, size: 17.5, color: MyColors.grey3AColor).paddingOnly(right: 11.5), const Icon(Icons.call, size: 17.5, color: MyColors.grey3AColor).paddingOnly(right: 11.5),
("${LocaleKeys.mobile.tr()}: ").toText18(color: MyColors.grey57Color), ("${LocaleKeys.mobile.tr()}: ").toText18(color: MyColors.grey57Color),
(AppState().memberInformationList!.mobileNumberWithZipCode ?? "").toText18(), (employeeInfo?.pMobilePhoneNumber ?? "").toText18(),
], ],
), ),
// 1.height,
// (AppState().memberInformationList!.jOBNAME ?? "").toText13(),
], ],
), ),
], ],

@ -12,6 +12,7 @@ import 'package:mohem_flutter_app/config/routes.dart';
import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart';
import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
import 'package:mohem_flutter_app/main.dart';
import 'package:mohem_flutter_app/models/offers_and_discounts/wala_plus_category_model.dart'; import 'package:mohem_flutter_app/models/offers_and_discounts/wala_plus_category_model.dart';
import 'package:mohem_flutter_app/models/offers_and_discounts/wala_plus_retailer_model.dart'; import 'package:mohem_flutter_app/models/offers_and_discounts/wala_plus_retailer_model.dart';
import 'package:mohem_flutter_app/widgets/info_chip_widget.dart'; import 'package:mohem_flutter_app/widgets/info_chip_widget.dart';
@ -239,12 +240,14 @@ class _DashboardScreenForDependetState extends State<DashboardScreenForDependet>
try { try {
String catParam = (targetCategoryId == "all" || targetCategoryId == "0") ? "" : targetCategoryId; String catParam = (targetCategoryId == "all" || targetCategoryId == "0") ? "" : targetCategoryId;
print("Fetching WalaPlus retailers: category='$catParam', page=1, per_page=$pageSize"); String? offerTypeParam = OffersAndDiscountsApiClient.mapOfferTypeFilter(selectedTypeFilter);
print("Fetching WalaPlus retailers: category='$catParam', offerType='$offerTypeParam', page=1, per_page=$pageSize");
WalaPlusRetailersResponse? response = await OffersAndDiscountsApiClient().getWalaPlusRetailers( WalaPlusRetailersResponse? response = await OffersAndDiscountsApiClient().getWalaPlusRetailers(
categoryId: catParam, categoryId: catParam,
page: 1, page: 1,
perPage: pageSize, perPage: pageSize,
geoLocation: isNearestOffers ? "24.9485,46.977" : null, geoLocation: isNearestOffers ? "24.9485,46.977" : null,
offerType: offerTypeParam,
context: context, context: context,
); );
@ -278,14 +281,16 @@ class _DashboardScreenForDependetState extends State<DashboardScreenForDependet>
try { try {
int nextPage = currentPage + 1; int nextPage = currentPage + 1;
String catParam = (currentCategoryId == "all" || currentCategoryId == "0") ? "" : currentCategoryId; String catParam = (currentCategoryId == "all" || currentCategoryId == "0") ? "" : currentCategoryId;
String? offerTypeParam = OffersAndDiscountsApiClient.mapOfferTypeFilter(selectedTypeFilter);
print("Fetching WalaPlus retailers next page: $nextPage of $totalPages, category: '$catParam'"); print("Fetching WalaPlus retailers next page: $nextPage of $totalPages, category: '$catParam', offerType: '$offerTypeParam'");
WalaPlusRetailersResponse? response = await OffersAndDiscountsApiClient().getWalaPlusRetailers( WalaPlusRetailersResponse? response = await OffersAndDiscountsApiClient().getWalaPlusRetailers(
categoryId: catParam, categoryId: catParam,
page: nextPage, page: nextPage,
perPage: pageSize, perPage: pageSize,
geoLocation: isNearestOffers ? "24.9485,46.977" : null, geoLocation: isNearestOffers ? "24.9485,46.977" : null,
offerType: offerTypeParam,
context: context, context: context,
); );
@ -319,22 +324,10 @@ class _DashboardScreenForDependetState extends State<DashboardScreenForDependet>
if (query != null) { if (query != null) {
searchQuery = query; searchQuery = query;
} }
// Type filtering (online/in store) is done server-side via WP_Offer_Type (see fetchOffers),
// so retailersList already reflects the selected type - only search is applied locally here.
List<WalaPlusRetailerModel> temp = retailersList; List<WalaPlusRetailerModel> temp = retailersList;
if (selectedTypeFilter != "all" && selectedTypeFilter.isNotEmpty) {
temp =
temp.where((WalaPlusRetailerModel item) {
String? norm = item.normalizedType;
if (selectedTypeFilter == "online") {
return norm == "online";
} else if (selectedTypeFilter == "instore") {
return norm == "instore";
} else {
return norm == selectedTypeFilter || (item.type?.trim().toLowerCase() == selectedTypeFilter);
}
}).toList();
}
if (searchQuery.trim().isNotEmpty) { if (searchQuery.trim().isNotEmpty) {
String q = searchQuery.trim().toLowerCase(); String q = searchQuery.trim().toLowerCase();
temp = temp =
@ -472,7 +465,7 @@ class _DashboardScreenForDependetState extends State<DashboardScreenForDependet>
GridView.builder( GridView.builder(
shrinkWrap: true, shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 0.85, crossAxisSpacing: 12, mainAxisSpacing: 16), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: isTablet ? 4 : 2, childAspectRatio: 0.7, crossAxisSpacing: 12, mainAxisSpacing: 16),
itemCount: _filteredRetailersList.length, itemCount: _filteredRetailersList.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
return _buildOfferCard(_filteredRetailersList[index], isAr); return _buildOfferCard(_filteredRetailersList[index], isAr);
@ -603,7 +596,7 @@ class _DashboardScreenForDependetState extends State<DashboardScreenForDependet>
setState(() { setState(() {
selectedTypeFilter = typeKey; selectedTypeFilter = typeKey;
}); });
_runFilter(); fetchOffers(categoryId: currentCategoryId.isEmpty ? "all" : currentCategoryId);
} }
}, },
child: Container( child: Container(
@ -908,7 +901,7 @@ class _DashboardScreenForDependetState extends State<DashboardScreenForDependet>
child: GridView.builder( child: GridView.builder(
shrinkWrap: true, shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 0.72, crossAxisSpacing: 12, mainAxisSpacing: 16), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: isTablet ? 4 : 2, childAspectRatio: 0.7, crossAxisSpacing: 12, mainAxisSpacing: 16),
itemCount: 4, itemCount: 4,
itemBuilder: (_, __) { itemBuilder: (_, __) {
return Container( return Container(

@ -142,7 +142,7 @@ class _WalaPlusRetailerDetailsScreenState extends State<WalaPlusRetailerDetailsS
Future<void> _openInAppBrowser(String url, {String? offerType}) async { Future<void> _openInAppBrowser(String url, {String? offerType}) async {
String title = _retailer?.name ?? LocaleKeys.offerDetails.tr(); String title = _retailer?.name ?? LocaleKeys.offerDetails.tr();
bool shouldStartScanning = offerType?.trim().toLowerCase() == "discount"; bool shouldStartScanning = offerType?.trim().toLowerCase() == "discount";
log("shouldStartScanning: ${shouldStartScanning.toString()} for offerType: ${offerType.toString()}");
await Navigator.push( await Navigator.push(
context, context,
MaterialPageRoute(builder: (BuildContext context) => AppInAppWebViewScreen(url: url, title: title, onPageLoaded: shouldStartScanning ? _clickStartScanningButton : null)), MaterialPageRoute(builder: (BuildContext context) => AppInAppWebViewScreen(url: url, title: title, onPageLoaded: shouldStartScanning ? _clickStartScanningButton : null)),
@ -158,7 +158,7 @@ class _WalaPlusRetailerDetailsScreenState extends State<WalaPlusRetailerDetailsS
source: r""" source: r"""
(function() { (function() {
var attempts = 0; var attempts = 0;
var maxAttempts = 10; // ~0.5s at 50ms var maxAttempts = 50; // ~10s at 200ms - page loads Tailwind from a CDN and mounts Vue, which can take a while on a real network
var timer = setInterval(function() { var timer = setInterval(function() {
attempts++; attempts++;
var buttons = document.querySelectorAll('button'); var buttons = document.querySelectorAll('button');
@ -168,12 +168,12 @@ class _WalaPlusRetailerDetailsScreenState extends State<WalaPlusRetailerDetailsS
buttons[i].click(); buttons[i].click();
clearInterval(timer); clearInterval(timer);
return; return;
} }
} }
if (attempts >= maxAttempts) { if (attempts >= maxAttempts) {
clearInterval(timer); clearInterval(timer);
} }
}, 50); }, 200);
})(); })();
""", """,
); );
@ -839,6 +839,7 @@ class _WalaPlusRetailerDetailsScreenState extends State<WalaPlusRetailerDetailsS
} }
Widget _buildLocationCard(WalaPlusRetailerLocation loc, bool isAr) { Widget _buildLocationCard(WalaPlusRetailerLocation loc, bool isAr) {
String distanceText = (loc.distance != null && loc.distance!.trim().isNotEmpty && loc.distance != "null") ? loc.distance!.trim() : "";
String cityText = loc.getLocalizedCity(isAr); String cityText = loc.getLocalizedCity(isAr);
if (cityText.isEmpty) { if (cityText.isEmpty) {
cityText = loc.city ?? ""; cityText = loc.city ?? "";
@ -846,7 +847,12 @@ class _WalaPlusRetailerDetailsScreenState extends State<WalaPlusRetailerDetailsS
String addressText = loc.address ?? ""; String addressText = loc.address ?? "";
String primaryTitle = addressText.isNotEmpty ? addressText : cityText; String primaryTitle = addressText.isNotEmpty ? addressText : cityText;
String? secondaryText = (addressText.isNotEmpty && cityText.isNotEmpty && addressText.toLowerCase() != cityText.toLowerCase()) ? cityText : null; String? secondaryText;
if (distanceText.isNotEmpty) {
secondaryText = distanceText;
} else if (addressText.isNotEmpty && cityText.isNotEmpty && addressText.toLowerCase() != cityText.toLowerCase()) {
secondaryText = cityText;
}
return Container( return Container(
padding: const EdgeInsets.all(14), padding: const EdgeInsets.all(14),

@ -2,6 +2,7 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:mohem_flutter_app/api/profile_api_client.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/colors.dart';
import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/classes/utils.dart';
@ -11,6 +12,7 @@ import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
import 'package:mohem_flutter_app/models/dashboard/drawer_menu_item_model.dart'; import 'package:mohem_flutter_app/models/dashboard/drawer_menu_item_model.dart';
import 'package:mohem_flutter_app/models/generic_response_model.dart';
import 'package:mohem_flutter_app/provider/chat_provider_model.dart'; import 'package:mohem_flutter_app/provider/chat_provider_model.dart';
import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart';
import 'package:mohem_flutter_app/ui/dialogs/id/business_card_dialog.dart'; import 'package:mohem_flutter_app/ui/dialogs/id/business_card_dialog.dart';
@ -37,6 +39,22 @@ class _AppDrawerState extends State<AppDrawer> {
chatData = Provider.of<ChatProviderModel>(context, listen: false); chatData = Provider.of<ChatProviderModel>(context, listen: false);
} }
Future<void> _showBusinessCard(BuildContext context) async {
Utils.showLoading(context);
try {
GenericResponseModel? response = await ProfileApiClient().getEmployeeBusinessCardInfo();
Utils.hideLoading(context);
showMDialog(
context,
child: BusinessCardDialog(qrBase64: response?.businessCardQROutside, employeeInfo: response?.empBusinessCardInfoModel),
isBusniessCard: true,
);
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (drawerMenuItemList.isEmpty) { if (drawerMenuItemList.isEmpty) {
@ -119,7 +137,7 @@ class _AppDrawerState extends State<AppDrawer> {
}), }),
menuItem("assets/images/drawer/employee_id.svg", LocaleKeys.employeeDigitalID.tr(), "", closeDrawer: false, onPress: () => showMDialog(context, child: EmployeeDigitialIdDialog())), menuItem("assets/images/drawer/employee_id.svg", LocaleKeys.employeeDigitalID.tr(), "", closeDrawer: false, onPress: () => showMDialog(context, child: EmployeeDigitialIdDialog())),
if (AppState().businessCardPrivilege) if (AppState().businessCardPrivilege)
menuItem("assets/images/drawer/view_business_card.svg", LocaleKeys.viewBusinessCard.tr(), "", closeDrawer: false, onPress: () => showMDialog(context, child: BusinessCardDialog(), isBusniessCard: true)), menuItem("assets/images/drawer/view_business_card.svg", LocaleKeys.viewBusinessCard.tr(), "", closeDrawer: false, onPress: () => _showBusinessCard(context)),
menuItem("assets/images/drawer/logout.svg", LocaleKeys.logout.tr(), "", color: MyColors.redA3Color, closeDrawer: false, onPress: (){Utils.performLogout(context, chatData);}), menuItem("assets/images/drawer/logout.svg", LocaleKeys.logout.tr(), "", color: MyColors.redA3Color, closeDrawer: false, onPress: (){Utils.performLogout(context, chatData);}),
// menuItem("assets/images/drawer/logout.svg", LocaleKeys.logout.tr(), "", color: MyColors.redA3Color, closeDrawer: false, onPress: () {Navigator.pushNamed(context, AppRoutes.survey,); // menuItem("assets/images/drawer/logout.svg", LocaleKeys.logout.tr(), "", color: MyColors.redA3Color, closeDrawer: false, onPress: () {Navigator.pushNamed(context, AppRoutes.survey,);
], ],

@ -8,6 +8,7 @@ import 'package:local_auth/local_auth.dart';
import 'package:local_auth_darwin/local_auth_darwin.dart'; import 'package:local_auth_darwin/local_auth_darwin.dart';
import 'package:local_auth_android/local_auth_android.dart'; import 'package:local_auth_android/local_auth_android.dart';
import 'package:mohem_flutter_app/api/login_api_client.dart'; import 'package:mohem_flutter_app/api/login_api_client.dart';
import 'package:mohem_flutter_app/api/profile_api_client.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/colors.dart';
import 'package:mohem_flutter_app/classes/consts.dart'; import 'package:mohem_flutter_app/classes/consts.dart';
@ -70,14 +71,22 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
surfaceTintColor: Colors.transparent, surfaceTintColor: Colors.transparent,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
automaticallyImplyLeading: false, automaticallyImplyLeading: false,
title: (mobileLoginInfoListModel?.businessCardPrivilege ?? false) title:
? LocaleKeys.viewBusinessCard.tr().toText12(color: MyColors.textMixColor, isUnderLine: true).onPress(() { (mobileLoginInfoListModel?.businessCardPrivilege ?? false)
showMDialog(context, child: const BusinessCardDialog()); ? LocaleKeys.viewBusinessCard.tr().toText12(color: MyColors.textMixColor, isUnderLine: true).onPress(() async {
}) Utils.showLoading(context);
: Container(), try {
GenericResponseModel? response = await ProfileApiClient().getEmployeeBusinessCardInfo();
Utils.hideLoading(context);
showMDialog(context, child: BusinessCardDialog(qrBase64: response?.businessCardQROutside, employeeInfo: response?.empBusinessCardInfoModel));
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
})
: Container(),
actions: [ actions: [
Center( Center(
child: LocaleKeys.employeeDigitalID.tr().toText12(color: MyColors.textMixColor, isUnderLine: true).onPress(() { child: LocaleKeys.employeeDigitalID.tr().toText12(color: MyColors.textMixColor, isUnderLine: true).onPress(() {
showMDialog(context, child: EmployeeDigitialIdDialog()); showMDialog(context, child: EmployeeDigitialIdDialog());
}), }),
@ -113,7 +122,10 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [LocaleKeys.lastLoginDetails.tr().toText16(), DateUtil.formatDateToDate(DateUtil.convertStringToDate(mobileLoginInfoListModel!.editedOn ?? DateTime.now().toString()), false).toText12()], children: [
LocaleKeys.lastLoginDetails.tr().toText16(),
DateUtil.formatDateToDate(DateUtil.convertStringToDate(mobileLoginInfoListModel!.editedOn ?? DateTime.now().toString()), false).toText12(),
],
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -208,8 +220,12 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
} }
Future<bool> loginWithFaceIDAndBiometrics() async { Future<bool> loginWithFaceIDAndBiometrics() async {
IOSAuthMessages iosStrings = const IOSAuthMessages(
IOSAuthMessages iosStrings = const IOSAuthMessages(cancelButton: 'cancel', goToSettingsButton: 'settings', goToSettingsDescription: 'Please set up your Touch ID.', lockOut: 'Please reenable your Touch ID'); cancelButton: 'cancel',
goToSettingsButton: 'settings',
goToSettingsDescription: 'Please set up your Touch ID.',
lockOut: 'Please reenable your Touch ID',
);
// IOSAuthMessages iosStrings = const IOSAuthMessages( // IOSAuthMessages iosStrings = const IOSAuthMessages(
// cancelButton: 'cancel', // cancelButton: 'cancel',
@ -220,13 +236,10 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
bool authenticated = false; bool authenticated = false;
try { try {
authenticated = await auth.authenticate(localizedReason: 'Scan your fingerprint to authenticate', options: const AuthenticationOptions( authenticated = await auth.authenticate(
useErrorDialogs: true, stickyAuth: true, biometricOnly: true, localizedReason: 'Scan your fingerprint to authenticate',
), options: const AuthenticationOptions(useErrorDialogs: true, stickyAuth: true, biometricOnly: true),
authMessages: [ authMessages: [iosStrings, const AndroidAuthMessages()],
iosStrings,
const AndroidAuthMessages(),
],
); );
} on PlatformException catch (e) { } on PlatformException catch (e) {
print(e); print(e);
@ -237,60 +250,58 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
} }
Widget _loginOptionButton(String _title, String _icon, int _flag, int? _loginIndex) { Widget _loginOptionButton(String _title, String _icon, int _flag, int? _loginIndex) {
// <<<<<<< HEAD // <<<<<<< HEAD
bool isDisable = false; bool isDisable = false;
if(_flag >= 3 && _flag <= 4) { if (_flag >= 3 && _flag <= 4) {
bool isFaceEnabled = (_flag == 3 && (checkBiometricIsAvailable(BiometricType.face) || bool isFaceEnabled = (_flag == 3 && (checkBiometricIsAvailable(BiometricType.face) || checkBiometricIsAvailable(BiometricType.weak)));
checkBiometricIsAvailable(BiometricType.weak)));
bool isThumbEnabled = bool isThumbEnabled = (_flag == 4 && (checkBiometricIsAvailable(BiometricType.fingerprint) || checkBiometricIsAvailable(BiometricType.strong)));
(_flag == 4 && (checkBiometricIsAvailable(BiometricType.fingerprint) ||
checkBiometricIsAvailable(BiometricType.strong)));
isDisable = !(isFaceEnabled || isThumbEnabled); isDisable = !(isFaceEnabled || isThumbEnabled);
} }
// ======= // =======
// bool isDisable = (_flag == 3 && !checkBiometricIsAvailable(BiometricType.face) || // bool isDisable = (_flag == 3 && !checkBiometricIsAvailable(BiometricType.face) ||
// _flag == 4 && !checkBiometricIsAvailable(BiometricType.fingerprint) && _flag == 4 && !checkBiometricIsAvailable(BiometricType.face)); // _flag == 4 && !checkBiometricIsAvailable(BiometricType.fingerprint) && _flag == 4 && !checkBiometricIsAvailable(BiometricType.face));
// // >>>>>>> master // // >>>>>>> master
return InkWell( return InkWell(
onTap: isDisable onTap:
? null isDisable
: () async { ? null
if (_flag == 0) { : () async {
setState(() { if (_flag == 0) {
// isMoreOption = true; setState(() {
}); // isMoreOption = true;
} else { });
if (_flag == 3 || _flag == 4) { } else {
bool authenticateWithFaceAndTouchID = await loginWithFaceIDAndBiometrics(); if (_flag == 3 || _flag == 4) {
if (!authenticateWithFaceAndTouchID) { bool authenticateWithFaceAndTouchID = await loginWithFaceIDAndBiometrics();
return; if (!authenticateWithFaceAndTouchID) {
} else { return;
if (mobileLoginInfoListModel!.loginType == 3 || mobileLoginInfoListModel!.loginType == 4) {
// bool authenticateWithFaceAndTouchID = await loginWithFaceIDAndBiometrics();
// if (!authenticateWithFaceAndTouchID) {
// return;
// } else {
// performApiCall(_title, _icon, _flag, isDirectLogin: true);
// }
performApiCall(_title, _icon, _flag, _flag, isDirectLogin: true);
} else { } else {
isNeedVerifyWithFaceIDAndBiometrics = true; if (mobileLoginInfoListModel!.loginType == 3 || mobileLoginInfoListModel!.loginType == 4) {
selectedFlag = _flag; // bool authenticateWithFaceAndTouchID = await loginWithFaceIDAndBiometrics();
setState(() { // if (!authenticateWithFaceAndTouchID) {
return; // return;
}); // } else {
// performApiCall(_title, _icon, _flag, isDirectLogin: true);
// }
performApiCall(_title, _icon, _flag, _flag, isDirectLogin: true);
} else {
isNeedVerifyWithFaceIDAndBiometrics = true;
selectedFlag = _flag;
setState(() {
return;
});
}
} }
} else {
if (isNeedVerifyWithFaceIDAndBiometrics)
performApiCall(_title, _icon, selectedFlag, _flag);
else
performApiCall(_title, _icon, _flag, _flag);
} }
} else {
if (isNeedVerifyWithFaceIDAndBiometrics)
performApiCall(_title, _icon, selectedFlag, _flag);
else
performApiCall(_title, _icon, _flag, _flag);
} }
} },
},
child: Container( child: Container(
padding: const EdgeInsets.only(left: 20, right: 20, bottom: 15, top: 28), padding: const EdgeInsets.only(left: 20, right: 20, bottom: 15, top: 28),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -415,15 +426,15 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
} }
} }
// //
// formatDate(date) { // formatDate(date) {
// return date; // return date;
// return DateFormat('MMM dd, yyy, kk:mm').format(date); // return DateFormat('MMM dd, yyy, kk:mm').format(date);
// } // }
// //
// showLoader(bool isTrue) { // showLoader(bool isTrue) {
// setState(() { // setState(() {
// // isLoading = isTrue; // // isLoading = isTrue;
// }); // });
// } // }
} }

Loading…
Cancel
Save