adding filters to my-listing (listingnumber), updated/new label

This commit is contained in:
2025-09-12 14:25:47 -05:00
parent d48cd7aa1d
commit 571cfb0e61
7 changed files with 187 additions and 17 deletions

View File

@@ -148,7 +148,16 @@ export class BusinessListingsComponent implements OnInit, OnDestroy {
if (!listing.location) return 'Location not specified';
return `${listing.location.name}, ${listing.location.state}`;
}
private isWithinDays(date: Date | string | undefined | null, days: number): boolean {
if (!date) return false;
return dayjs().diff(dayjs(date), 'day') < days;
}
getListingBadge(listing: BusinessListing): 'NEW' | 'UPDATED' | null {
if (this.isWithinDays(listing.created, 14)) return 'NEW'; // Priorität
if (this.isWithinDays(listing.updated, 14)) return 'UPDATED';
return null;
}
navigateToDetails(listingId: string): void {
this.router.navigate(['/details-business', listingId]);
}