Paginator & SQL Querries where clauses & city search
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { environment } from '../../environments/environment';
|
||||
import { Observable } from 'rxjs';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
export interface GeoResult { city: string; state: string; state_code: string }
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { GeoResult } from '../../../../bizmatch-server/src/models/main.model';
|
||||
import { environment } from '../../environments/environment';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class GeoService {
|
||||
|
||||
private apiBaseUrl = environment.apiBaseUrl;
|
||||
constructor(private http: HttpClient) { }
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
findCitiesStartingWith(prefix:string, state?:string):Observable<GeoResult[]>{
|
||||
const stateString = state?`/${state}`:''
|
||||
findCitiesStartingWith(prefix: string, state?: string): Observable<GeoResult[]> {
|
||||
const stateString = state ? `/${state}` : '';
|
||||
return this.http.get<GeoResult[]>(`${this.apiBaseUrl}/bizmatch/geo/${prefix}${stateString}`);
|
||||
}
|
||||
}
|
||||
|
||||
17
bizmatch/src/app/services/search.service.ts
Normal file
17
bizmatch/src/app/services/search.service.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { BusinessListingCriteria, CommercialPropertyListingCriteria, UserListingCriteria } from '../../../../bizmatch-server/src/models/main.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class SearchService {
|
||||
private criteriaSource = new BehaviorSubject<BusinessListingCriteria | CommercialPropertyListingCriteria | UserListingCriteria>(null);
|
||||
currentCriteria = this.criteriaSource.asObservable();
|
||||
|
||||
constructor() {}
|
||||
|
||||
search(criteria: BusinessListingCriteria | CommercialPropertyListingCriteria | UserListingCriteria): void {
|
||||
this.criteriaSource.next(criteria);
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,9 @@ export class SelectOptionsService {
|
||||
getState(value: string): string {
|
||||
return this.states.find(l => l.value === value)?.name;
|
||||
}
|
||||
getStateInitials(name: string): string {
|
||||
return this.states.find(l => l.name === name?.toUpperCase())?.value;
|
||||
}
|
||||
getBusiness(value: string): string {
|
||||
return this.typesOfBusiness.find(t => t.value === value)?.name;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user