history service, mail template improved, general listing entry

This commit is contained in:
2024-05-14 11:53:20 -05:00
parent aff55c5433
commit d2e5562602
17 changed files with 261 additions and 49 deletions

View File

@@ -1,7 +1,6 @@
import { Location } from '@angular/common';
import { Component } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { ActivatedRoute, Router } from '@angular/router';
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
import onChange from 'on-change';
import { MessageService } from 'primeng/api';
import { GalleriaModule } from 'primeng/galleria';
@@ -9,6 +8,7 @@ import { lastValueFrom } from 'rxjs';
import { BusinessListing, User } from '../../../../../../bizmatch-server/src/models/db.model';
import { ListingCriteria, MailInfo } from '../../../../../../bizmatch-server/src/models/main.model';
import { environment } from '../../../../environments/environment';
import { HistoryService } from '../../../services/history.service';
import { ListingsService } from '../../../services/listings.service';
import { MailService } from '../../../services/mail.service';
import { SelectOptionsService } from '../../../services/select-options.service';
@@ -49,7 +49,9 @@ export class DetailsBusinessListingComponent {
mailinfo: MailInfo;
environment = environment;
user: User;
listingUser: User;
description: SafeHtml;
private history: string[] = [];
constructor(
private activatedRoute: ActivatedRoute,
private listingsService: ListingsService,
@@ -59,8 +61,13 @@ export class DetailsBusinessListingComponent {
private mailService: MailService,
private messageService: MessageService,
private sanitizer: DomSanitizer,
private location: Location,
public historyService: HistoryService,
) {
this.router.events.subscribe(event => {
if (event instanceof NavigationEnd) {
this.history.push(event.urlAfterRedirects);
}
});
this.mailinfo = { sender: {}, userId: '', email: '' };
this.userService.getUserObservable().subscribe(user => {
this.user = user;
@@ -70,16 +77,15 @@ export class DetailsBusinessListingComponent {
async ngOnInit() {
this.listing = await lastValueFrom(this.listingsService.getListingById(this.id, 'business'));
this.listingUser = await this.userService.getById(this.listing.userId);
this.description = this.sanitizer.bypassSecurityTrustHtml(this.listing.description);
}
back() {
this.location.back();
}
isAdmin() {
return this.userService.hasAdminRole();
}
async mail() {
this.mailinfo.email = this.user.email;
this.mailinfo.email = this.listingUser.email;
this.mailinfo.userId = this.listing.userId;
this.mailinfo.listing = this.listing;
await this.mailService.mail(this.mailinfo);