From b9baa8b12e301be1aaaf942554d6753700893df2 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Fri, 18 Jun 2021 14:16:14 +0300 Subject: [PATCH] offers and discount and ERM --- Mohem/src/app/app.component.ts | 42 ++++++++++++++++--- .../app/erm-channel/home/home.component.html | 22 ++++++---- .../app/erm-channel/home/home.component.scss | 4 ++ .../app/erm-channel/home/home.component.ts | 42 ++++++++++++++++++- .../erm-channel/survey/survey.component.html | 8 ++-- .../erm-channel/survey/survey.component.ts | 23 ++++++++-- .../authentication/authentication.service.ts | 13 ++++-- Mohem/src/app/home/home.page.ts | 4 +- .../offersdiscount/home/home.component.html | 7 ++-- .../offersdiscount/home/home.component.scss | 20 ++++++--- .../app/offersdiscount/home/home.component.ts | 28 ++++++++++--- .../offer-details.component.html | 2 +- 12 files changed, 170 insertions(+), 45 deletions(-) diff --git a/Mohem/src/app/app.component.ts b/Mohem/src/app/app.component.ts index d230d5af..039b8aed 100644 --- a/Mohem/src/app/app.component.ts +++ b/Mohem/src/app/app.component.ts @@ -137,11 +137,41 @@ export class AppComponent implements OnInit { this.authService.checkAds({ EmployeeNumber: '', - ItgEnableAt: "Before Service Initiation", - ItgServiceName: "Ticket" + ItgEnableAt: "After Service Submission", //Before Service Initiation + ItgServiceName: "Login" }, () => { }, this.ts.trPK('general', 'ok')).subscribe(res => { - console.log("Check Ads") - console.log(res); + + var result = JSON.parse(res.Mohemm_ITG_ResponseItem).result.data; + + this.cs.sharedService.setSharedData( + result, + AuthenticationService.SERVEY_DATA + ) + if (!CommonService.SKIP && result) { + if (result.notificationType == 'Survey') { + this.cs.navigateForward('/erm-channel/survey'); + } else { + this.authService.adsDetails({ + "ItgNotificationMasterId": result['notificationMasterId'] + }, + () => { }, this.ts.trPK('general', 'ok') + ).subscribe((result) => { + var data = result.Mohemm_ITG_ResponseItem; + if (data) { + this.cs.sharedService.setSharedData( + JSON.parse(data), + AuthenticationService.ADS_DATA + ); + this.cs.navigateForward('/erm-channel/home'); + } + + }) + + } + + } + + }); if (this.cs.getUpdateImage().status) { @@ -151,8 +181,8 @@ export class AppComponent implements OnInit { } this.User_Job_name = user.JOB_NAME; //erm channel - if (!CommonService.SKIP) - this.cs.navigateForward('/erm-channel/survey'); + // if (!CommonService.SKIP) + // this.cs.navigateForward('/erm-channel/survey'); } else { console.log(user); } diff --git a/Mohem/src/app/erm-channel/home/home.component.html b/Mohem/src/app/erm-channel/home/home.component.html index 5929573b..911f0bd1 100644 --- a/Mohem/src/app/erm-channel/home/home.component.html +++ b/Mohem/src/app/erm-channel/home/home.component.html @@ -1,13 +1,19 @@ -
+
-
{{ts.trPK('worklistMain','skip')}}
-
{{setTime}}
+ + + + + +
- - - - - +
{{setTime}}
+
+ + + +
\ No newline at end of file diff --git a/Mohem/src/app/erm-channel/home/home.component.scss b/Mohem/src/app/erm-channel/home/home.component.scss index 284af1b8..f795eea4 100644 --- a/Mohem/src/app/erm-channel/home/home.component.scss +++ b/Mohem/src/app/erm-channel/home/home.component.scss @@ -41,4 +41,8 @@ background: #fff; color: #000; +} +.seconds{ + font-size: 28px; + font-weight: bold; } \ No newline at end of file diff --git a/Mohem/src/app/erm-channel/home/home.component.ts b/Mohem/src/app/erm-channel/home/home.component.ts index e82eac45..5bec5386 100644 --- a/Mohem/src/app/erm-channel/home/home.component.ts +++ b/Mohem/src/app/erm-channel/home/home.component.ts @@ -1,6 +1,9 @@ import { Component, OnInit } from '@angular/core'; import { NavController } from '@ionic/angular'; +import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service'; import { CommonService } from 'src/app/hmg-common/services/common/common.service'; +import { DomSanitizer } from '@angular/platform-browser'; +import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; @Component({ selector: 'app-home', @@ -10,9 +13,19 @@ import { CommonService } from 'src/app/hmg-common/services/common/common.service export class HomeComponent implements OnInit { isSkip: boolean = false; setTime: number = 5; - constructor(public nav: NavController,) { } + advertisement: any; + data: any; + constructor(public nav: NavController, public cs: CommonService, public sanitizer: DomSanitizer, public authService: AuthenticationService, public ts: TranslatorService) { } - ngOnInit() { } + ngOnInit() { + this.data = this.cs.sharedService.getSharedData( + AuthenticationService.ADS_DATA, + false + ); + this.advertisement = this.data.result.data.advertisement.viewAttachFileColl[0]; + this.setTime = this.data.result.data.advertisement.durationInSeconds; + this.setTimer(); + } skip() { this.nav.pop(); CommonService.SKIP = true; @@ -27,4 +40,29 @@ export class HomeComponent implements OnInit { } }, 1000); } + setView(status) { + // var request = + // { + // "ItgSurveyId": data.serviceId, "ItgNotificationMasterId": data.notificationMasterId, "ItgComments": this.note, "ItgQuestionResponses": [ + // { "questionId": 1, "optionId": null, "starRating": parseInt(this.rate) }, + // { "questionId": 2, "optionId": 4, "starRating": parseInt(this.satisfied) } + // ] + // }; + + + + this.authService.setViewAds({ + "ItgNotificationMasterId": this.data.result.data.notificationMasterId, + "ItgAdvertisement": { + "advertisementId": this.data.result.data.advertisementId, + "acknowledgment": status + } + }, ( + + ) => { }, this.ts.trPK('general', 'ok')).subscribe((result) => { + CommonService.SKIP = true; + this.cs.openHome(); + }) + } + } diff --git a/Mohem/src/app/erm-channel/survey/survey.component.html b/Mohem/src/app/erm-channel/survey/survey.component.html index bab9b971..8df2b19a 100644 --- a/Mohem/src/app/erm-channel/survey/survey.component.html +++ b/Mohem/src/app/erm-channel/survey/survey.component.html @@ -1,6 +1,6 @@ -
{{ts.trPK('worklistMain','skip')}}
-
{{setTime}}
+ @@ -57,7 +57,7 @@ - + @@ -65,7 +65,7 @@
- + {{'general,submit' | translate}}
diff --git a/Mohem/src/app/erm-channel/survey/survey.component.ts b/Mohem/src/app/erm-channel/survey/survey.component.ts index cba63469..b547457b 100644 --- a/Mohem/src/app/erm-channel/survey/survey.component.ts +++ b/Mohem/src/app/erm-channel/survey/survey.component.ts @@ -14,7 +14,7 @@ export class SurveyComponent implements OnInit { isSkip: boolean = false; setTime: number = 5; satisfied: any = '5'; - + note: any; constructor(public ts: TranslatorService, public cs: CommonService, public nav: NavController, public authService: AuthenticationService) { } ngOnInit() { @@ -34,11 +34,26 @@ export class SurveyComponent implements OnInit { } }, 1000); } - saveSruvey() { + saveSurvey() { - var request = {} - this.authService.saveAdsStatus(request, () => { }, this.ts.trPK('general', 'ok')).subscribe((result) => { + var data = this.cs.sharedService.getSharedData( + AuthenticationService.SERVEY_DATA, + false + ) + + var request = + { + "ItgSurveyId": data.serviceId, "ItgNotificationMasterId": data.notificationMasterId, "ItgComments": this.note, "ItgQuestionResponses": [ + { "questionId": 1, "optionId": null, "starRating": parseInt(this.rate) }, + { "questionId": 2, "optionId": 4, "starRating": parseInt(this.satisfied) } + ] + }; + + + this.authService.saveAdsStatus(request, () => { }, this.ts.trPK('general', 'ok')).subscribe((result) => { + CommonService.SKIP = true; + this.cs.openHome(); }) } select(rating) { diff --git a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts index bd3ffbf3..c8927aa9 100644 --- a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts +++ b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts @@ -79,7 +79,7 @@ export class AuthenticationService { public static getITGPageNotification = 'Services/COCWS.svc/REST/Mohemm_ITG_GetPageNotification'; public static getITGPageNotificationDetails = 'Services/COCWS.svc/REST/Mohemm_ITG_GetPageNotificationDetails'; public static saveSurveyAds = 'Services/COCWS.svc/REST/Mohemm_ITG_Survey_Response'; - + public static setViewAdvertisement = 'Services/COCWS.svc/REST/Mohemm_ITG_UpdateAdvertisementAsViewed'; public static LOGIN_EVENT = 'user-login-event'; @@ -89,8 +89,8 @@ export class AuthenticationService { public static DEVICE_TOKEN = "device_token"; public static LAST_LOGIN = 'last-login'; public static IMEI_USER_DATA = "imei-user-data"; - - + public static SERVEY_DATA = "survey-data"; + public static ADS_DATA = "ads-data"; // private static user: AuthenticatedUser; constructor( public con: ConnectorService, @@ -756,6 +756,13 @@ export class AuthenticationService { return this.con.post(AuthenticationService.saveSurveyAds, request, onError, errorLabel); } + setViewAds(request, onError, errorLabel) { + request = this.authenticateRequest(request); + request.EmployeeNumber = request.UserName; + return this.con.post(AuthenticationService.setViewAdvertisement, request, onError, errorLabel); + + } + //**************************// diff --git a/Mohem/src/app/home/home.page.ts b/Mohem/src/app/home/home.page.ts index 3eaf395c..0bd553d1 100644 --- a/Mohem/src/app/home/home.page.ts +++ b/Mohem/src/app/home/home.page.ts @@ -638,7 +638,7 @@ export class HomePage implements OnInit { } openNotificationsDashbored() { - this.DS.getOpenNotifications('', '', this.isPostNoLoad).subscribe((result: GetOpenNotificationsResponse) => { + this.DS.getOpenNotifications('', '', false).subscribe((result: GetOpenNotificationsResponse) => { if (this.common.validResponse(result)) { const key = 'P_OPEN_NTF_NUMBER'; this.countAllNotification = result[key]; @@ -788,7 +788,7 @@ export class HomePage implements OnInit { offersDiscount() { this.common.navigateForward('/offersdiscount/home'); } - openAnnouncement(){ + openAnnouncement() { this.common.openAnnouncement(); } } diff --git a/Mohem/src/app/offersdiscount/home/home.component.html b/Mohem/src/app/offersdiscount/home/home.component.html index f8890934..96289de6 100644 --- a/Mohem/src/app/offersdiscount/home/home.component.html +++ b/Mohem/src/app/offersdiscount/home/home.component.html @@ -33,12 +33,13 @@
-
+
+
-

{{key}}

+

{{key.name}}

@@ -65,7 +66,7 @@

{{ts.trPK('general','offer-valid')}}

- +

{{ts.trPK('general','expired')}}

diff --git a/Mohem/src/app/offersdiscount/home/home.component.scss b/Mohem/src/app/offersdiscount/home/home.component.scss index a447930d..bfaf8447 100644 --- a/Mohem/src/app/offersdiscount/home/home.component.scss +++ b/Mohem/src/app/offersdiscount/home/home.component.scss @@ -42,9 +42,9 @@ } .sale-icon{ box-shadow: 1px 1px 5px 1px #cccc; - padding: 5px; - margin: 5px; - border-radius: 10px; + padding: 0px; + margin: 3px; + border-radius: 8px; background: #fff; position: relative; } @@ -52,16 +52,18 @@ font-size: 25px; } .sale-icon p{ - margin-top:5px; + margin-top: 5px; margin-bottom: 5px; text-transform: capitalize; - font-size: 15px; + font-size: 17px; + + text-align: center; } .bottom-icon{ text-overflow: clip; white-space: normal; font-size: 14px; - padding: 4px; + padding:1px; font-weight: bold; } ion-card{ @@ -148,4 +150,10 @@ margin: 5px; } ion-content{ --background:#F5F5F5 ; +} +.top{ + text-align: center; +} +.top img{ + height:40px } \ No newline at end of file diff --git a/Mohem/src/app/offersdiscount/home/home.component.ts b/Mohem/src/app/offersdiscount/home/home.component.ts index 899b130e..f4e783b0 100644 --- a/Mohem/src/app/offersdiscount/home/home.component.ts +++ b/Mohem/src/app/offersdiscount/home/home.component.ts @@ -47,20 +47,36 @@ export class HomeComponent implements AfterViewInit { if (data['data']) { var parseJSON = data['data']; var offers = JSON.parse(parseJSON) - this.categoriesObj = this.groupBy(offers, 'categoryName'); - this.categories = Object.keys(this.categoriesObj); + this.categoriesObj = this.groupBy(offers, TranslatorService.getCurrentDirection() == 'ltr' ? 'categoryName_en' : 'categoryName_ar'); + // = Object.keys(this.categoriesObj); + + + + for (var x in this.categoriesObj) { + for (var y in offers) { + if (x == offers[y].categoryName_en && this.categories.filter(item => item.name.includes(x)) == false) { + this.categories.push({ + name: x, + icon: offers[y].icon + }) + + } + } + } + this.filterOffers(this.categories[0]); } } groupBy(xs, key) { return xs.reduce((rv, x) => { - (rv[x[key]] = rv[x[key]] || []).push(x); - return rv; + + (rv[x[key.trim()]] = rv[x[key]] || []).push(x); + return rv }, {}); }; filterOffers(key) { - this.activeClass = key; - this.offersData = this.categoriesObj[key]; + this.activeClass = key.name; + this.offersData = this.categoriesObj[key.name]; this.tempSearch = JSON.parse(JSON.stringify(this.offersData)); } checkDate(date) { diff --git a/Mohem/src/app/offersdiscount/offer-details/offer-details.component.html b/Mohem/src/app/offersdiscount/offer-details/offer-details.component.html index 7e99556d..986f2208 100644 --- a/Mohem/src/app/offersdiscount/offer-details/offer-details.component.html +++ b/Mohem/src/app/offersdiscount/offer-details/offer-details.component.html @@ -68,7 +68,7 @@

{{ts.trPK('general','offer-valid')}}

- +

{{ts.trPK('general','expired')}}