diff --git a/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation-dialog.component.ts b/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation-dialog.component.ts index fd87a879e..a57ee5cb6 100644 --- a/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation-dialog.component.ts +++ b/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation-dialog.component.ts @@ -16,6 +16,9 @@ import { Observable } from 'rxjs'; import { map, takeUntil } from 'rxjs/operators'; import { Role } from '@app/core/common/enum/role'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; +import { UiNotificationService } from '@app/core/services/notification/ui-notification-service'; +import { SnackBarNotificationLevel } from '@common/modules/notification/ui-notification-service'; +import { TranslateService } from '@ngx-translate/core'; @Component({ selector: 'app-invitation-dialog-component', @@ -41,7 +44,9 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni public enumUtils: EnumUtils, public route: ActivatedRoute, public router: Router, + private language: TranslateService, public dialogRef: MatDialogRef, + private uiNotificationService: UiNotificationService, @Inject(MAT_DIALOG_DATA) public data: any ) { super(); @@ -98,9 +103,13 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni this.invitationService.inviteDmpInvitationUsers(invitationObject) .pipe(takeUntil(this._destroyed)) - .subscribe(items => { - this.dialogRef.close(); - }); + .subscribe( + complete => { + this.dialogRef.close(); + this.onCallbackSuccess(); + }, + error => this.onCallbackError(error) + ); } closeDialog(): void { @@ -130,4 +139,12 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni return this.formGroup.get('users') && this.formGroup.get('users').value && this.formGroup.get('users').value.length > 0; } + onCallbackSuccess(): void { + this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.INVITATION-DIALOG.SUCCESS' ), SnackBarNotificationLevel.Success); + } + + onCallbackError(errorResponse: any) { + this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.INVITATION-DIALOG.ERROR' ), SnackBarNotificationLevel.Error); + } + } diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 6d9505132..fab016e47 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -87,7 +87,9 @@ "UPLOAD-FILE": "Upload File" }, "INVITATION-DIALOG": { - "HINT": "Press comma or enter between authors" + "HINT": "Press comma or enter between authors", + "SUCCESS": "Invitation successfully sent", + "ERROR": "Invitation sent failed" }, "ACTIONS": { "VIEW-ALL": "View All",