- {{ listing.title }}
- @if(listing.draft){
- Draft
+
+
+
+
+
+
+
+ @if(listings?.length > 0) {
+
+ @for (listing of listings; track listing.id) {
+
+ @if (listing.imageOrder?.length>0){
+

+ } @else {
+

}
-
-
{{ listing.location.name ? listing.location.name : listing.location.county }}
-
{{ listing.price | currency : 'USD' : 'symbol' : '1.0-0' }}
-
-
+
+
{{ selectOptions.getCommercialProperty(listing.type) }}
+
+
{{ selectOptions.getState(listing.location.state) }}
+
+ {{ getDaysListed(listing) }} days listed
+
+
+
+ {{ listing.title }}
+ @if(listing.draft){
+ Draft
+ }
+
+
{{ listing.location.name ? listing.location.name : listing.location.county }}
+
{{ listing.price | currency : 'USD' : 'symbol' : '1.0-0' }}
+
+
+
+
+ }
+ } @else if (listings?.length === 0){
+
+
+
+
+
There’s no listing here
+
Try changing your filters to
see listings
+
+
+
+
+
+
+
+ }
+ @if(pageCount > 1) {
+
}
- } @else if (listings?.length===0){
-
-
-
-
-
There’s no listing here
-
Try changing your filters to
see listings
-
-
-
-
-
-
-
- }
+
+
+
-@if(pageCount>1){
-
-}
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 e49304b..c974f5f 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
@@ -9,17 +9,19 @@ import { CommercialPropertyListingCriteria, LISTINGS_PER_PAGE, ResponseCommercia
import { environment } from '../../../../environments/environment';
import { PaginatorComponent } from '../../../components/paginator/paginator.component';
import { ModalService } from '../../../components/search-modal/modal.service';
+import { SearchModalCommercialComponent } from '../../../components/search-modal/search-modal-commercial.component';
import { CriteriaChangeService } from '../../../services/criteria-change.service';
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 { assignProperties, getCriteriaProxy, resetCommercialPropertyListingCriteria } from '../../../utils/utils';
+
@UntilDestroy()
@Component({
selector: 'app-commercial-property-listings',
standalone: true,
- imports: [CommonModule, FormsModule, RouterModule, PaginatorComponent],
+ imports: [CommonModule, FormsModule, RouterModule, PaginatorComponent, SearchModalCommercialComponent],
templateUrl: './commercial-property-listings.component.html',
styleUrls: ['./commercial-property-listings.component.scss', '../../pages.scss'],
})
@@ -41,6 +43,7 @@ export class CommercialPropertyListingsComponent {
page = 1;
pageCount = 1;
ts = new Date().getTime();
+
constructor(
public selectOptions: SelectOptionsService,
private listingsService: ListingsService,
@@ -54,6 +57,7 @@ export class CommercialPropertyListingsComponent {
private criteriaChangeService: CriteriaChangeService,
) {
this.criteria = getCriteriaProxy('commercialPropertyListings', this) as CommercialPropertyListingCriteria;
+ this.modalService.sendCriteria(this.criteria);
this.init();
this.searchService.currentCriteria.pipe(untilDestroyed(this)).subscribe(criteria => {
if (criteria && criteria.criteriaType === 'commercialPropertyListings') {
@@ -62,10 +66,13 @@ export class CommercialPropertyListingsComponent {
}
});
}
+
async ngOnInit() {}
+
async init() {
this.search();
}
+
async search() {
const listingReponse = await this.listingsService.getListings(this.criteria, 'commercialProperty');
this.listings = (listingReponse).results;
@@ -75,21 +82,26 @@ export class CommercialPropertyListingsComponent {
this.cdRef.markForCheck();
this.cdRef.detectChanges();
}
+
onPageChange(page: any) {
this.criteria.start = (page - 1) * LISTINGS_PER_PAGE;
this.criteria.length = LISTINGS_PER_PAGE;
this.criteria.page = page;
this.search();
}
+
reset() {
this.criteria.title = null;
}
+
getTS() {
return new Date().getTime();
}
+
getDaysListed(listing: CommercialPropertyListing) {
return dayjs().diff(listing.created, 'day');
}
+
// New methods for filter actions
clearAllFilters() {
// Reset criteria to default values
@@ -106,12 +118,10 @@ export class CommercialPropertyListingsComponent {
}
async openFilterModal() {
- // Open the search modal with current criteria
const modalResult = await this.modalService.showModal(this.criteria);
if (modalResult.accepted) {
- this.searchService.search(this.criteria);
- } else {
- this.criteria = assignProperties(this.criteria, modalResult.criteria);
+ this.criteria = assignProperties(this.criteria, modalResult.criteria); // Update criteria with modal result
+ this.searchService.search(this.criteria); // Trigger search with updated criteria
}
}
}