diff --git a/src/app/components/contacts/contact-detail/contact-detail.component.html b/src/app/components/contacts/contact-detail/contact-detail.component.html index 68fffbf..ddfbe51 100644 --- a/src/app/components/contacts/contact-detail/contact-detail.component.html +++ b/src/app/components/contacts/contact-detail/contact-detail.component.html @@ -7,12 +7,12 @@ {{ "contacts.headlineDescription" | translate }} -
{{ "contacts.btnDelete0" | translate }}
diff --git a/src/app/components/contacts/contact-detail/contact-detail.component.scss b/src/app/components/contacts/contact-detail/contact-detail.component.scss
index 9240914..ccecb6a 100644
--- a/src/app/components/contacts/contact-detail/contact-detail.component.scss
+++ b/src/app/components/contacts/contact-detail/contact-detail.component.scss
@@ -177,6 +177,10 @@
}
}
+.d-none {
+ display: none;
+}
+
/*------------- ANIMATION -------------*/
.animation-coming-in {
diff --git a/src/app/components/contacts/contact-detail/contact-detail.component.ts b/src/app/components/contacts/contact-detail/contact-detail.component.ts
index b5cd883..49165ac 100644
--- a/src/app/components/contacts/contact-detail/contact-detail.component.ts
+++ b/src/app/components/contacts/contact-detail/contact-detail.component.ts
@@ -9,9 +9,11 @@ import { CommonModule } from '@angular/common';
import { FirebaseService } from '../../../services/firebase.service';
import { TranslateModule } from '@ngx-translate/core';
import { UserService } from '../../../services/user.service';
-import { finalize } from 'rxjs';
+import { finalize, lastValueFrom } from 'rxjs';
import { User } from '../../../interfaces/user.interface';
import { OverlayService } from '../../../services/overlay.service';
+import { ApiService } from '../../../services/api.service';
+import { ToastNotificationService } from '../../../services/toast-notification.servic';
@Component({
selector: 'app-contact-detail',
@@ -32,7 +34,9 @@ export class ContactDetailComponent {
constructor(
public firebaseService: FirebaseService,
private overlayService: OverlayService,
- private userService: UserService
+ private userService: UserService,
+ private apiService: ApiService,
+ private toastNotificationService: ToastNotificationService
) {}
ngOnChanges(changes: SimpleChanges) {
@@ -97,8 +101,13 @@ export class ContactDetailComponent {
* Opens the delete contact dialog by setting the appropriate flags in the shared service.
* This method is used by the contact details component to open the delete contact dialog when the user clicks the delete button.
*/
- openDeleteContactDialog() {
- // TODO
- this.isMobileNavbarOpen = false;
+ async deleteContact(userId: string) {
+ try {
+ await lastValueFrom(this.apiService.deleteUserById(userId));
+ this.toastNotificationService.deleteContactSuccessToast();
+ this.closeUserDetails();
+ } catch (error) {
+ console.error(error);
+ }
}
}
diff --git a/src/app/services/api.service.ts b/src/app/services/api.service.ts
index aca64c4..42a7cd0 100644
--- a/src/app/services/api.service.ts
+++ b/src/app/services/api.service.ts
@@ -73,4 +73,8 @@ export class ApiService {
ids: userIds.join(','),
});
}
+
+ deleteUserById(userId: string): Observable