feat: Initialize Angular SSR application with core pages, components, and server setup.

This commit is contained in:
Timo
2026-01-03 12:53:37 +01:00
parent 0ac17ef155
commit b52e47b653
28 changed files with 1115 additions and 461 deletions

View File

@@ -77,7 +77,7 @@ export class BusinessListingsComponent implements OnInit, OnDestroy {
private route: ActivatedRoute,
private seoService: SeoService,
private authService: AuthService,
) {}
) { }
async ngOnInit(): Promise<void> {
// Load user for favorites functionality
@@ -259,6 +259,47 @@ export class BusinessListingsComponent implements OnInit, OnDestroy {
}
}
/**
* Share a listing - opens native share dialog or copies to clipboard
*/
async shareListing(event: Event, listing: BusinessListing): Promise<void> {
event.stopPropagation();
event.preventDefault();
const url = `${window.location.origin}/business/${listing.slug || listing.id}`;
const title = listing.title || 'Business Listing';
// Try native share API first (works on mobile and some desktop browsers)
if (navigator.share) {
try {
await navigator.share({
title: title,
text: `Check out this business: ${title}`,
url: url,
});
} catch (err) {
// User cancelled or share failed - fall back to clipboard
this.copyToClipboard(url);
}
} else {
// Fallback: open Facebook share dialog
const encodedUrl = encodeURIComponent(url);
window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodedUrl}`, '_blank', 'width=600,height=400');
}
}
/**
* Copy URL to clipboard and show feedback
*/
private copyToClipboard(url: string): void {
navigator.clipboard.writeText(url).then(() => {
// Could add a toast notification here
console.log('Link copied to clipboard!');
}).catch(err => {
console.error('Failed to copy link:', err);
});
}
ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();