Skip to content

Commit

Permalink
Merge pull request Sunbird-RC#359 from chaitrali-r/main
Browse files Browse the repository at this point in the history
Loader stop - after esign window closed
  • Loading branch information
Pratikshakhandagale authored Aug 1, 2023
2 parents 1636034 + ce883cb commit d903c91
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 16 deletions.
50 changes: 42 additions & 8 deletions donor-registry/src/app/forms/forms.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export class FormsComponent implements OnInit {
isVerified: string;
isFormEdited: boolean = false;
count: number = 0;
eSignWindowClosed: boolean = false;

ngAfterViewChecked() {
this.cdr.detectChanges();
Expand Down Expand Up @@ -191,7 +192,7 @@ export class FormsComponent implements OnInit {
...this.model,
"personalDetails": {
...('personalDetails' in this.model ? this.model['personalDetails'] : {}),
"firstName": this.tempData?.firstName,
"firstName": this.tempData?.firstName,
"middleName": this.tempData?.middleName,
"lastName": this.tempData?.lastName,
"gender": (this.tempData?.gender) ? `${GenderMap[this.tempData?.gender]}` : {},
Expand Down Expand Up @@ -2386,6 +2387,16 @@ export class FormsComponent implements OnInit {
\t\tdocument.getElementById("formid").submit();
\t</script>`);
eSignWindow.focus();
let _self = this;
let checkLoaderStatus = setInterval(checkWindowStatus, 1000);
function checkWindowStatus() {
if (eSignWindow.closed) {
_self.hideLoader();
clearInterval(checkLoaderStatus);
checkESignStatus = false;
_self.eSignWindowClosed = true;
}
}
let checkESignStatus = true;
let count = 0;
while (checkESignStatus) {
Expand All @@ -2412,7 +2423,7 @@ export class FormsComponent implements OnInit {

eSignWindow.close();



if (this.model.hasOwnProperty('emergencyDetails') && this.model['emergencyDetails']['relation'] == "") {
this.model['emergencyDetails'] = {}
Expand Down Expand Up @@ -2442,11 +2453,19 @@ export class FormsComponent implements OnInit {
this.isSubmitForm = false;
}
}, (err) => {
this.toastMsg.error('error', err.error.params.errmsg);
this.isSubmitForm = false;
if(err.error.params != undefined){
this.hideLoader();
this.toastMsg.error('error', err.error.params.errmsg);
this.isSubmitForm = false;
}

});
localStorage.removeItem(this.model['identificationDetails']['abha']);
localStorage.removeItem('isVerified');

if(!this.eSignWindowClosed){
localStorage.removeItem(this.model['identificationDetails']['abha']);
localStorage.removeItem('isVerified');
}

});
} else {
this.callPostAPI();
Expand Down Expand Up @@ -2514,6 +2533,16 @@ export class FormsComponent implements OnInit {
\t\tdocument.getElementById("formid").submit();
\t</script>`);
eSignWindow.focus();
let _self = this;
let checkLoaderStatus = setInterval(checkWindowStatus, 1000);
function checkWindowStatus() {
if (eSignWindow.closed) {
_self.hideLoader();
clearInterval(checkLoaderStatus);
checkESignStatus = false;
_self.eSignWindowClosed = true;
}
}
let checkESignStatus = true;
let count = 0;
while (checkESignStatus) {
Expand Down Expand Up @@ -2567,14 +2596,19 @@ export class FormsComponent implements OnInit {
this.hideLoader();
}
}, (err) => {
this.hideLoader();
this.toastMsg.error('error', err.error.params.errmsg);
this.isSubmitForm = false;
this.hideLoader();
});

setTimeout(() => {
localStorage.removeItem(this.model['identificationDetails']['abha']);
localStorage.removeItem('isVerified');

if(!this.eSignWindowClosed){
localStorage.removeItem(this.model['identificationDetails']['abha']);
localStorage.removeItem('isVerified');
}

}, 3000);

});
Expand Down
12 changes: 10 additions & 2 deletions donor-registry/src/app/forms/types/verify-aadhaar.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class VerifyAadhaar extends FieldType {
correctAadhar: boolean = false;
err409: boolean = false;
errHeading: string;
errorCode: any;


constructor(private http: HttpClient, public generalService: GeneralService, public router: Router,
Expand Down Expand Up @@ -198,8 +199,15 @@ export class VerifyAadhaar extends FieldType {
}
if (error?.error['status'] == '409') {
this.err409 = true;
this.errHeading = 'Already Pledged';
this.errorMessage = 'To download the pledge certificate, please login with ABHA number or mobile number';

this.errorCode = error?.error['code'];
if(this.errorCode == 0){
this.errHeading = 'Already Pledged';
}
else if(this.errorCode == 1){
this.errHeading = 'Already Unpledged';
}
this.errorMessage = error?.error['message'];
this.closePops('verifyOtpModal');
this.closeAllModal();
this.openPopup('errorMessagePop');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ <h3 class="fw-bold mb-3">Thank you for your enthusiasm. </h3>
<div class="d-flex flex-column justify-content-center align-items-center">

<div>
<span class="p24 mb-2 mt-2 mb-2 fw-bold">Already Registered</span>
<span class="p24 mb-2 mt-2 mb-2 fw-bold">{{errHeading}}</span>

<br>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,15 @@ export class VerifyIndentityCode extends FieldType {
this.isGotErr = true;
console.log(error);
this.errorCode = error?.error['code'];
if(this.errorCode == 0){
this.errHeading = 'Already Pledged';
}
else if(this.errorCode == 1){
this.errHeading = 'Already Unpledged';
}

this.err409 = true;
this.errHeading = 'Already Pledged';

this.errorMessage = error?.error['message'];

}
Expand Down
4 changes: 2 additions & 2 deletions donor-registry/src/app/forms/types/verify-mobileno.type.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ <h3 class="fw-bold mb-3">{{'THANK_YOU_MSG' | translate}} </h3>
<span class="mr-2 text-grey-color">ABHA number</span>
<span class="fw-bold">{{profile.healthIdNumber}}</span>
</p>
<a *ngIf="profile?.pledgeStatus == 1" href="/login"><div class="text-success" [hidden]="!profile?.pledged">{{'ALREADY_REGISTERED' | translate }} .{{'CLICK_TO_LOGIN' | translate }} </div>
<a *ngIf="profile?.pledgeStatus == 1" href="/login"><div class="text-success" [hidden]="!profile?.pledged">{{'YOU_UNPLEDGED' | translate }}.{{'LOGIN_TO_PLEDGE' | translate }} </div>

</a>
<a *ngIf="profile?.pledgeStatus == 0" href="/login"><div class="text-success" [hidden]="!profile?.pledged">{{'YOU_UNPLEDGED' | translate }}. {{'CLICK_TO_PLEDGE_AGAIN' | translate}}</div>
<a *ngIf="profile?.pledgeStatus == 0" href="/login"><div class="text-success" [hidden]="!profile?.pledged"> {{'ALREADY_REGISTERED' | translate }} . {{'CLICK_TO_PLEDGE_AGAIN' | translate}}</div>
</a>

</div>
Expand Down
6 changes: 4 additions & 2 deletions donor-registry/src/assets/i18n/global/en-global.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,10 @@
"LINK_COPIED":"Link Copied",
"LOGIN_TOSHARE_PLEDGE_STATUS": "Login to share your pledge status",
"CLICK_TO_LOGIN":"Click here to login",
"YOU_UNPLEDGED":"You have already unpledged",
"CLICK_TO_PLEDGE_AGAIN":"Click here to pledge again"
"YOU_UNPLEDGED":"You have unpledged your exisitng pledge",
"CLICK_TO_PLEDGE_AGAIN":"Click here to pledge again",
"LOGIN_TO_PLEDGE":"Click here to update the pledge"



}

0 comments on commit d903c91

Please sign in to comment.