ticket changes moved to dashboard & wallet balance

flutter_upgrade_with_timesheet_changes
aamir-csol 1 month ago
parent 1bcecde59b
commit cca95cee6a

@ -170,6 +170,21 @@ class DashboardApiClient {
); );
} }
Future<GenericResponseModel?> getTicketBalance() async {
String url = "${ApiConsts.erpRest}GET_TICKET_BALANCE";
Map<String, dynamic> postParams = {"P_USER_NAME": AppState().memberInformationList?.eMPLOYEENUMBER};
postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject(
(json) {
GenericResponseModel responseData = GenericResponseModel.fromJson(json);
return responseData;
},
url,
postParams,
);
}
Future<SSOAuthModel?> getBookingSSOAuthRedirection({required String clientID}) async { Future<SSOAuthModel?> getBookingSSOAuthRedirection({required String clientID}) async {
String url = "${ApiConsts.ssoAuthRedirection}?grantType=mohemm"; String url = "${ApiConsts.ssoAuthRedirection}?grantType=mohemm";
//https://sso-uat.hmg.com/api/auth/connect?grantType=mohemm' //https://sso-uat.hmg.com/api/auth/connect?grantType=mohemm'
@ -180,6 +195,7 @@ class DashboardApiClient {
"PersonId": AppState().memberInformationList?.eMPLOYEENUMBER, "PersonId": AppState().memberInformationList?.eMPLOYEENUMBER,
"Username": AppState().memberInformationList?.eMPLOYEENUMBER, "Username": AppState().memberInformationList?.eMPLOYEENUMBER,
"Language": "US", "Language": "US",
"SessionId": AppState().postParamsObject?.pSessionId,
}; };
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject( return await ApiClient().postJsonForObject(
@ -193,7 +209,8 @@ class DashboardApiClient {
} }
Future<dynamic> getBookingSSOFinalRedirection({required String token}) async { Future<dynamic> getBookingSSOFinalRedirection({required String token}) async {
token = "eyJhbGciOiJSUzI1NiIsImtpZCI6IjhjZTE2OWM0YjIwYjQ2ZWM5YTQyOTU3Y2ZhODUzNzQ1IiwidHlwIjoiSldUIn0.eyJ0ZW5hbnRfaWQiOiJhOWY0ZDFhMDU5NmQ0YWVhOGY4MzA5OTJlYzRiZGFjM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ODE1ZmVhIiwibGFuZ3VhZ2UiOiJVUyIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL2VtYWlsYWRkcmVzcyI6IjExNzkzMEBobWcuY29tIiwiZXhwIjoxNzgyNDc1NzY5LCJpc3MiOiJodHRwczovL3Nzby11YXQuaG1nLmNvbSIsImF1ZCI6ImE5ZjRkMWEwNTk2ZDRhZWE4ZjgzMDk5MmVjNGJkYWMxIn0.rJcLVsG8D0XECyLERCTD2uqGeWyvp-OBVGE9uL2qKrX4etFUHgdFt_5kYF6edFTtGy-0PIZadHDmv7e-IOhVWHm5HVMClaukiXoRXR8cDN8XA1wfme3Kd-U5PXN-IRh49AyRTzLO0rYNPvH81ScosWGlsFSkOvA-0hJNa2adHdtvgNvB8wJshSU5p7sAmF8mjdDY6aInG19etu2iEuUDwHHA4ZY_ts4hboHo8fE392hFaYGonExoD7bpW5RMx5xKWeRCmWpG_PK8Aw_z1jGzdB9PANus4pteRGuln1J-kmo2lQC9pVrSyZATAKp1HfgfyZ_vUhaHEfM69cMWaCslJQ";
var request = http.MultipartRequest('POST', Uri.parse('https://ek.techmaster.in/SSO/HMG')); var request = http.MultipartRequest('POST', Uri.parse('https://ek.techmaster.in/SSO/HMG'));
request.fields.addAll({'JWTToken': token}); request.fields.addAll({'JWTToken': token});

@ -48,6 +48,7 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
double get leaveBalance => leaveBalanceAccrual?.accrualNetEntitlement ?? 0; double get leaveBalance => leaveBalanceAccrual?.accrualNetEntitlement ?? 0;
double ticketBalance = 0; double ticketBalance = 0;
double walletBalance = 0;
//Menu Entries //Menu Entries
bool isServicesMenusLoading = true; bool isServicesMenusLoading = true;
@ -202,6 +203,8 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
isLeaveTicketBalanceLoading = false; isLeaveTicketBalanceLoading = false;
leaveBalanceAccrual = accrualList![0]; leaveBalanceAccrual = accrualList![0];
ticketBalance = (accrualList![1].accrualNetEntitlement ?? 0.0) + (accrualList![2].accrualNetEntitlement ?? 0.0) + (accrualList![3].accrualNetEntitlement ?? 0.0); ticketBalance = (accrualList![1].accrualNetEntitlement ?? 0.0) + (accrualList![2].accrualNetEntitlement ?? 0.0) + (accrualList![3].accrualNetEntitlement ?? 0.0);
walletBalance = (accrualList![4].accrualNetEntitlement ?? 0.0);
print("================ Ticket Balance: $ticketBalance ===============");
notifyListeners(); notifyListeners();
} catch (ex) { } catch (ex) {
isLeaveTicketBalanceLoading = false; isLeaveTicketBalanceLoading = false;
@ -286,11 +289,12 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
} }
} }
void fetchTicketBooking() async { Future<void> fetchTicketBooking() async {
try { try {
GenericResponseModel? genericResponseModel = await DashboardApiClient().getTicketBookingRedirection(); GenericResponseModel? genericResponseModel = await DashboardApiClient().getTicketBookingRedirection();
if (genericResponseModel?.portalDirectionData?.pRedirection!.toLowerCase() == "alma") { if (genericResponseModel?.portalDirectionData?.pRedirection!.toLowerCase() == "alma") {
ticketBookingResponse = TicketBookingResult(true, genericResponseModel?.portalDirectionData?.clientID); ticketBookingResponse = TicketBookingResult(true, genericResponseModel?.portalDirectionData?.clientID);
return;
} }
ticketBookingResponse = TicketBookingResult(false, null); ticketBookingResponse = TicketBookingResult(false, null);
} catch (ex) { } catch (ex) {
@ -302,6 +306,20 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
} }
} }
void fetchTicketBalance() async {
try {
GenericResponseModel? ticketResponse = await DashboardApiClient().getTicketBalance();
logger.d("Ticket Balance Response: ${ticketResponse?.toJson()}");
print(" ========= Ticket Balance Response ======= ");
} catch (ex) {
logger.wtf(ex);
isEventLoadingLoading = false;
notifyListeners();
Utils.handleException(ex, null, null);
// ticketBookingResponse = TicketBookingResult(false, null); // Ensure a return value in case of an exception
}
}
Future<SSOAuthModel?> fetchSSOAuthRedirection({String? clientID}) async { Future<SSOAuthModel?> fetchSSOAuthRedirection({String? clientID}) async {
try { try {
SSOAuthModel? ssoResponse = await DashboardApiClient().getBookingSSOAuthRedirection(clientID: clientID!); SSOAuthModel? ssoResponse = await DashboardApiClient().getBookingSSOAuthRedirection(clientID: clientID!);

@ -148,6 +148,7 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
data.fetchAttendanceTracking(context); data.fetchAttendanceTracking(context);
data.fetchWorkListCounter(context); data.fetchWorkListCounter(context);
data.fetchMissingSwipe(context); data.fetchMissingSwipe(context);
data.fetchLeaveTicketBalance(context, DateTime.now()); data.fetchLeaveTicketBalance(context, DateTime.now());
data.fetchMenuEntries(); data.fetchMenuEntries();
data.fetchEventActivity(); data.fetchEventActivity();
@ -160,7 +161,10 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
if (!cProvider.disbaleChatForThisUser && !isFromInit) checkHubCon(); if (!cProvider.disbaleChatForThisUser && !isFromInit) checkHubCon();
_refreshController.refreshCompleted(); _refreshController.refreshCompleted();
data.fetchTicketBooking(); await data.fetchTicketBooking();
// if (data.ticketBookingResponse != null && !data.ticketBookingResponse!.success) {
// // data.fetchTicketBalance();
// }
//continue here //continue here
} }

@ -27,114 +27,99 @@ class MenusWidget extends StatelessWidget {
children: [ children: [
data.isWorkListLoading data.isWorkListLoading
? MenuShimmer().onPress(() { ? MenuShimmer().onPress(() {
data.fetchWorkListCounter(context, showLoading: true); data.fetchWorkListCounter(context, showLoading: true);
}) })
: Container( : Container(
decoration: BoxDecoration( decoration: BoxDecoration(color: Color(namesColor[0]), borderRadius: BorderRadius.circular(10)),
color: Color(namesColor[0]), child: Column(
borderRadius: BorderRadius.circular(10), mainAxisAlignment: MainAxisAlignment.spaceBetween,
), crossAxisAlignment: CrossAxisAlignment.start,
child: Column( children: [
mainAxisAlignment: MainAxisAlignment.spaceBetween, LocaleKeys.workList.tr().toText12(color: Colors.white),
crossAxisAlignment: CrossAxisAlignment.start, Row(
children: [ children: [
LocaleKeys.workList.tr().toText12(color: Colors.white), Expanded(child: data.workListCounter.toString().toText16(color: Colors.white, isBold: true, maxlines: 1)),
Row( RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)),
children: [ ],
Expanded( ),
child: data.workListCounter.toString().toText16(color: Colors.white, isBold: true, maxlines: 1), ],
), ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6),
RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)), ).onPress(() {
], Navigator.pushNamed(context, AppRoutes.workList);
) }),
],
).paddingOnly(left: 10, right: 10, bottom: 6, top: 6),
).onPress(() {
Navigator.pushNamed(context, AppRoutes.workList);
}),
data.isMissingSwipeLoading data.isMissingSwipeLoading
? MenuShimmer().onPress(() { ? MenuShimmer().onPress(() {
data.fetchWorkListCounter(context); data.fetchWorkListCounter(context);
}) })
: Container( : Container(
decoration: BoxDecoration( decoration: BoxDecoration(color: Color(namesColor[1]), borderRadius: BorderRadius.circular(10)),
color: Color(namesColor[1]), child: Column(
borderRadius: BorderRadius.circular(10), mainAxisAlignment: MainAxisAlignment.spaceBetween,
), crossAxisAlignment: CrossAxisAlignment.start,
child: Column( children: [
mainAxisAlignment: MainAxisAlignment.spaceBetween, LocaleKeys.missingSwipes.tr().toText12(color: Colors.white),
crossAxisAlignment: CrossAxisAlignment.start, Row(
children: [ children: [
LocaleKeys.missingSwipes.tr().toText12(color: Colors.white), Expanded(child: data.missingSwipeCounter.toString().toText16(color: Colors.white, isBold: true, maxlines: 1)),
Row( RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)),
children: [ ],
Expanded( ),
child: data.missingSwipeCounter.toString().toText16(color: Colors.white, isBold: true, maxlines: 1), ],
), ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6),
RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)), ).onPress(() {
], Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(LocaleKeys.missingSwipes.tr(), "HMG_OTL_MISSING_SWIPE_EIT_SS"));
) }),
],
).paddingOnly(left: 10, right: 10, bottom: 6, top: 6),
).onPress(() {
Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(LocaleKeys.missingSwipes.tr(), "HMG_OTL_MISSING_SWIPE_EIT_SS"));
}),
data.isLeaveTicketBalanceLoading data.isLeaveTicketBalanceLoading
? MenuShimmer().onPress(() { ? MenuShimmer().onPress(() {
data.fetchWorkListCounter(context); data.fetchWorkListCounter(context);
}) })
: Container( : Container(
decoration: BoxDecoration( decoration: BoxDecoration(color: Color(namesColor[2]), borderRadius: BorderRadius.circular(10)),
color: Color(namesColor[2]), child: Column(
borderRadius: BorderRadius.circular(10), mainAxisAlignment: MainAxisAlignment.spaceBetween,
), crossAxisAlignment: CrossAxisAlignment.start,
child: Column( children: [
mainAxisAlignment: MainAxisAlignment.spaceBetween, LocaleKeys.leaveBalance.tr().toText12(color: Colors.white),
crossAxisAlignment: CrossAxisAlignment.start, Row(
children: [ children: [
LocaleKeys.leaveBalance.tr().toText12(color: Colors.white), Expanded(child: data.leaveBalance.toStringAsFixed(2).toText16(color: Colors.white, isBold: true, maxlines: 1)),
Row( RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)),
children: [ ],
Expanded( ),
child: data.leaveBalance.toStringAsFixed(2).toText16(color: Colors.white, isBold: true, maxlines: 1), ],
), ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6),
RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)), ).onPress(() {
], Navigator.pushNamed(context, AppRoutes.leaveBalance);
) }),
],
).paddingOnly(left: 10, right: 10, bottom: 6, top: 6),
).onPress(() {
Navigator.pushNamed(context, AppRoutes.leaveBalance);
}),
data.isLeaveTicketBalanceLoading data.isLeaveTicketBalanceLoading
? MenuShimmer().onPress(() { ? MenuShimmer().onPress(() {
data.fetchWorkListCounter(context); data.fetchWorkListCounter(context);
}) })
: Container( : Container(
decoration: BoxDecoration( decoration: BoxDecoration(color: Color(namesColor[3]), borderRadius: BorderRadius.circular(10)),
color: Color(namesColor[3]), child: Column(
borderRadius: BorderRadius.circular(10), mainAxisAlignment: MainAxisAlignment.spaceBetween,
), crossAxisAlignment: CrossAxisAlignment.start,
child: Column( children: [
mainAxisAlignment: MainAxisAlignment.spaceBetween, data.ticketBookingResponse != null && data.ticketBookingResponse!.success
crossAxisAlignment: CrossAxisAlignment.start, ? "Wallet Balance".toText12(color: Colors.white)
children: [ : LocaleKeys.ticketBalance.tr().toText12(color: Colors.white),
LocaleKeys.ticketBalance.tr().toText12(color: Colors.white), Row(
Row( children: [
children: [ Expanded(
Expanded( child:
child: data.ticketBalance.toStringAsFixed(2).toText16(color: Colors.white, isBold: true, maxlines: 1), data.ticketBookingResponse != null && data.ticketBookingResponse!.success
), ? data.walletBalance.toStringAsFixed(0).toText16(color: Colors.white, isBold: true, maxlines: 1)
RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)), : data.ticketBalance.toStringAsFixed(2).toText16(color: Colors.white, isBold: true, maxlines: 1),
], ),
) RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)),
], ],
).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), ),
).onPress( ],
() { ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6),
Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(LocaleKeys.ticketBalance.tr(), "HMG_TKT_NEW_EIT_SS")); ).onPress(() {
}, Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(LocaleKeys.ticketBalance.tr(), "HMG_TKT_NEW_EIT_SS"));
) }),
], ],
); );
}, },

@ -255,7 +255,7 @@ class ServicesWidget extends StatelessWidget {
} else { } else {
if (menuEntry.menuName == "HMG_TICKET_REQUESTS") { if (menuEntry.menuName == "HMG_TICKET_REQUESTS") {
Utils.showLoading(context); Utils.showLoading(context);
//Ticket Work //Ticket Work
if (pro.ticketBookingResponse != null && pro.ticketBookingResponse!.success) { if (pro.ticketBookingResponse != null && pro.ticketBookingResponse!.success) {
SSOAuthModel? ssoToken = await pro.fetchSSOAuthRedirection(clientID: pro.ticketBookingResponse!.clientId); SSOAuthModel? ssoToken = await pro.fetchSSOAuthRedirection(clientID: pro.ticketBookingResponse!.clientId);
if (ssoToken != null) { if (ssoToken != null) {

Loading…
Cancel
Save