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

@@ -0,0 +1,35 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
import { Observable, of } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { environment } from '../../environments/environment';
@Injectable({
providedIn: 'root',
})
export class ListingCategoryGuard implements CanActivate {
private apiBaseUrl = environment.apiBaseUrl;
constructor(private http: HttpClient, private router: Router) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> {
const id = route.paramMap.get('id');
const url = `${this.apiBaseUrl}/bizmatch/listings/undefined/${id}`;
return this.http.get<any>(url).pipe(
map(response => {
const category = response.listingsCategory;
if (category === 'business') {
return this.router.createUrlTree([`/details-business-listing/${id}`]);
} else if (category === 'commercialProperty') {
return this.router.createUrlTree([`/details-commercial-property-listing/${id}`]);
} else {
return this.router.createUrlTree(['/not-found']);
}
}),
catchError(() => {
return of(this.router.createUrlTree(['/not-found']));
}),
);
}
}