Add photo carousel to listing cards and fix tap-to-detail
Backend: include first 5 photo URLs from additional_info in GeoJSON streaming response, with fallback to photo_thumbnail. Frontend: replace single thumbnail with swipeable embla-carousel on compact cards. Remove window.open on card tap so clicking opens the detail bottom sheet instead of navigating to Rightmove.
This commit is contained in:
parent
f2e8d7d9f9
commit
4deed9911c
5 changed files with 87 additions and 14 deletions
|
|
@ -53,6 +53,17 @@ def convert_row_to_geojson(row: dict[str, Any], listing_type: str = "RENT") -> d
|
|||
else:
|
||||
last_seen_str = str(last_seen_val)
|
||||
|
||||
# Extract first 5 photo URLs from additional_info
|
||||
photos: list[str] = []
|
||||
additional_info = row.get('additional_info')
|
||||
if additional_info:
|
||||
if isinstance(additional_info, str):
|
||||
additional_info = json.loads(additional_info)
|
||||
images = additional_info.get('property', {}).get('images', [])
|
||||
photos = [img['url'] for img in images[:5] if isinstance(img, dict) and 'url' in img]
|
||||
if not photos and row.get('photo_thumbnail'):
|
||||
photos = [row['photo_thumbnail']]
|
||||
|
||||
properties: dict[str, Any] = {
|
||||
"id": row['id'],
|
||||
"listing_type": listing_type,
|
||||
|
|
@ -64,6 +75,7 @@ def convert_row_to_geojson(row: dict[str, Any], listing_type: str = "RENT") -> d
|
|||
"total_price": price,
|
||||
"url": f"https://www.rightmove.co.uk/properties/{row['id']}",
|
||||
"photo_thumbnail": row.get('photo_thumbnail'),
|
||||
"photos": photos,
|
||||
"last_seen": last_seen_str,
|
||||
"price_history": price_history,
|
||||
"agency": row.get('agency'),
|
||||
|
|
@ -98,6 +110,12 @@ def convert_to_geojson_feature(listing: RentListing | BuyListing) -> dict[str, A
|
|||
property_info = listing.additional_info.get("property", {}) if listing.additional_info else {}
|
||||
listing_type = "RENT" if isinstance(listing, RentListing) else "BUY"
|
||||
|
||||
# Extract first 5 photo URLs
|
||||
images = property_info.get('images', [])
|
||||
photos = [img['url'] for img in images[:5] if isinstance(img, dict) and 'url' in img]
|
||||
if not photos and listing.photo_thumbnail:
|
||||
photos = [listing.photo_thumbnail]
|
||||
|
||||
properties: dict[str, Any] = {
|
||||
"id": listing.id,
|
||||
"listing_type": listing_type,
|
||||
|
|
@ -109,6 +127,7 @@ def convert_to_geojson_feature(listing: RentListing | BuyListing) -> dict[str, A
|
|||
"total_price": listing.price,
|
||||
"url": listing.url,
|
||||
"photo_thumbnail": listing.photo_thumbnail,
|
||||
"photos": photos,
|
||||
"last_seen": listing.last_seen.isoformat(),
|
||||
"price_history": [item.to_dict() for item in listing.price_history],
|
||||
"agency": listing.agency,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue