diff --git a/src/app/main/component/errors/mat-snack-bar/mat-snack-bar.component.ts b/src/app/main/component/errors/mat-snack-bar/mat-snack-bar.component.ts
index 9f4c902ebc..653f663243 100644
--- a/src/app/main/component/errors/mat-snack-bar/mat-snack-bar.component.ts
+++ b/src/app/main/component/errors/mat-snack-bar/mat-snack-bar.component.ts
@@ -74,6 +74,8 @@ export class MatSnackBarComponent {
addFriend: { classname: SnackbarClassName.success, key: 'snack-bar.success.add-friend' },
friendValidation: { classname: SnackbarClassName.error, key: 'snack-bar.error.friend-request' },
friendInValidRequest: { classname: SnackbarClassName.error, key: 'snack-bar.error.friend-already-added' },
+ friendRequestAccepted: { classname: SnackbarClassName.success, key: 'snack-bar.success.friend-added-success' },
+ friendRequestDeclined: { classname: SnackbarClassName.success, key: 'snack-bar.success.friend-declined-success' },
habitAcceptRequest: { classname: SnackbarClassName.success, key: 'snack-bar.success.habit-added-success' },
habitDeclineRequest: { classname: SnackbarClassName.success, key: 'snack-bar.success.habit-decline-success' },
habitAcceptInValidRequest: { classname: SnackbarClassName.error, key: 'snack-bar.error.habit-not-added' },
diff --git a/src/app/main/component/user/components/profile/user-notifications/user-notifications.component.ts b/src/app/main/component/user/components/profile/user-notifications/user-notifications.component.ts
index aa12f4003e..bc499f7784 100644
--- a/src/app/main/component/user/components/profile/user-notifications/user-notifications.component.ts
+++ b/src/app/main/component/user/components/profile/user-notifications/user-notifications.component.ts
@@ -296,9 +296,7 @@ export class UserNotificationsComponent implements OnInit, OnDestroy {
isAccepted = false;
},
complete: () => {
- if (isAccepted) {
- this.matSnackBar.openSnackBar('friendInValidRequest');
- }
+ this.matSnackBar.openSnackBar(isAccepted ? 'friendRequestAccepted' : 'friendInValidRequest');
}
});
} else {
@@ -307,9 +305,7 @@ export class UserNotificationsComponent implements OnInit, OnDestroy {
isAccepted = false;
},
complete: () => {
- if (isAccepted) {
- this.matSnackBar.openSnackBar('friendInValidRequest');
- }
+ this.matSnackBar.openSnackBar(isAccepted ? 'friendRequestDeclined' : 'friendInValidRequest');
}
});
}
diff --git a/src/app/main/component/user/directives/notific-content-replace.directive.spec.ts b/src/app/main/component/user/directives/notific-content-replace.directive.spec.ts
index ecc4b6e9e6..229b29fe83 100644
--- a/src/app/main/component/user/directives/notific-content-replace.directive.spec.ts
+++ b/src/app/main/component/user/directives/notific-content-replace.directive.spec.ts
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
-import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { NotificContentReplaceDirective } from './notific-content-replace.directive';
@Component({
@@ -30,7 +30,7 @@ describe('NotificContentReplaceDirective', () => {
viewed: false
};
- beforeEach(() => {
+ beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [TestComponent, NotificContentReplaceDirective]
});
@@ -39,7 +39,7 @@ describe('NotificContentReplaceDirective', () => {
fixture.detectChanges();
component = fixture.componentInstance;
paragrEl = fixture.nativeElement.querySelector('p');
- });
+ }));
it('should display multiple user replacements', () => {
component.notification = { ...notification, ...{ bodyText: '{user1} and {user2} liked your post' } };
@@ -74,7 +74,7 @@ describe('NotificContentReplaceDirective', () => {
component.notification = { ...notification, ...{ bodyText: 'commented event {message}' } };
fixture.detectChanges();
expect(paragrEl.textContent).toBe('commented event test message');
- expect(paragrEl.innerHTML).toBe('commented event test message');
+ expect(paragrEl.innerHTML).toBe('commented event test message');
});
it('should add property value to the content and anchor tag', () => {
@@ -83,10 +83,7 @@ describe('NotificContentReplaceDirective', () => {
...{ bodyText: '{user1},{user2} commented event {message}', actionUserId: [2, 3], actionUserText: ['testUser1', 'testUser2'] }
};
fixture.detectChanges();
- expect(paragrEl.textContent).toBe('testUser1,testUser2 commented event test message'); // Text content without tags
- expect(paragrEl.innerHTML).toBe(
- 'testUser1,testUser2 commented event ' +
- 'test message'
- );
+ expect(paragrEl.textContent).toBe('testUser1,testUser2 commented event test message');
+ expect(paragrEl.innerHTML).toBe('testUser1,testUser2 commented event test message');
});
});
diff --git a/src/app/main/component/user/directives/notific-content-replace.directive.ts b/src/app/main/component/user/directives/notific-content-replace.directive.ts
index 07bdf79dd3..a3c2e7e362 100644
--- a/src/app/main/component/user/directives/notific-content-replace.directive.ts
+++ b/src/app/main/component/user/directives/notific-content-replace.directive.ts
@@ -45,11 +45,6 @@ export class NotificContentReplaceDirective implements OnChanges {
userId: replacements.actionUserId[index]
});
}
- } else if (contentKey === 'message' && replacements.notificationType) {
- const linkAttributes = replacements.targetId
- ? { targetId: replacements.targetId, notificationType: replacements.notificationType }
- : null;
- result = this.buildReplacementString(result, contentKey, replacements[replacementKey], linkAttributes);
} else if (replacements.hasOwnProperty(replacementKey)) {
const linkAttributes = idToNavigate ? { userId: replacements[idToNavigate] } : null;
diff --git a/src/app/main/service/habit/habit.service.spec.ts b/src/app/main/service/habit/habit.service.spec.ts
index 3d3fab39b8..670312de13 100644
--- a/src/app/main/service/habit/habit.service.spec.ts
+++ b/src/app/main/service/habit/habit.service.spec.ts
@@ -1,5 +1,5 @@
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
-import { TestBed } from '@angular/core/testing';
+import { TestBed, waitForAsync } from '@angular/core/testing';
import { LocalStorageService } from '@global-service/localstorage/local-storage.service';
import { BehaviorSubject } from 'rxjs';
import { HabitService } from './habit.service';
@@ -255,4 +255,30 @@ describe('HabitService', () => {
expect(req.request.method).toBe('GET');
req.flush(HABITLIST);
});
+
+ it('should accept habit invitation', () => {
+ const invitationId = 123;
+ const mockResponse = 'Invitation accepted successfully';
+
+ habitService.acceptHabitInvitation(invitationId).subscribe((response) => {
+ expect(response).toEqual(mockResponse);
+ });
+
+ const req = httpMock.expectOne(`${habitLink}/invite/${invitationId}/accept`);
+ expect(req.request.method).toBe('PATCH');
+ req.flush(mockResponse);
+ });
+
+ it('should decline habit invitation', () => {
+ const invitationId = 456;
+ const mockResponse = 'Invitation declined successfully';
+
+ habitService.declineHabitInvitation(invitationId).subscribe((response) => {
+ expect(response).toEqual(mockResponse);
+ });
+
+ const req = httpMock.expectOne(`${habitLink}/invite/${invitationId}/reject`);
+ expect(req.request.method).toBe('DELETE');
+ req.flush(mockResponse);
+ });
});
diff --git a/src/app/main/service/habit/habit.service.ts b/src/app/main/service/habit/habit.service.ts
index 461a6504e8..304e2e7019 100644
--- a/src/app/main/service/habit/habit.service.ts
+++ b/src/app/main/service/habit/habit.service.ts
@@ -89,7 +89,7 @@ export class HabitService {
}
declineHabitInvitation(invitationId: number): Observable {
- return this.http.patch(`${habitLink}/invite/${invitationId}/reject`, {});
+ return this.http.delete(`${habitLink}/invite/${invitationId}/reject`);
}
private prepareCustomHabitRequest(habit: CustomHabit, lang: string): FormData {
diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json
index fe6b4c326b..8afc05583c 100644
--- a/src/assets/i18n/en.json
+++ b/src/assets/i18n/en.json
@@ -509,7 +509,7 @@
"exist-address": "This address has already been added",
"certificate-duration": "The duration of the certificate cant be more than 12 months",
"friend-request": "You cannot add this friend",
- "friend-already-added": "This friend has been already added",
+ "friend-already-added": "This friend invitation has been already accepted or declined",
"error-create-address": "Oops, An error occurred while creating the address. Please try again.",
"habit-not-added": "This habit invitation can`t be accepted",
"habit-already-added": "This habit invitation can`t be declined",
@@ -538,7 +538,9 @@
"joint-event-request": "The request to join the closed event has been successfully sent to the organizer",
"create-news": "Your news has been successfully published",
"habit-added-success": "Habit invitation was accepted",
- "habit-decline-success": "Habit invitation was declined"
+ "habit-decline-success": "Habit invitation was declined",
+ "friend-added-success": "Friend invitation accepted",
+ "friend-declined-success": "Friend invitation declined"
}
},
"user": {
diff --git a/src/assets/i18n/ua.json b/src/assets/i18n/ua.json
index 03fdd4ae59..6c01adecae 100644
--- a/src/assets/i18n/ua.json
+++ b/src/assets/i18n/ua.json
@@ -516,7 +516,7 @@
"exist-address": "Ця адреса вже додана",
"certificate-duration": "Термін дії сертифіката не може перевищувати 12 місяців",
"friend-request": "Ви не можете додати цього друга",
- "friend-already-added": "Цього друга вже було додано",
+ "friend-already-added": "Це запрошення друга вже було додано або відхилено",
"error-create-address": "Упс! Виникла помилка при створенні адреси. Будь ласка, спробуйте ще раз.",
"habit-not-added": "Неможливо прийняти запрошення",
"habit-already-added": "Неможливо відхилити запрошення",
@@ -547,7 +547,9 @@
"joint-event-request": "Запит на приєднання до закритої події надіслано",
"create-news": "Ваша новина успішно опублікована",
"habit-added-success": "Запрошення прийнято",
- "habit-decline-success": "Запрошення відхилено"
+ "habit-decline-success": "Запрошення відхилено",
+ "friend-added-success": "Запит на дружбу прийнято",
+ "friend-declined-success": "Запит на дружбу відхилено"
}
},
"user": {