Paginator & SQL Querries where clauses & city search

This commit is contained in:
2024-07-18 19:02:32 +02:00
parent f88eebe8d3
commit abcde3991d
30 changed files with 850 additions and 421 deletions

View File

@@ -2,14 +2,14 @@ import { CommonModule } from '@angular/common';
import { ChangeDetectorRef, Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
import onChange from 'on-change';
import { CommercialPropertyListing } from '../../../../../../bizmatch-server/src/models/db.model';
import { CommercialPropertyListingCriteria } from '../../../../../../bizmatch-server/src/models/main.model';
import { CommercialPropertyListingCriteria, ResponseCommercialPropertyListingArray } from '../../../../../../bizmatch-server/src/models/main.model';
import { environment } from '../../../../environments/environment';
import { ImageService } from '../../../services/image.service';
import { ListingsService } from '../../../services/listings.service';
import { SearchService } from '../../../services/search.service';
import { SelectOptionsService } from '../../../services/select-options.service';
import { getCriteriaStateObject, getSessionStorageHandlerWrapper } from '../../../utils/utils';
import { getCriteriaStateObject } from '../../../utils/utils';
@Component({
selector: 'app-commercial-property-listings',
@@ -43,15 +43,23 @@ export class CommercialPropertyListingsComponent {
private cdRef: ChangeDetectorRef,
private imageService: ImageService,
private route: ActivatedRoute,
private searchService: SearchService,
) {
this.criteria = onChange(getCriteriaStateObject('commercialProperty'), getSessionStorageHandlerWrapper('commercialProperty'));
this.route.data.subscribe(async () => {
if (this.router.getCurrentNavigation().extras.state) {
} else {
this.first = this.criteria.page * this.criteria.length;
this.rows = this.criteria.length;
this.criteria = getCriteriaStateObject('commercialProperty');
// this.route.data.subscribe(async () => {
// if (this.router.getCurrentNavigation().extras.state) {
// } else {
// this.first = this.criteria.page * this.criteria.length;
// this.rows = this.criteria.length;
// }
// this.init();
// });
this.init();
this.searchService.currentCriteria.subscribe(criteria => {
if (criteria && criteria.criteriaType === 'commercialProperty') {
this.criteria = criteria as CommercialPropertyListingCriteria;
this.search();
}
this.init();
});
}
async ngOnInit() {}
@@ -67,8 +75,8 @@ export class CommercialPropertyListingsComponent {
}
async search() {
const listingReponse = await this.listingsService.getListings(this.criteria, 'commercialProperty');
this.listings = listingReponse.data;
this.totalRecords = listingReponse.total;
this.listings = (<ResponseCommercialPropertyListingArray>listingReponse).results;
this.totalRecords = (<ResponseCommercialPropertyListingArray>listingReponse).totalCount;
this.cdRef.markForCheck();
this.cdRef.detectChanges();
}