diff --git a/bizmatch-server/src/models/main.model.ts b/bizmatch-server/src/models/main.model.ts index aa423aa..e4d332c 100644 --- a/bizmatch-server/src/models/main.model.ts +++ b/bizmatch-server/src/models/main.model.ts @@ -64,7 +64,7 @@ export interface ListCriteria { searchType: 'exact' | 'radius'; // radius: '5' | '20' | '50' | '100' | '200' | '300' | '400' | '500'; radius: number; - criteriaType: 'business' | 'commercialProperty' | 'broker'; + criteriaType: 'businessListings' | 'commercialPropertyListings' | 'brokerListings'; } export interface BusinessListingCriteria extends ListCriteria { minPrice: number; @@ -82,20 +82,20 @@ export interface BusinessListingCriteria extends ListCriteria { franchiseResale: boolean; title: string; brokerName: string; - criteriaType: 'business'; + criteriaType: 'businessListings'; } export interface CommercialPropertyListingCriteria extends ListCriteria { minPrice: number; maxPrice: number; title: string; - criteriaType: 'commercialProperty'; + criteriaType: 'commercialPropertyListings'; } export interface UserListingCriteria extends ListCriteria { firstname: string; lastname: string; companyName: string; counties: string[]; - criteriaType: 'broker'; + criteriaType: 'brokerListings'; } export interface KeycloakUser { diff --git a/bizmatch-server/src/user/user.service.ts b/bizmatch-server/src/user/user.service.ts index f06d2a3..8b0d974 100644 --- a/bizmatch-server/src/user/user.service.ts +++ b/bizmatch-server/src/user/user.service.ts @@ -72,7 +72,8 @@ export class UserService { // Paginierung query.limit(length).offset(start); - const results = await query; + const data = await query; + const results = data.map(r => convertDrizzleUserToUser(r)); const totalCount = await this.getUserListingsCount(criteria); return { @@ -117,7 +118,7 @@ export class UserService { const user = users[0]; user.hasCompanyLogo = this.fileService.hasCompanyLogo(emailToDirName(user.email)); user.hasProfile = this.fileService.hasProfile(emailToDirName(user.email)); - return user; + return convertDrizzleUserToUser(user); } async saveUser(user: User): Promise { try { @@ -131,7 +132,7 @@ export class UserService { const drizzleUser = convertUserToDrizzleUser(validatedUser); if (user.id) { const [updateUser] = await this.conn.update(schema.users).set(drizzleUser).where(eq(schema.users.id, user.id)).returning(); - return updateUser as User; + return convertDrizzleUserToUser(updateUser) as User; } else { const [newUser] = await this.conn.insert(schema.users).values(drizzleUser).returning(); return convertDrizzleUserToUser(newUser) as User; diff --git a/bizmatch-server/src/utils.ts b/bizmatch-server/src/utils.ts index 26f9e9b..d25832a 100644 --- a/bizmatch-server/src/utils.ts +++ b/bizmatch-server/src/utils.ts @@ -67,69 +67,22 @@ export function convertDrizzleCommercialToCommercial(drizzleCommercialPropertyLi return unflattenObject(o); } export function convertUserToDrizzleUser(user: Partial): DrizzleUser { - const { companyLocation, ...restUser } = user; - - // Ensure all required fields are present - if (!user.email || !user.firstname || !user.lastname) { - throw new Error('Missing required fields: email, firstname, or lastname'); - } - - return { - id: user.id, - email: user.email, - firstname: user.firstname, - lastname: user.lastname, - phoneNumber: user.phoneNumber || null, - description: user.description || null, - companyName: user.companyName || null, - companyOverview: user.companyOverview || null, - companyWebsite: user.companyWebsite || null, - city: companyLocation?.city || null, - state: companyLocation?.state || null, - offeredServices: user.offeredServices || null, - areasServed: user.areasServed || [], - hasProfile: user.hasProfile || false, - hasCompanyLogo: user.hasCompanyLogo || false, - licensedIn: user.licensedIn || [], - gender: user.gender || null, - customerType: user.customerType || null, - customerSubType: user.customerSubType || null, - created: user.created || new Date(), - updated: user.updated || new Date(), - latitude: companyLocation?.latitude || 0, - longitude: companyLocation?.longitude || 0, - }; + return flattenObject(user); } export function convertDrizzleUserToUser(drizzleUser: Partial): User { - const user = { - id: drizzleUser.id, - firstname: drizzleUser.firstname, - lastname: drizzleUser.lastname, - email: drizzleUser.email, - phoneNumber: drizzleUser.phoneNumber ?? null, - description: drizzleUser.description ?? null, - companyName: drizzleUser.companyName ?? null, - companyOverview: drizzleUser.companyOverview ?? null, - companyWebsite: drizzleUser.companyWebsite ?? null, - companyLocation: { - city: drizzleUser.city, - state: drizzleUser.state, - latitude: drizzleUser.latitude, // Latitude wird zugewiesen, auch wenn es nicht direkt benötigt wird - longitude: drizzleUser.longitude, // Longitude wird zugewiesen, auch wenn es nicht direkt benötigt wird - }, - offeredServices: drizzleUser.offeredServices ?? null, - areasServed: drizzleUser.areasServed ?? null, - hasProfile: drizzleUser.hasProfile ?? null, - hasCompanyLogo: drizzleUser.hasCompanyLogo ?? null, - licensedIn: drizzleUser.licensedIn ?? null, - gender: drizzleUser.gender ?? null, - customerType: drizzleUser.customerType, - customerSubType: drizzleUser.customerSubType ?? null, - created: drizzleUser.created ?? null, - updated: drizzleUser.updated ?? null, + const o = { + companyLocation_city: drizzleUser.city, + companyLocation_state: drizzleUser.state, + companyLocation_latitude: drizzleUser.latitude, + companyLocation_longitude: drizzleUser.longitude, + ...drizzleUser, }; - return user; + delete o.city; + delete o.state; + delete o.latitude; + delete o.longitude; + return unflattenObject(o); } function flattenObject(obj: any, res: any = {}): any { for (const key in obj) { diff --git a/bizmatch/src/app/components/header/header.component.html b/bizmatch/src/app/components/header/header.component.html index fa32ec7..26c6be3 100644 --- a/bizmatch/src/app/components/header/header.component.html +++ b/bizmatch/src/app/components/header/header.component.html @@ -206,7 +206,7 @@ [ngClass]="{ 'bg-blue-700 text-white md:text-blue-700 md:bg-transparent md:dark:text-blue-500': isActive('/businessListings') }" class="block py-2 px-3 rounded hover:bg-gray-100 md:hover:bg-transparent md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent dark:border-gray-700" aria-current="page" - (click)="closeMenus()" + (click)="closeMenusAndSetCriteria('businessListings')" >Businesses @@ -216,7 +216,7 @@ routerLink="/commercialPropertyListings" [ngClass]="{ 'bg-blue-700 text-white md:text-blue-700 md:bg-transparent md:dark:text-blue-500': isActive('/commercialPropertyListings') }" class="block py-2 px-3 rounded hover:bg-gray-100 md:hover:bg-transparent md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent dark:border-gray-700" - (click)="closeMenus()" + (click)="closeMenusAndSetCriteria('commercialPropertyListings')" >Properties @@ -226,7 +226,7 @@ routerLink="/brokerListings" [ngClass]="{ 'bg-blue-700 text-white md:text-blue-700 md:bg-transparent md:dark:text-blue-500': isActive('/brokerListings') }" class="block py-2 px-3 rounded hover:bg-gray-100 md:hover:bg-transparent md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent dark:border-gray-700" - (click)="closeMenus()" + (click)="closeMenusAndSetCriteria('brokerListings')" >Professionals @@ -247,141 +247,3 @@ } - - - - - diff --git a/bizmatch/src/app/components/header/header.component.ts b/bizmatch/src/app/components/header/header.component.ts index d0ec527..e498aac 100644 --- a/bizmatch/src/app/components/header/header.component.ts +++ b/bizmatch/src/app/components/header/header.component.ts @@ -6,7 +6,6 @@ import { NavigationEnd, Router, RouterModule } from '@angular/router'; import { faUserGear } from '@fortawesome/free-solid-svg-icons'; import { Collapse, Dropdown, initFlowbite } from 'flowbite'; import { KeycloakService } from 'keycloak-angular'; -import onChange from 'on-change'; import { filter, Observable, Subject, Subscription } from 'rxjs'; import { User } from '../../../../../bizmatch-server/src/models/db.model'; import { BusinessListingCriteria, CommercialPropertyListingCriteria, emailToDirName, KeycloakUser, UserListingCriteria } from '../../../../../bizmatch-server/src/models/main.model'; @@ -15,7 +14,7 @@ import { CriteriaChangeService } from '../../services/criteria-change.service'; import { SearchService } from '../../services/search.service'; import { SharedService } from '../../services/shared.service'; import { UserService } from '../../services/user.service'; -import { compareObjects, createEmptyBusinessListingCriteria, createEmptyCommercialPropertyListingCriteria, createEmptyUserListingCriteria, getCriteriaStateObject, map2User } from '../../utils/utils'; +import { compareObjects, createEmptyBusinessListingCriteria, createEmptyCommercialPropertyListingCriteria, createEmptyUserListingCriteria, getCriteriaProxy, map2User } from '../../utils/utils'; import { DropdownComponent } from '../dropdown/dropdown.component'; import { ModalService } from '../search-modal/modal.service'; @Component({ @@ -80,43 +79,43 @@ export class HeaderComponent { private checkCurrentRoute(url: string): void { this.baseRoute = url.split('/')[1]; // Nimmt den ersten Teil der Route nach dem ersten '/' const specialRoutes = [, '', '']; - if ('businessListings' === this.baseRoute) { - //this.criteria = onChange(getCriteriaStateObject('business'), getSessionStorageHandlerWrapper('business')); - //this.criteria = onChange(getCriteriaStateObject('business'), this.getSessionStorageHandler); - this.criteria = this.createEnhancedProxy(getCriteriaStateObject('business')); - } else if ('commercialPropertyListings' === this.baseRoute) { - // this.criteria = onChange(getCriteriaStateObject('commercialProperty'), getSessionStorageHandlerWrapper('commercialProperty')); - this.criteria = this.createEnhancedProxy(getCriteriaStateObject('commercialProperty')); - } else if ('brokerListings' === this.baseRoute) { - // this.criteria = onChange(getCriteriaStateObject('broker'), getSessionStorageHandlerWrapper('broker')); - this.criteria = this.createEnhancedProxy(getCriteriaStateObject('broker')); - } else { - this.criteria = undefined; - } + this.criteria = getCriteriaProxy(this.baseRoute, this); + this.searchService.search(this.criteria); } - private createEnhancedProxy(obj: any) { - const component = this; + // getCriteriaProxy(path:string):BusinessListingCriteria | CommercialPropertyListingCriteria | UserListingCriteria{ + // if ('businessListings' === path) { + // return this.createEnhancedProxy(getCriteriaStateObject('business')); + // } else if ('commercialPropertyListings' === path) { + // return this.createEnhancedProxy(getCriteriaStateObject('commercialProperty')); + // } else if ('brokerListings' === path) { + // return this.createEnhancedProxy(getCriteriaStateObject('broker')); + // } else { + // return undefined; + // } + // } + // private createEnhancedProxy(obj: any) { + // const component = this; - const sessionStorageHandler = function (path, value, previous, applyData) { - let criteriaType = ''; - if ('/businessListings' === window.location.pathname) { - criteriaType = 'business'; - } else if ('/commercialPropertyListings' === window.location.pathname) { - criteriaType = 'commercialProperty'; - } else if ('/brokerListings' === window.location.pathname) { - criteriaType = 'broker'; - } - sessionStorage.setItem(`${criteriaType}_criteria`, JSON.stringify(this)); - }; + // const sessionStorageHandler = function (path, value, previous, applyData) { + // let criteriaType = ''; + // if ('/businessListings' === window.location.pathname) { + // criteriaType = 'business'; + // } else if ('/commercialPropertyListings' === window.location.pathname) { + // criteriaType = 'commercialProperty'; + // } else if ('/brokerListings' === window.location.pathname) { + // criteriaType = 'broker'; + // } + // sessionStorage.setItem(`${criteriaType}_criteria`, JSON.stringify(this)); + // }; - return onChange(obj, function (path, value, previous, applyData) { - // Call the original sessionStorageHandler - sessionStorageHandler.call(this, path, value, previous, applyData); + // return onChange(obj, function (path, value, previous, applyData) { + // // Call the original sessionStorageHandler + // sessionStorageHandler.call(this, path, value, previous, applyData); - // Notify about the criteria change using the component's context - component.criteriaChangeService.notifyCriteriaChange(); - }); - } + // // Notify about the criteria change using the component's context + // component.criteriaChangeService.notifyCriteriaChange(); + // }); + // } ngAfterViewInit() {} @@ -161,9 +160,12 @@ export class HeaderComponent { collapse.collapse(); } } - closeMenus() { + closeMenusAndSetCriteria(path: string) { this.closeDropdown(); this.closeMobileMenu(); + const criteria = getCriteriaProxy(path, this); + criteria.page = 1; + criteria.start = 0; } ngOnDestroy() { @@ -171,11 +173,11 @@ export class HeaderComponent { this.destroy$.complete(); } getNumberOfFiltersSet() { - if (this.criteria?.criteriaType === 'broker') { + if (this.criteria?.criteriaType === 'brokerListings') { return compareObjects(createEmptyUserListingCriteria(), this.criteria, ['start', 'length', 'page', 'searchType', 'radius']); - } else if (this.criteria?.criteriaType === 'business') { + } else if (this.criteria?.criteriaType === 'businessListings') { return compareObjects(createEmptyBusinessListingCriteria(), this.criteria, ['start', 'length', 'page', 'searchType', 'radius']); - } else if (this.criteria?.criteriaType === 'commercialProperty') { + } else if (this.criteria?.criteriaType === 'commercialPropertyListings') { return compareObjects(createEmptyCommercialPropertyListingCriteria(), this.criteria, ['start', 'length', 'page', 'searchType', 'radius']); } else { return 0; diff --git a/bizmatch/src/app/components/search-modal/search-modal.component.html b/bizmatch/src/app/components/search-modal/search-modal.component.html index ac9b0d0..1ea9f1e 100644 --- a/bizmatch/src/app/components/search-modal/search-modal.component.html +++ b/bizmatch/src/app/components/search-modal/search-modal.component.html @@ -15,7 +15,7 @@ - @if(criteria.criteriaType==='business'){ + @if(criteria.criteriaType==='businessListings'){
@@ -233,7 +233,7 @@
- } @if(criteria.criteriaType==='commercialProperty'){ + } @if(criteria.criteriaType==='commercialPropertyListings'){
@@ -341,7 +341,7 @@
- } @if(criteria.criteriaType==='broker'){ + } @if(criteria.criteriaType==='brokerListings'){
diff --git a/bizmatch/src/app/components/search-modal/search-modal.component.ts b/bizmatch/src/app/components/search-modal/search-modal.component.ts index 8594bb8..8f748a9 100644 --- a/bizmatch/src/app/components/search-modal/search-modal.component.ts +++ b/bizmatch/src/app/components/search-modal/search-modal.component.ts @@ -46,6 +46,7 @@ export class SearchModalComponent { this.modalService.modalVisible$.pipe(untilDestroyed(this)).subscribe(val => { if (val) { this.criteria.page = 1; + this.criteria.start = 0; } }); this.loadCities(); @@ -137,9 +138,9 @@ export class SearchModalComponent { setTotalNumberOfResults() { if (this.criteria) { console.log(`Getting total number of results for ${this.criteria.criteriaType}`); - if (this.criteria.criteriaType === 'business' || this.criteria.criteriaType === 'commercialProperty') { - this.numberOfResults$ = this.listingService.getNumberOfListings(this.criteria, this.criteria.criteriaType); - } else if (this.criteria.criteriaType === 'broker') { + if (this.criteria.criteriaType === 'businessListings' || this.criteria.criteriaType === 'commercialPropertyListings') { + this.numberOfResults$ = this.listingService.getNumberOfListings(this.criteria, this.criteria.criteriaType === 'businessListings' ? 'business' : 'commercialProperty'); + } else if (this.criteria.criteriaType === 'brokerListings') { this.numberOfResults$ = this.userService.getNumberOfBroker(this.criteria); } else { this.numberOfResults$ = of(); diff --git a/bizmatch/src/app/pages/details/details-business-listing/details-business-listing.component.ts b/bizmatch/src/app/pages/details/details-business-listing/details-business-listing.component.ts index a325d5a..650649a 100644 --- a/bizmatch/src/app/pages/details/details-business-listing/details-business-listing.component.ts +++ b/bizmatch/src/app/pages/details/details-business-listing/details-business-listing.component.ts @@ -2,10 +2,9 @@ import { Component } from '@angular/core'; import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; import { ActivatedRoute, NavigationEnd, Router } from '@angular/router'; import { KeycloakService } from 'keycloak-angular'; -import onChange from 'on-change'; import { lastValueFrom } from 'rxjs'; import { BusinessListing, User } from '../../../../../../bizmatch-server/src/models/db.model'; -import { BusinessListingCriteria, KeycloakUser, MailInfo } from '../../../../../../bizmatch-server/src/models/main.model'; +import { KeycloakUser, MailInfo } from '../../../../../../bizmatch-server/src/models/main.model'; import { environment } from '../../../../environments/environment'; import { MessageService } from '../../../components/message/message.service'; import { ValidatedInputComponent } from '../../../components/validated-input/validated-input.component'; @@ -17,7 +16,7 @@ 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, map2User } from '../../../utils/utils'; +import { map2User } from '../../../utils/utils'; @Component({ selector: 'app-details-business-listing', standalone: true, @@ -47,7 +46,6 @@ export class DetailsBusinessListingComponent { ]; private id: string | undefined = this.activatedRoute.snapshot.params['id'] as string | undefined; listing: BusinessListing; - criteria: BusinessListingCriteria; mailinfo: MailInfo; environment = environment; keycloakUser: KeycloakUser; @@ -76,7 +74,6 @@ export class DetailsBusinessListingComponent { } }); this.mailinfo = { sender: {}, email: '', url: environment.mailinfoUrl }; - this.criteria = onChange(getCriteriaStateObject('business'), getSessionStorageHandler.bind('business')); } async ngOnInit() { diff --git a/bizmatch/src/app/pages/details/details-commercial-property-listing/details-commercial-property-listing.component.html b/bizmatch/src/app/pages/details/details-commercial-property-listing/details-commercial-property-listing.component.html index c42cae6..9a3e417 100644 --- a/bizmatch/src/app/pages/details/details-commercial-property-listing/details-commercial-property-listing.component.html +++ b/bizmatch/src/app/pages/details/details-commercial-property-listing/details-commercial-property-listing.component.html @@ -101,8 +101,11 @@

{{ listing?.title }}

-
@if (listing && listing.imageOrder && listing.imageOrder.length > 0) { diff --git a/bizmatch/src/app/pages/details/details-user/details-user.component.html b/bizmatch/src/app/pages/details/details-user/details-user.component.html index f1fb38d..7622afe 100644 --- a/bizmatch/src/app/pages/details/details-user/details-user.component.html +++ b/bizmatch/src/app/pages/details/details-user/details-user.component.html @@ -138,7 +138,7 @@ @if(user){
-
+
@if(user.hasProfile){ @@ -167,7 +167,12 @@ }
- +
@@ -194,7 +199,7 @@
Company Location - {{ user.companyLocation }} + {{ user.companyLocation.city }} - {{ user.companyLocation.state }}
diff --git a/bizmatch/src/app/pages/home/home.component.ts b/bizmatch/src/app/pages/home/home.component.ts index 5d2b9ed..0738489 100644 --- a/bizmatch/src/app/pages/home/home.component.ts +++ b/bizmatch/src/app/pages/home/home.component.ts @@ -5,7 +5,6 @@ import { ActivatedRoute, Router, RouterModule } from '@angular/router'; import { NgSelectModule } from '@ng-select/ng-select'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { KeycloakService } from 'keycloak-angular'; -import onChange from 'on-change'; import { catchError, concat, debounceTime, distinctUntilChanged, Observable, of, Subject, Subscription, switchMap, tap } from 'rxjs'; import { BusinessListingCriteria, CityAndStateResult, CommercialPropertyListingCriteria, GeoResult, KeycloakUser, UserListingCriteria } from '../../../../../bizmatch-server/src/models/main.model'; import { ModalService } from '../../components/search-modal/modal.service'; @@ -15,7 +14,7 @@ import { ListingsService } from '../../services/listings.service'; import { SearchService } from '../../services/search.service'; import { SelectOptionsService } from '../../services/select-options.service'; import { UserService } from '../../services/user.service'; -import { compareObjects, createEmptyBusinessListingCriteria, createEmptyCommercialPropertyListingCriteria, createEmptyUserListingCriteria, getCriteriaStateObject, map2User } from '../../utils/utils'; +import { compareObjects, createEmptyBusinessListingCriteria, createEmptyCommercialPropertyListingCriteria, createEmptyUserListingCriteria, createEnhancedProxy, getCriteriaStateObject, map2User } from '../../utils/utils'; @UntilDestroy() @Component({ selector: 'app-home', @@ -55,10 +54,10 @@ export class HomeComponent { ) {} async ngOnInit() { const token = await this.keycloakService.getToken(); - sessionStorage.removeItem('business_criteria'); - sessionStorage.removeItem('commercialProperty_criteria'); - sessionStorage.removeItem('broker_criteria'); - this.criteria = this.createEnhancedProxy(getCriteriaStateObject('business')); + sessionStorage.removeItem('businessListings'); + sessionStorage.removeItem('commercialPropertyListings'); + sessionStorage.removeItem('brokerListings'); + this.criteria = createEnhancedProxy(getCriteriaStateObject('businessListings'), this); this.user = map2User(token); this.loadCities(); this.setupCriteriaChangeListener(); @@ -66,31 +65,31 @@ export class HomeComponent { async changeTab(tabname: 'business' | 'commercialProperty' | 'broker') { this.activeTabAction = tabname; if ('business' === tabname) { - this.criteria = this.createEnhancedProxy(getCriteriaStateObject('business')); + this.criteria = createEnhancedProxy(getCriteriaStateObject('businessListings'), this); } else if ('commercialProperty' === tabname) { - this.criteria = this.createEnhancedProxy(getCriteriaStateObject('commercialProperty')); + this.criteria = createEnhancedProxy(getCriteriaStateObject('commercialPropertyListings'), this); } else if ('broker' === tabname) { - this.criteria = this.createEnhancedProxy(getCriteriaStateObject('broker')); + this.criteria = createEnhancedProxy(getCriteriaStateObject('brokerListings'), this); } else { this.criteria = undefined; } } - private createEnhancedProxy(obj: any) { - const component = this; + // private createEnhancedProxy(obj: any) { + // const component = this; - const sessionStorageHandler = function (path, value, previous, applyData) { - let criteriaType = this.criteriaType; - sessionStorage.setItem(`${criteriaType}_criteria`, JSON.stringify(this)); - }; + // const sessionStorageHandler = function (path, value, previous, applyData) { + // let criteriaType = this.criteriaType; + // sessionStorage.setItem(`${criteriaType}_criteria`, JSON.stringify(this)); + // }; - return onChange(obj, function (path, value, previous, applyData) { - // Call the original sessionStorageHandler - sessionStorageHandler.call(this, path, value, previous, applyData); + // return onChange(obj, function (path, value, previous, applyData) { + // // Call the original sessionStorageHandler + // sessionStorageHandler.call(this, path, value, previous, applyData); - // Notify about the criteria change using the component's context - component.criteriaChangeService.notifyCriteriaChange(); - }); - } + // // Notify about the criteria change using the component's context + // component.criteriaChangeService.notifyCriteriaChange(); + // }); + // } search() { this.router.navigate([`${this.activeTabAction}Listings`]); } @@ -169,18 +168,18 @@ export class HomeComponent { } } getTypes() { - if (this.criteria.criteriaType === 'business') { + if (this.criteria.criteriaType === 'businessListings') { return this.selectOptions.typesOfBusiness; - } else if (this.criteria.criteriaType === 'commercialProperty') { + } else if (this.criteria.criteriaType === 'commercialPropertyListings') { return this.selectOptions.typesOfCommercialProperty; } else { return this.selectOptions.customerSubTypes; } } getPlaceholderLabel() { - if (this.criteria.criteriaType === 'business') { + if (this.criteria.criteriaType === 'businessListings') { return 'Business Type'; - } else if (this.criteria.criteriaType === 'commercialProperty') { + } else if (this.criteria.criteriaType === 'commercialPropertyListings') { return 'Property Type'; } else { return 'Professional Type'; @@ -189,9 +188,9 @@ export class HomeComponent { setTotalNumberOfResults() { if (this.criteria) { console.log(`Getting total number of results for ${this.criteria.criteriaType}`); - if (this.criteria.criteriaType === 'business' || this.criteria.criteriaType === 'commercialProperty') { - this.numberOfResults$ = this.listingService.getNumberOfListings(this.criteria, this.criteria.criteriaType); - } else if (this.criteria.criteriaType === 'broker') { + if (this.criteria.criteriaType === 'businessListings' || this.criteria.criteriaType === 'commercialPropertyListings') { + this.numberOfResults$ = this.listingService.getNumberOfListings(this.criteria, this.criteria.criteriaType === 'businessListings' ? 'business' : 'commercialProperty'); + } else if (this.criteria.criteriaType === 'brokerListings') { this.numberOfResults$ = this.userService.getNumberOfBroker(this.criteria); } else { this.numberOfResults$ = of(); @@ -199,11 +198,11 @@ export class HomeComponent { } } getNumberOfFiltersSet() { - if (this.criteria?.criteriaType === 'broker') { + if (this.criteria?.criteriaType === 'brokerListings') { return compareObjects(createEmptyUserListingCriteria(), this.criteria, ['start', 'length', 'page', 'searchType', 'radius']); - } else if (this.criteria?.criteriaType === 'business') { + } else if (this.criteria?.criteriaType === 'businessListings') { return compareObjects(createEmptyBusinessListingCriteria(), this.criteria, ['start', 'length', 'page', 'searchType', 'radius']); - } else if (this.criteria?.criteriaType === 'commercialProperty') { + } else if (this.criteria?.criteriaType === 'commercialPropertyListings') { return compareObjects(createEmptyCommercialPropertyListingCriteria(), this.criteria, ['start', 'length', 'page', 'searchType', 'radius']); } else { return 0; diff --git a/bizmatch/src/app/pages/listings/broker-listings/broker-listings.component.ts b/bizmatch/src/app/pages/listings/broker-listings/broker-listings.component.ts index abae681..111d4a9 100644 --- a/bizmatch/src/app/pages/listings/broker-listings/broker-listings.component.ts +++ b/bizmatch/src/app/pages/listings/broker-listings/broker-listings.component.ts @@ -53,10 +53,10 @@ export class BrokerListingsComponent { private route: ActivatedRoute, private searchService: SearchService, ) { - this.criteria = getCriteriaStateObject('broker'); + this.criteria = getCriteriaStateObject('brokerListings'); this.init(); this.searchService.currentCriteria.subscribe(criteria => { - if (criteria && criteria.criteriaType === 'broker') { + if (criteria && criteria.criteriaType === 'brokerListings') { this.criteria = criteria as UserListingCriteria; this.search(); } @@ -74,6 +74,7 @@ export class BrokerListingsComponent { this.users = usersReponse.results; this.totalRecords = usersReponse.totalCount; this.pageCount = this.totalRecords % LISTINGS_PER_PAGE === 0 ? this.totalRecords / LISTINGS_PER_PAGE : Math.floor(this.totalRecords / LISTINGS_PER_PAGE) + 1; + this.page = this.criteria.page ? this.criteria.page : 1; this.cdRef.markForCheck(); this.cdRef.detectChanges(); } diff --git a/bizmatch/src/app/pages/listings/business-listings/business-listings.component.ts b/bizmatch/src/app/pages/listings/business-listings/business-listings.component.ts index d7e34b5..1cea884 100644 --- a/bizmatch/src/app/pages/listings/business-listings/business-listings.component.ts +++ b/bizmatch/src/app/pages/listings/business-listings/business-listings.component.ts @@ -49,10 +49,10 @@ export class BusinessListingsComponent { private route: ActivatedRoute, private searchService: SearchService, ) { - this.criteria = getCriteriaStateObject('business'); + this.criteria = getCriteriaStateObject('businessListings'); this.init(); this.searchService.currentCriteria.subscribe(criteria => { - if (criteria && criteria.criteriaType === 'business') { + if (criteria && criteria.criteriaType === 'businessListings') { this.criteria = criteria as BusinessListingCriteria; this.search(); } @@ -66,11 +66,11 @@ export class BusinessListingsComponent { } async search() { - //this.listings = await this.listingsService.getListingsByPrompt(this.criteria); const listingReponse = await this.listingsService.getListings(this.criteria, 'business'); this.listings = listingReponse.results; this.totalRecords = listingReponse.totalCount; this.pageCount = this.totalRecords % LISTINGS_PER_PAGE === 0 ? this.totalRecords / LISTINGS_PER_PAGE : Math.floor(this.totalRecords / LISTINGS_PER_PAGE) + 1; + this.page = this.criteria.page ? this.criteria.page : 1; this.cdRef.markForCheck(); this.cdRef.detectChanges(); } diff --git a/bizmatch/src/app/pages/listings/commercial-property-listings/commercial-property-listings.component.ts b/bizmatch/src/app/pages/listings/commercial-property-listings/commercial-property-listings.component.ts index 851d900..65a94b2 100644 --- a/bizmatch/src/app/pages/listings/commercial-property-listings/commercial-property-listings.component.ts +++ b/bizmatch/src/app/pages/listings/commercial-property-listings/commercial-property-listings.component.ts @@ -48,10 +48,10 @@ export class CommercialPropertyListingsComponent { private route: ActivatedRoute, private searchService: SearchService, ) { - this.criteria = getCriteriaStateObject('commercialProperty'); + this.criteria = getCriteriaStateObject('commercialPropertyListings'); this.init(); this.searchService.currentCriteria.subscribe(criteria => { - if (criteria && criteria.criteriaType === 'commercialProperty') { + if (criteria && criteria.criteriaType === 'commercialPropertyListings') { this.criteria = criteria as CommercialPropertyListingCriteria; this.search(); } @@ -63,16 +63,12 @@ export class CommercialPropertyListingsComponent { this.states = statesResult.map(ls => ({ name: this.selectOptions.getState(ls.state as string), value: ls.state, count: ls.count })); this.search(); } - refine() { - this.criteria.start = 0; - this.criteria.page = 0; - this.search(); - } async search() { const listingReponse = await this.listingsService.getListings(this.criteria, 'commercialProperty'); this.listings = (listingReponse).results; this.totalRecords = (listingReponse).totalCount; this.pageCount = this.totalRecords % LISTINGS_PER_PAGE === 0 ? this.totalRecords / LISTINGS_PER_PAGE : Math.floor(this.totalRecords / LISTINGS_PER_PAGE) + 1; + this.page = this.criteria.page ? this.criteria.page : 1; this.cdRef.markForCheck(); this.cdRef.detectChanges(); } diff --git a/bizmatch/src/app/pages/subscription/account/account.component.html b/bizmatch/src/app/pages/subscription/account/account.component.html index b151945..2c5bf8f 100644 --- a/bizmatch/src/app/pages/subscription/account/account.component.html +++ b/bizmatch/src/app/pages/subscription/account/account.component.html @@ -71,13 +71,14 @@
--> - @if (!isAdmin()){ - - }@else{ + @if (isAdmin() && !id){
ADMIN
+ + }@else{ + } @if (isProfessional){
- - + + +
- +
-
- -
+ -
+
+
-
- - -
+ + + +