format on save, resolve compile errors, functionality 1. stage

This commit is contained in:
2024-04-23 17:32:21 +02:00
parent 7f0f21b598
commit 9e03620be7
32 changed files with 1506 additions and 1389 deletions

View File

@@ -0,0 +1,87 @@
import { Component } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { ActivatedRoute, Router } from '@angular/router';
import onChange from 'on-change';
import { MessageService } from 'primeng/api';
import { GalleriaModule } from 'primeng/galleria';
import { lastValueFrom } from 'rxjs';
import { BusinessListing, User } from '../../../../../../bizmatch-server/src/models/db.model';
import { ImageProperty, ListingCriteria, MailInfo } from '../../../../../../bizmatch-server/src/models/main.model';
import { environment } from '../../../../environments/environment';
import { ListingsService } from '../../../services/listings.service';
import { MailService } from '../../../services/mail.service';
import { SelectOptionsService } from '../../../services/select-options.service';
import { UserService } from '../../../services/user.service';
import { SharedModule } from '../../../shared/shared/shared.module';
import { getCriteriaStateObject, getSessionStorageHandler } from '../../../utils/utils';
@Component({
selector: 'app-details-business-listing',
standalone: true,
imports: [SharedModule, GalleriaModule],
providers: [MessageService],
templateUrl: './details-business-listing.component.html',
styleUrl: './details-business-listing.component.scss',
})
export class DetailsBusinessListingComponent {
// listings: Array<BusinessListing>;
responsiveOptions = [
{
breakpoint: '1199px',
numVisible: 1,
numScroll: 1,
},
{
breakpoint: '991px',
numVisible: 2,
numScroll: 1,
},
{
breakpoint: '767px',
numVisible: 1,
numScroll: 1,
},
];
private id: string | undefined = this.activatedRoute.snapshot.params['id'] as string | undefined;
private type: 'business' | 'commercialProperty' | undefined = this.activatedRoute.snapshot.params['type'] as 'business' | 'commercialProperty' | undefined;
listing: BusinessListing;
criteria: ListingCriteria;
mailinfo: MailInfo;
propertyImages: ImageProperty[] = [];
environment = environment;
user: User;
description: SafeHtml;
constructor(
private activatedRoute: ActivatedRoute,
private listingsService: ListingsService,
private router: Router,
private userService: UserService,
public selectOptions: SelectOptionsService,
private mailService: MailService,
private messageService: MessageService,
private sanitizer: DomSanitizer,
) {
this.userService.getUserObservable().subscribe(user => {
this.user = user;
});
this.criteria = onChange(getCriteriaStateObject(), getSessionStorageHandler);
this.mailinfo = { sender: {}, userId: '' };
}
async ngOnInit() {
this.listing = await lastValueFrom(this.listingsService.getListingById(this.id, this.type));
this.propertyImages = await this.listingsService.getPropertyImages(this.listing.id);
this.description = this.sanitizer.bypassSecurityTrustHtml(this.listing.description);
}
back() {
this.router.navigate(['businessListings']);
}
isAdmin() {
return this.userService.hasAdminRole();
}
async mail() {
this.mailinfo.userId = this.listing.userId;
await this.mailService.mail(this.mailinfo);
this.messageService.add({ severity: 'info', summary: 'Confirmed', detail: 'Your message has been sent to the creator of the listing', life: 3000 });
}
}