Skip to content

Commit

Permalink
MOSIP-32390: duplication fix (#728)
Browse files Browse the repository at this point in the history
* MOSIP-32390: duplication fix

Signed-off-by: SwethaKrish4 <[email protected]>

* MOSIP-32390: duplication fix

Signed-off-by: SwethaKrish4 <[email protected]>

---------

Signed-off-by: SwethaKrish4 <[email protected]>
  • Loading branch information
SwethaKrish4 authored Apr 15, 2024
1 parent b3f92ec commit 29d0659
Showing 1 changed file with 30 additions and 43 deletions.
73 changes: 30 additions & 43 deletions src/app/core/components/dialog/dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,28 +410,16 @@ export class DialogComponent implements OnInit {
};
const subs = this.dataService.submitReportForReview(submitRequest).subscribe(
(res: any) => {
this.dataLoaded = true;
if (res) {
if (res.errors && res.errors.length > 0) {
this.dialogRef.close();
Utils.showErrorMessage(this.resourceBundleJson, res.errors, this.dialog);
} else {
this.closeMe();
window.location.reload();
}
} else {
Utils.showErrorMessage(this.resourceBundleJson,
null,
this.dialog,
'Unable to submit report for review. Try Again!');
}
const msg = "Unable to submit report for review. Try Again!";
this.handleReportErrResponse(res, msg, true);
},
(errors) => {
Utils.showErrorMessage(this.resourceBundleJson, errors, this.dialog);
}
);
this.subscriptions.push(subs);
}

approvePartnerReport(adminApproveComments: String) {
let newRequest = {
...this.input.approveRequest,
Expand All @@ -445,27 +433,16 @@ export class DialogComponent implements OnInit {
};
const subs = this.dataService.approvePartnerReport(this.input.partnerId, approveRequest).subscribe(
(res: any) => {
this.dataLoaded = true;
if (res) {
if (res.errors && res.errors.length > 0) {
this.dialogRef.close(true);
Utils.showErrorMessage(this.resourceBundleJson, res.errors, this.dialog);
} else {
this.dialogRef.close(false);
}
} else {
Utils.showErrorMessage(this.resourceBundleJson,
null,
this.dialog,
'Unable to approve report. Try Again!');
}
const msg = "Unable to approve report. Try Again!";
this.handleReportErrResponse(res, msg, false);
},
(errors) => {
Utils.showErrorMessage(this.resourceBundleJson, errors, this.dialog);
}
);
this.subscriptions.push(subs);
}

rejectPartnerReport(adminRejectComments: String) {
let newRequest = {
...this.input.rejectRequest,
Expand All @@ -479,20 +456,8 @@ export class DialogComponent implements OnInit {
};
const subs = this.dataService.rejectPartnerReport(this.input.partnerId, rejectRequest).subscribe(
(res: any) => {
this.dataLoaded = true;
if (res) {
if (res.errors && res.errors.length > 0) {
this.dialogRef.close(true);
Utils.showErrorMessage(this.resourceBundleJson, res.errors, this.dialog);
} else {
this.dialogRef.close(false);
}
} else {
Utils.showErrorMessage(this.resourceBundleJson,
null,
this.dialog,
'Unable to reject report. Try Again!');
}
const msg = "Unable to reject report. Try Again!";
this.handleReportErrResponse(res, msg, false);
},
(errors) => {
Utils.showErrorMessage(this.resourceBundleJson, errors, this.dialog);
Expand All @@ -501,6 +466,28 @@ export class DialogComponent implements OnInit {
this.subscriptions.push(subs);
}

handleReportErrResponse(res: any, msg: string, isSubmitForReview: boolean) {
this.dataLoaded = true;
if (res) {
if (res.errors && res.errors.length > 0) {
this.dialogRef.close(true);
Utils.showErrorMessage(this.resourceBundleJson, res.errors, this.dialog);
} else {
if (isSubmitForReview) {
this.closeMe();
window.location.reload();
} else {
this.dialogRef.close(false);
}
}
} else {
Utils.showErrorMessage(this.resourceBundleJson,
null,
this.dialog,
msg);
}
}

checkHashAndWebsiteUrl() {
this.dialogRef.close(false);
}
Expand Down

0 comments on commit 29d0659

Please sign in to comment.