Compare commits
2 Commits
8b71b073be
...
8698aa3e66
| Author | SHA1 | Date |
|---|---|---|
|
|
8698aa3e66 | |
|
|
398f8d29ca |
|
|
@ -102,7 +102,7 @@ export class BusinessListingService {
|
||||||
if (criteria.brokerName) {
|
if (criteria.brokerName) {
|
||||||
whereConditions.push(or(ilike(schema.users.firstname, `%${criteria.brokerName}%`), ilike(schema.users.lastname, `%${criteria.brokerName}%`)));
|
whereConditions.push(or(ilike(schema.users.firstname, `%${criteria.brokerName}%`), ilike(schema.users.lastname, `%${criteria.brokerName}%`)));
|
||||||
}
|
}
|
||||||
|
whereConditions.push(and(eq(schema.users.customerType, 'professional'), eq(schema.users.customerSubType, 'broker')));
|
||||||
return whereConditions;
|
return whereConditions;
|
||||||
}
|
}
|
||||||
async searchBusinessListings(criteria: BusinessListingCriteria, user: JwtUser) {
|
async searchBusinessListings(criteria: BusinessListingCriteria, user: JwtUser) {
|
||||||
|
|
|
||||||
|
|
@ -53,14 +53,14 @@ export class CommercialPropertyService {
|
||||||
if (criteria.title) {
|
if (criteria.title) {
|
||||||
whereConditions.push(or(ilike(schema.commercials.title, `%${criteria.title}%`), ilike(schema.commercials.description, `%${criteria.title}%`)));
|
whereConditions.push(or(ilike(schema.commercials.title, `%${criteria.title}%`), ilike(schema.commercials.description, `%${criteria.title}%`)));
|
||||||
}
|
}
|
||||||
|
whereConditions.push(and(eq(schema.users.customerType, 'professional')));
|
||||||
return whereConditions;
|
return whereConditions;
|
||||||
}
|
}
|
||||||
// #### Find by criteria ########################################
|
// #### Find by criteria ########################################
|
||||||
async searchCommercialProperties(criteria: CommercialPropertyListingCriteria, user: JwtUser): Promise<any> {
|
async searchCommercialProperties(criteria: CommercialPropertyListingCriteria, user: JwtUser): Promise<any> {
|
||||||
const start = criteria.start ? criteria.start : 0;
|
const start = criteria.start ? criteria.start : 0;
|
||||||
const length = criteria.length ? criteria.length : 12;
|
const length = criteria.length ? criteria.length : 12;
|
||||||
const query = this.conn.select().from(schema.commercials);
|
const query = this.conn.select({ commercial: commercials }).from(commercials).leftJoin(schema.users, eq(commercials.email, schema.users.email));
|
||||||
const whereConditions = this.getWhereConditions(criteria);
|
const whereConditions = this.getWhereConditions(criteria);
|
||||||
|
|
||||||
if (whereConditions.length > 0) {
|
if (whereConditions.length > 0) {
|
||||||
|
|
@ -71,7 +71,8 @@ export class CommercialPropertyService {
|
||||||
// Paginierung
|
// Paginierung
|
||||||
query.limit(length).offset(start);
|
query.limit(length).offset(start);
|
||||||
|
|
||||||
const results = await query;
|
const data = await query;
|
||||||
|
const results = data.map(r => r.commercial);
|
||||||
const totalCount = await this.getCommercialPropertiesCount(criteria);
|
const totalCount = await this.getCommercialPropertiesCount(criteria);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -80,7 +81,7 @@ export class CommercialPropertyService {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
async getCommercialPropertiesCount(criteria: CommercialPropertyListingCriteria): Promise<number> {
|
async getCommercialPropertiesCount(criteria: CommercialPropertyListingCriteria): Promise<number> {
|
||||||
const countQuery = this.conn.select({ value: count() }).from(schema.commercials);
|
const countQuery = this.conn.select({ value: count() }).from(schema.commercials).leftJoin(schema.users, eq(commercials.email, schema.users.email));
|
||||||
const whereConditions = this.getWhereConditions(criteria);
|
const whereConditions = this.getWhereConditions(criteria);
|
||||||
|
|
||||||
if (whereConditions.length > 0) {
|
if (whereConditions.length > 0) {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ export class UserService {
|
||||||
|
|
||||||
private getWhereConditions(criteria: UserListingCriteria): SQL[] {
|
private getWhereConditions(criteria: UserListingCriteria): SQL[] {
|
||||||
const whereConditions: SQL[] = [];
|
const whereConditions: SQL[] = [];
|
||||||
|
whereConditions.push(eq(schema.users.customerType, 'professional'));
|
||||||
if (criteria.city && criteria.searchType === 'exact') {
|
if (criteria.city && criteria.searchType === 'exact') {
|
||||||
whereConditions.push(ilike(schema.users.companyLocation, `%${criteria.city}%`));
|
whereConditions.push(ilike(schema.users.companyLocation, `%${criteria.city}%`));
|
||||||
}
|
}
|
||||||
|
|
@ -53,9 +53,6 @@ export class UserService {
|
||||||
whereConditions.push(or(...criteria.counties.map(county => sql`EXISTS (SELECT 1 FROM jsonb_array_elements(${schema.users.areasServed}) AS area WHERE area->>'county' ILIKE ${`%${county}%`})`)));
|
whereConditions.push(or(...criteria.counties.map(county => sql`EXISTS (SELECT 1 FROM jsonb_array_elements(${schema.users.areasServed}) AS area WHERE area->>'county' ILIKE ${`%${county}%`})`)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (criteria.states && criteria.states.length > 0) {
|
|
||||||
// whereConditions.push(or(...criteria.states.map(state => sql`EXISTS (SELECT 1 FROM jsonb_array_elements(${schema.users.areasServed}) AS area WHERE area->>'state' = ${state})`)));
|
|
||||||
// }
|
|
||||||
if (criteria.state) {
|
if (criteria.state) {
|
||||||
whereConditions.push(sql`EXISTS (SELECT 1 FROM jsonb_array_elements(${schema.users.areasServed}) AS area WHERE area->>'state' = ${criteria.state})`);
|
whereConditions.push(sql`EXISTS (SELECT 1 FROM jsonb_array_elements(${schema.users.areasServed}) AS area WHERE area->>'state' = ${criteria.state})`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,16 +13,16 @@
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "^18.0.6",
|
"@angular/animations": "^18.1.3",
|
||||||
"@angular/cdk": "^18.0.6",
|
"@angular/cdk": "^18.0.6",
|
||||||
"@angular/common": "^18.0.6",
|
"@angular/common": "^18.1.3",
|
||||||
"@angular/compiler": "^18.0.6",
|
"@angular/compiler": "^18.1.3",
|
||||||
"@angular/core": "^18.0.6",
|
"@angular/core": "^18.1.3",
|
||||||
"@angular/forms": "^18.0.6",
|
"@angular/forms": "^18.1.3",
|
||||||
"@angular/platform-browser": "^18.0.6",
|
"@angular/platform-browser": "^18.1.3",
|
||||||
"@angular/platform-browser-dynamic": "^18.0.6",
|
"@angular/platform-browser-dynamic": "^18.1.3",
|
||||||
"@angular/platform-server": "^18.0.6",
|
"@angular/platform-server": "^18.1.3",
|
||||||
"@angular/router": "^18.0.6",
|
"@angular/router": "^18.1.3",
|
||||||
"@fortawesome/angular-fontawesome": "^0.15.0",
|
"@fortawesome/angular-fontawesome": "^0.15.0",
|
||||||
"@fortawesome/fontawesome-free": "^6.5.2",
|
"@fortawesome/fontawesome-free": "^6.5.2",
|
||||||
"@fortawesome/fontawesome-svg-core": "^6.5.2",
|
"@fortawesome/fontawesome-svg-core": "^6.5.2",
|
||||||
|
|
@ -52,9 +52,9 @@
|
||||||
"zone.js": "~0.14.7"
|
"zone.js": "~0.14.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/build-angular": "^18.0.7",
|
"@angular-devkit/build-angular": "^18.1.3",
|
||||||
"@angular/cli": "^18.0.7",
|
"@angular/cli": "^18.1.3",
|
||||||
"@angular/compiler-cli": "^18.0.6",
|
"@angular/compiler-cli": "^18.1.3",
|
||||||
"@types/express": "^4.17.21",
|
"@types/express": "^4.17.21",
|
||||||
"@types/jasmine": "~5.1.4",
|
"@types/jasmine": "~5.1.4",
|
||||||
"@types/node": "^20.14.9",
|
"@types/node": "^20.14.9",
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,10 @@
|
||||||
@if (loadingService.isLoading$ | async) {
|
@if (loadingService.isLoading$ | async) {
|
||||||
<div class="spinner-overlay">
|
<div class="spinner-overlay">
|
||||||
<div class="spinner-container">
|
<div class="spinner-container">
|
||||||
<div class="spinner-text" *ngIf="loadingService.loadingText$ | async as loadingText">{{ loadingText }}</div>
|
@let loadingText = (loadingService.loadingText$ | async);
|
||||||
|
<!-- @if(loadingService.loadingText$ | async){ -->
|
||||||
|
<div class="spinner-text">{{ loadingText }}</div>
|
||||||
|
<!-- } -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { AsyncPipe, NgIf } from '@angular/common';
|
import { AsyncPipe, NgIf } from '@angular/common';
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { NgSelectModule } from '@ng-select/ng-select';
|
import { NgSelectModule } from '@ng-select/ng-select';
|
||||||
|
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
|
||||||
import { catchError, concat, debounceTime, distinctUntilChanged, map, Observable, of, Subject, Subscription, switchMap, tap } from 'rxjs';
|
import { catchError, concat, debounceTime, distinctUntilChanged, map, Observable, of, Subject, Subscription, switchMap, tap } from 'rxjs';
|
||||||
import { BusinessListingCriteria, CommercialPropertyListingCriteria, CountyResult, GeoResult, KeyValue, KeyValueStyle, UserListingCriteria } from '../../../../../bizmatch-server/src/models/main.model';
|
import { BusinessListingCriteria, CommercialPropertyListingCriteria, CountyResult, GeoResult, KeyValue, KeyValueStyle, UserListingCriteria } from '../../../../../bizmatch-server/src/models/main.model';
|
||||||
import { CriteriaChangeService } from '../../services/criteria-change.service';
|
import { CriteriaChangeService } from '../../services/criteria-change.service';
|
||||||
|
|
@ -10,7 +11,7 @@ import { SelectOptionsService } from '../../services/select-options.service';
|
||||||
import { UserService } from '../../services/user.service';
|
import { UserService } from '../../services/user.service';
|
||||||
import { SharedModule } from '../../shared/shared/shared.module';
|
import { SharedModule } from '../../shared/shared/shared.module';
|
||||||
import { ModalService } from './modal.service';
|
import { ModalService } from './modal.service';
|
||||||
|
@UntilDestroy()
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-search-modal',
|
selector: 'app-search-modal',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
|
|
@ -38,10 +39,15 @@ export class SearchModalComponent {
|
||||||
) {}
|
) {}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.setupCriteriaChangeListener();
|
this.setupCriteriaChangeListener();
|
||||||
this.modalService.message$.subscribe(msg => {
|
this.modalService.message$.pipe(untilDestroyed(this)).subscribe(msg => {
|
||||||
this.criteria = msg;
|
this.criteria = msg;
|
||||||
this.setTotalNumberOfResults();
|
this.setTotalNumberOfResults();
|
||||||
});
|
});
|
||||||
|
this.modalService.modalVisible$.pipe(untilDestroyed(this)).subscribe(val => {
|
||||||
|
if (val) {
|
||||||
|
this.criteria.page = 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
this.loadCities();
|
this.loadCities();
|
||||||
this.loadCounties();
|
this.loadCounties();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,7 @@ export class HomeComponent {
|
||||||
this.criteria.radius = 20;
|
this.criteria.radius = 20;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
this.criteria.state = null;
|
||||||
this.criteria.city = null;
|
this.criteria.city = null;
|
||||||
this.criteria.radius = null;
|
this.criteria.radius = null;
|
||||||
this.criteria.searchType = 'exact';
|
this.criteria.searchType = 'exact';
|
||||||
|
|
|
||||||
|
|
@ -58,12 +58,11 @@ export class BusinessListingsComponent {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
async ngOnInit() {}
|
async ngOnInit() {
|
||||||
|
this.search();
|
||||||
|
}
|
||||||
async init() {
|
async init() {
|
||||||
this.reset();
|
this.reset();
|
||||||
const statesResult = await this.listingsService.getAllStates('business');
|
|
||||||
this.states = statesResult.map(ls => ({ name: this.selectOptions.getState(ls.state as string), value: ls.state, count: ls.count }));
|
|
||||||
this.search();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async search() {
|
async search() {
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@
|
||||||
@for (listing of listings; track listing.id) {
|
@for (listing of listings; track listing.id) {
|
||||||
<div class="bg-white rounded-lg shadow-md overflow-hidden">
|
<div class="bg-white rounded-lg shadow-md overflow-hidden">
|
||||||
@if (listing.imageOrder?.length>0){
|
@if (listing.imageOrder?.length>0){
|
||||||
<img src="{{ env.imageBaseUrl }}/pictures/property/{{ listing.imagePath }}/{{ listing.serialId }}/{{ listing.imageOrder[0] }}?_ts={{ getTS() }}" alt="Image" class="w-full h-48 object-cover" />
|
<img src="{{ env.imageBaseUrl }}/pictures/property/{{ listing.imagePath }}/{{ listing.serialId }}/{{ listing.imageOrder[0] }}" alt="Image" class="w-full h-48 object-cover" />
|
||||||
} @else {
|
} @else {
|
||||||
<img src="assets/images/placeholder_properties.jpg" alt="Image" class="w-full h-48 object-cover" />
|
<img src="assets/images/placeholder_properties.jpg" alt="Image" class="w-full h-48 object-cover" />
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ export class CommercialPropertyListingsComponent {
|
||||||
env = environment;
|
env = environment;
|
||||||
page = 1;
|
page = 1;
|
||||||
pageCount = 1;
|
pageCount = 1;
|
||||||
|
ts = new Date().getTime();
|
||||||
constructor(
|
constructor(
|
||||||
public selectOptions: SelectOptionsService,
|
public selectOptions: SelectOptionsService,
|
||||||
private listingsService: ListingsService,
|
private listingsService: ListingsService,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue