From 030887452da4960450bbd6c30c0ab1e51d84fad8 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 25 Jul 2024 10:40:33 +0300 Subject: [PATCH] generate QR Api added. --- assets/langs/ar-SA.json | 1 + assets/langs/en-US.json | 3 +- lib/api/worklist/worklist_api_client.dart | 31 +++++++++++++---- lib/generated/codegen_loader.g.dart | 4 ++- lib/generated/locale_keys.g.dart | 1 + lib/ui/login/login_screen.dart | 9 ++--- lib/ui/work_list/itg_detail_screen.dart | 41 +++++++++++++++++++++-- 7 files changed, 75 insertions(+), 15 deletions(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 8f127f2..c59641b 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -97,6 +97,7 @@ "reject": "يرفض", "approve": "يوافق", "cancel": "إلغاء", + "generate": "يولد", "requestedItems": "العناصر المطلوبة", "request": "طلب", "myRequest": "طلبي", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index eec20d4..275864f 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -93,6 +93,7 @@ "whatsapp": "Whatsapp", "reject": "Reject", "approve": "Approve", + "generate": "Generate", "cancel": "Cancel", "requestedItems": "Requested Items", "request": "Request", @@ -547,7 +548,7 @@ "manageGroup": "Manage Group", "admin": "Admin", "addUsers": "Add users to the group", - "editGroups":"Edit Group", + "editGroups": "Edit Group", "groupNameshouldbe": "Group name should be minimum 10 character long", "enterGroupName": "Please enter valid group Name", "groupName": "Group Name", diff --git a/lib/api/worklist/worklist_api_client.dart b/lib/api/worklist/worklist_api_client.dart index d2389ab..732ed06 100644 --- a/lib/api/worklist/worklist_api_client.dart +++ b/lib/api/worklist/worklist_api_client.dart @@ -380,7 +380,7 @@ class WorkListApiClient { }, url, postParams); } - Future rejectITGRequest(String requestType, taskId, itemId, String employeeNumber, String comments) async { + Future rejectITGRequest(String requestType, taskId, itemId, String employeeNumber, String comments) async { String url = "${ApiConsts.cocRest}ITGRejectRequest"; Map postParams = { "RequestType": requestType, @@ -396,7 +396,7 @@ class WorkListApiClient { }, url, postParams); } - Future approveITGRequest(String requestType, taskId, itemId, String employeeNumber, String comments) async { + Future approveITGRequest(String requestType, taskId, itemId, String employeeNumber, String comments) async { String url = "${ApiConsts.cocRest}ITGApproveRequest"; Map postParams = { "RequestType": requestType, @@ -412,7 +412,7 @@ class WorkListApiClient { }, url, postParams); } - Future delegateITGRequest(String requestType, taskId, itemId, String employeeNumber, String newUserEMPId, String comments) async { + Future delegateITGRequest(String requestType, taskId, itemId, String employeeNumber, String newUserEMPId, String comments) async { String url = "${ApiConsts.cocRest}ITGDelegateRequest"; Map postParams = { "RequestType": requestType, @@ -431,7 +431,7 @@ class WorkListApiClient { // ANSWER = 'Services/COCWS.svc/REST/ITGAnswer'; - Future answerITGRequest(String requestType, taskId, itemId, String employeeNumber, String newUserEMPId, String comments) async { + Future answerITGRequest(String requestType, taskId, itemId, String employeeNumber, String newUserEMPId, String comments) async { String url = "${ApiConsts.cocRest}ITGAnswer"; Map postParams = { "RequestType": requestType, @@ -447,6 +447,25 @@ class WorkListApiClient { }, url, postParams); } + Future requestActionITGRequest(String requestType, taskId, itemId, String employeeNumber, String newUserEMPId, String comments) async { + String url = "${ApiConsts.cocRest}Mohemm_ITG_GenerateQR_RequestAction"; + Map postParams = { + "RequestType": requestType, + "TaskID": taskId, + "ItemIDStr":itemId, + "EmployeeNumber": employeeNumber, + "Comments": comments, + "RequestID": itemId, + "RequestActionId": 3, + "IsQRCodeGenerate": true, + }; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + ItgFormsModel responseData = ItgFormsModel.fromJson(json); + return responseData.itgRequest; + }, url, postParams); + } + Future grantITGRequest(String requestType, int taskId, int itemId, String employeeNumber, String newUserEMPId, String comments) async { String url = "${ApiConsts.cocRest}ITGGrantAccess"; Map postParams = { @@ -465,7 +484,7 @@ class WorkListApiClient { }, url, postParams); } - Future informationITGRequest(String requestType, taskId, itemId, String employeeNumber, String newUserEMPId, String comments) async { + Future informationITGRequest(String requestType, taskId, itemId, String employeeNumber, String newUserEMPId, String comments) async { String url = "${ApiConsts.cocRest}ITGRequestInformation"; Map postParams = { "RequestType": requestType, @@ -581,8 +600,6 @@ class WorkListApiClient { }, url, postParams); } - - Future?> getFavoriteReplacementWithoutImage() async { String url = "${ApiConsts.erpRest}Mohemm_GetFavoriteReplacementsWithoutImage"; Map postParams = {}; diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index af972f6..1251dd6 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -551,6 +551,7 @@ class CodegenLoader extends AssetLoader { "uploadedDocuments": "المستندات التي تم تحميلها", "youCannotJoinTheMarathon": "لا يمكنك الانضمام إلى الماراثون لأنك تجاوزت الحد الزمني", "pleaseClickButtonToJoinMarathon": "الرجاء الضغط على الزر أدناه للانضمام إلى الماراثون", + "generate": "يولد", }; static const Map en_US = { "mohemm": "Mohemm", @@ -1107,7 +1108,8 @@ class CodegenLoader extends AssetLoader { "userName": "User Name", "userId": "UserID", "pleaseClickButtonToJoinMarathon": "Press the button below to join the Marathon.", - "youCannotJoinTheMarathon": "You cannot join the Marathon because you have exceeded the time limit." + "youCannotJoinTheMarathon": "You cannot join the Marathon because you have exceeded the time limit.", + "generate": "Generate" }; static const Map> mapLocales = {"ar_SA": ar_SA, "en_US": en_US}; } diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index a6fd43d..cc7f2b4 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -550,4 +550,5 @@ abstract class LocaleKeys { static const pleaseClickButtonToJoinMarathon ='pleaseClickButtonToJoinMarathon'; static const youCannotJoinTheMarathon ='youCannotJoinTheMarathon'; static const open ='open'; + static const generate = 'generate'; } diff --git a/lib/ui/login/login_screen.dart b/lib/ui/login/login_screen.dart index c85ecb7..d4f1644 100644 --- a/lib/ui/login/login_screen.dart +++ b/lib/ui/login/login_screen.dart @@ -8,7 +8,6 @@ import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; - // import 'package:huawei_hmsavailability/huawei_hmsavailability.dart'; import 'package:mohem_flutter_app/api/login_api_client.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; @@ -31,7 +30,6 @@ import 'package:mohem_flutter_app/models/member_login_list_model.dart'; import 'package:mohem_flutter_app/models/privilege_list_model.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; import 'package:mohem_flutter_app/widgets/input_widget.dart'; - // import 'package:safe_device/safe_device.dart'; import 'package:wifi_iot/wifi_iot.dart'; @@ -116,8 +114,11 @@ class _LoginScreenState extends State { print("GOOGLE PLAY STOREEEE!!!!"); await Firebase.initializeApp(); _firebaseMessaging = FirebaseMessaging.instance; - firebaseToken = await _firebaseMessaging.getToken(); - print(firebaseToken); + try { + firebaseToken = await _firebaseMessaging.getToken(); + } catch (ex) { + firebaseToken = ""; + } AppNotifications().init(firebaseToken, context); checkLoginInfo(); await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true); diff --git a/lib/ui/work_list/itg_detail_screen.dart b/lib/ui/work_list/itg_detail_screen.dart index e0c65cc..2aa9490 100644 --- a/lib/ui/work_list/itg_detail_screen.dart +++ b/lib/ui/work_list/itg_detail_screen.dart @@ -45,6 +45,7 @@ class _ItgDetailScreenState extends State { bool isCloseAvailable = false; bool isApproveAvailable = false; bool isRejectAvailable = false; + bool isGenerateAvailable = false; List allowedActionList = []; List itgFormAttachmentsList = []; @@ -76,6 +77,7 @@ class _ItgDetailScreenState extends State { isCloseAvailable = allowedActionList.any((element) => element.action == "CLOSE"); isApproveAvailable = itgRequest!.allowedActions!.any((element) => element.action == "Approve"); isRejectAvailable = itgRequest!.allowedActions!.any((element) => element.action == "Reject"); + isGenerateAvailable = itgRequest!.allowedActions!.any((element) => element.action == "Generate"); } Utils.hideLoading(context); setState(() { @@ -209,6 +211,16 @@ class _ItgDetailScreenState extends State { Color(0xff1BB271), ], ).expanded, + if ((isApproveAvailable ||isRejectAvailable) && isGenerateAvailable) 8.width, + if (isGenerateAvailable) + DefaultButton( + LocaleKeys.generate.tr(), + () => performAction("Generate"), + colors: const [ + Color(0xff28C884), + Color(0xff1BB271), + ], + ).expanded, if (isCloseAvailable) DefaultButton( LocaleKeys.ok.tr(), @@ -279,7 +291,7 @@ class _ItgDetailScreenState extends State { ], ), ), - floatingActionButton: (!isApproveAvailable && !isRejectAvailable && !isCloseAvailable) + floatingActionButton: (!isApproveAvailable && !isRejectAvailable && !isCloseAvailable && !isGenerateAvailable) ? Container( height: 43, width: 43, @@ -300,7 +312,7 @@ class _ItgDetailScreenState extends State { List viewApiButtonsList(List allowedActionList) { List fabs = []; for (int i = 0; i < allowedActionList.length; i++) { - if (allowedActionList[i].action! == "Reject" || allowedActionList[i].action! == "Approve" || allowedActionList[i].action! == "CLOSE") { + if (allowedActionList[i].action! == "Reject" || allowedActionList[i].action! == "Approve" || allowedActionList[i].action! == "CLOSE" || allowedActionList[i].action! == "Generate") { continue; } fabs.add(myFab(getFabActionTitle(allowedActionList[i].action!), getFabActionImages(allowedActionList[i].action!)).paddingOnly(bottom: 12).onPress(() => handleFabAction(allowedActionList[i]))); @@ -487,6 +499,8 @@ class _ItgDetailScreenState extends State { performApproveAction(requestDetails!.requestType!, requestDetails!.iD, requestDetails!.itemID, AppState().memberInformationList?.eMPLOYEENUMBER ?? "", note); } else if (actionMode == "Answer") { performAnswerAction(requestDetails!.requestType!, requestDetails!.iD, requestDetails!.itemID, AppState().memberInformationList?.eMPLOYEENUMBER ?? "", note); + } else if (actionMode == "Generate") { + performGenerateQrAction(requestDetails!.requestType!, requestDetails!.iD, requestDetails!.itemID, AppState().memberInformationList?.eMPLOYEENUMBER ?? "", note); } else { performRejectAction(requestDetails!.requestType!, requestDetails!.iD, requestDetails!.itemID, AppState().memberInformationList?.eMPLOYEENUMBER ?? "", note); } @@ -495,6 +509,29 @@ class _ItgDetailScreenState extends State { ); } + void performGenerateQrAction(String requestType, taskId, itemId, String employeeNumber, String comments) async { + try { + Utils.showLoading(context); + ITGRequest? itgRequest = await WorkListApiClient().requestActionITGRequest(requestType, taskId, itemId, employeeNumber, "", comments); + Utils.hideLoading(context); + Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr()); + // Navigator.pop(context, "delegate_reload"); + AppState().requestAllList!.removeAt(AppState().itgWorkListIndex!); + if (AppState().requestAllList!.isEmpty) { + Navigator.pop(context, "delegate_reload"); + } else { + if (AppState().requestAllList!.length <= AppState().itgWorkListIndex!) { + Navigator.pop(context, "delegate_reload"); + } else { + requestDetails = null; + getDataFromState(); + } + } + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } void performAnswerAction(String requestType, taskId, itemId, String employeeNumber, String comments) async { try { Utils.showLoading(context);