Issues gitea
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ChangeDetectorRef, Component } from '@angular/core';
|
||||
import { NgOptimizedImage } from '@angular/common';
|
||||
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
@@ -59,7 +59,8 @@ export class DetailsUserComponent {
|
||||
private auditService: AuditService,
|
||||
private emailService: EMailService,
|
||||
private messageService: MessageService,
|
||||
) {}
|
||||
private cdref: ChangeDetectorRef,
|
||||
) { }
|
||||
|
||||
async ngOnInit() {
|
||||
this.user = await this.userService.getById(this.id);
|
||||
@@ -74,25 +75,40 @@ export class DetailsUserComponent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add professional to favorites
|
||||
* Toggle professional favorite status
|
||||
*/
|
||||
async save() {
|
||||
await this.listingsService.addToFavorites(this.user.id, 'user');
|
||||
if (!this.user.favoritesForUser) {
|
||||
this.user.favoritesForUser = [];
|
||||
async toggleFavorite() {
|
||||
try {
|
||||
const isFavorited = this.user.favoritesForUser?.includes(this.keycloakUser.email);
|
||||
|
||||
if (isFavorited) {
|
||||
// Remove from favorites
|
||||
await this.listingsService.removeFavorite(this.user.id, 'user');
|
||||
this.user.favoritesForUser = this.user.favoritesForUser.filter(
|
||||
email => email !== this.keycloakUser.email
|
||||
);
|
||||
} else {
|
||||
// Add to favorites
|
||||
await this.listingsService.addToFavorites(this.user.id, 'user');
|
||||
if (!this.user.favoritesForUser) {
|
||||
this.user.favoritesForUser = [];
|
||||
}
|
||||
this.user.favoritesForUser.push(this.keycloakUser.email);
|
||||
this.auditService.createEvent(this.user.id, 'favorite', this.keycloakUser?.email);
|
||||
}
|
||||
|
||||
this.cdref.detectChanges();
|
||||
} catch (error) {
|
||||
console.error('Error toggling favorite', error);
|
||||
}
|
||||
this.user.favoritesForUser.push(this.keycloakUser.email);
|
||||
this.auditService.createEvent(this.user.id, 'favorite', this.keycloakUser?.email);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if already in favorites
|
||||
*/
|
||||
isAlreadyFavorite(): boolean {
|
||||
if (!this.keycloakUser?.email || !this.user?.favoritesForUser) return false;
|
||||
return this.user.favoritesForUser.includes(this.keycloakUser.email);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show email sharing modal
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user